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