30 lines
795 B
PHP
30 lines
795 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 Proveedor extends Model {
|
|
use UuidPrimaryKey, SoftDeletes;
|
|
|
|
protected $table = 'proveedores';
|
|
protected $hidden = ['created_at', 'updated_at', 'deleted_at'];
|
|
protected $fillable = [
|
|
'id', 'rut', 'nombre', 'descripcion',
|
|
'direccion', 'telefono', 'restaurante_id'
|
|
];
|
|
|
|
public static function findOrFail($id) {
|
|
$proveedor = Proveedor::find($id);
|
|
if(!$proveedor) throw new ModelNotFoundException("proveedor", $id);
|
|
return $proveedor;
|
|
}
|
|
|
|
public function restaurante() {
|
|
return $this->belongsTo(Restaurante::class);
|
|
}
|
|
}
|