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