40 lines
805 B
PHP
40 lines
805 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 $timestamps = false;
|
|
|
|
public function existe($plantelId = null)
|
|
{
|
|
if (!$plantelId) {
|
|
return false;
|
|
}
|
|
|
|
return $this->planesPlantel()
|
|
->wherePivot('plantel_id', $plantelId)
|
|
->exists();
|
|
}
|
|
|
|
public function carreraRel()
|
|
{
|
|
return $this->belongsTo(Carrera::class, 'carrera');
|
|
}
|
|
|
|
public function nivelRel()
|
|
{
|
|
return $this->belongsTo(Nivel::class, 'nivel');
|
|
}
|
|
|
|
}
|