Files
Sistema-Educativo-Laravel/app/Models/Plan.php
T

29 lines
567 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Plan extends Model
{
protected $guarded = [];
public function planesPlantel() : BelongsToMany
{
return $this->belongsToMany(Plantel::class)->withPivot('plantel_id');
}
public function existe($plantelId = null)
{
if (!$plantelId) {
return false;
}
return $this->planesPlantel()
->wherePivot('plantel_id', $plantelId)
->exists();
}
}