46 lines
960 B
PHP
46 lines
960 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Plantel;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Nivel extends Model
|
|
{
|
|
protected $guarded = [];
|
|
|
|
public $timestamps = false;
|
|
|
|
public function nivelPlantel() : BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Plantel::class)->withPivot('plantel_id');
|
|
}
|
|
|
|
public function nivelPlane() : BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Plane::class);
|
|
}
|
|
|
|
public function existe($plantelId = null)
|
|
{
|
|
if (!$plantelId) {
|
|
return false;
|
|
}
|
|
|
|
return $this->nivelPlantel()
|
|
->wherePivot('plantel_id', $plantelId)
|
|
->exists();
|
|
}
|
|
|
|
public function documentosRequeridos()
|
|
{
|
|
return $this->belongsToMany(
|
|
DocumentoTipo::class,
|
|
'nivel_documento',
|
|
'nivel_id',
|
|
'documento_tipo_id'
|
|
);
|
|
}
|
|
}
|