Mantenedor Ingredientes
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,7 +11,13 @@ class Ingrediente extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'ingredientes';
|
||||
protected $fillable = ['id', 'nombre', 'medida', 'restaurante_id'];
|
||||
|
||||
public static function findOrFail($id) {
|
||||
$ingrediente = Ingrediente::find($id);
|
||||
if(!$ingrediente) throw new ModelNotFoundException("ingrediente", $id);
|
||||
return $ingrediente;
|
||||
}
|
||||
|
||||
public function recetas() {
|
||||
return $this->hasMany(Receta::class, 'ingrediente_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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use App\Exceptions\ModelNotFoundException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Receta extends Model {
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\Sector;
|
||||
use App\Models\ZonaProduccion;
|
||||
use App\Models\Categoria;
|
||||
use App\Models\Proveedor;
|
||||
use App\Models\Ingrediente;
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use App\Exceptions\ModelNotFoundException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -50,4 +51,8 @@ class Restaurante extends Model {
|
||||
public function proveedores() {
|
||||
return $this->hasMany(Proveedor::class, 'restaurante_id');
|
||||
}
|
||||
|
||||
public function ingredientes() {
|
||||
return $this->hasMany(Ingrediente::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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user