26 lines
636 B
PHP
26 lines
636 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\UuidPrimaryKey;
|
|
use App\Exceptions\ModelNotFoundException;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Sector extends Model {
|
|
use UuidPrimaryKey, SoftDeletes;
|
|
|
|
protected $table = 'sectores';
|
|
protected $fillable = ['id', 'nombre', 'restaurante_id'];
|
|
|
|
public static function findOrFail($id) {
|
|
$sector = Sector::find($id);
|
|
if(!$sector) throw new ModelNotFoundException("sector", $id);
|
|
return $sector;
|
|
}
|
|
|
|
public function restaurante() {
|
|
return $this->belongsTo(Restaurante::class);
|
|
}
|
|
}
|