Categorias
This commit is contained in:
@@ -10,6 +10,14 @@ 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);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use App\Models\CanalVenta;
|
||||
use App\Models\Sector;
|
||||
use App\Models\ZonaProduccion;
|
||||
use App\Models\Categoria;
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use App\Exceptions\ModelNotFoundException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -40,4 +41,8 @@ class Restaurante extends Model {
|
||||
public function zonasProduccion() {
|
||||
return $this->hasMany(ZonaProduccion::class, 'restaurante_id');
|
||||
}
|
||||
|
||||
public function categorias() {
|
||||
return $this->hasMany(Categoria::class, 'restaurante_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user