crud de canales de venta y sectores
This commit is contained in:
@@ -11,6 +11,7 @@ class CanalVenta extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'canales_venta';
|
||||
protected $fillable = ['id', 'nombre', 'restaurante_id', 'sector_id', 'tipo_canal_id'];
|
||||
|
||||
public static function findOrFail($id) {
|
||||
$canal_venta = CanalVenta::find($id);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\CanalVenta;
|
||||
use App\Models\Sector;
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use App\Exceptions\ModelNotFoundException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -30,4 +31,8 @@ class Restaurante extends Model {
|
||||
public function canalesVenta() {
|
||||
return $this->hasMany(CanalVenta::class, 'restaurante_id');
|
||||
}
|
||||
|
||||
public function sectores() {
|
||||
return $this->hasMany(Sector::class, 'restaurante_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use App\Exceptions\ModelNotFoundException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -10,6 +11,13 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user