IG
Size: a a a
IG
SM
SC
D
D
IG
IG
D
IG
D
IG
IG
IG
IG
В
id, weight, grind
id, quantity, temperature
drink_name, description, ingredient_type, ingredient_id
class Drink extends Model {
public function coffees(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphedByMany(Coffee::class, 'ingredient');
}
public function waters(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphedByMany(Water::class, 'ingredient');
}
}
class Coffee extends Model {
public function drinks(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphToMany(Drink::class, 'ingredient');
}
}
class Water extends Model {
public function drinks(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphToMany(Drink::class, 'ingredient');
}
}
public function show(string $recipe){
return Drink::with( 'coffees', 'waters')->findOrFail($recipe);
}
json
{
"name": "espresso",
"coffees": [
{
"id": 1,
"weight": 7,
"grind": "fine",
"pivot": {
"drink_name": "espresso",
"ingredient_id": 1,
"ingredient_type": "App\\Models\\Coffee"
}
}
],
"machines": [],
"milks": [],
"waters": [
{
"id": 1,
"quantity": 30,
"temperature": 90,
"pivot": {
"drink_name": "espresso",
"ingredient_id": 1,
"ingredient_type": "App\\Models\\Water"
}
}
]
}
IG
id, weight, grind
id, quantity, temperature
drink_name, description, ingredient_type, ingredient_id
class Drink extends Model {
public function coffees(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphedByMany(Coffee::class, 'ingredient');
}
public function waters(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphedByMany(Water::class, 'ingredient');
}
}
class Coffee extends Model {
public function drinks(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphToMany(Drink::class, 'ingredient');
}
}
class Water extends Model {
public function drinks(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphToMany(Drink::class, 'ingredient');
}
}
public function show(string $recipe){
return Drink::with( 'coffees', 'waters')->findOrFail($recipe);
}
json
{
"name": "espresso",
"coffees": [
{
"id": 1,
"weight": 7,
"grind": "fine",
"pivot": {
"drink_name": "espresso",
"ingredient_id": 1,
"ingredient_type": "App\\Models\\Coffee"
}
}
],
"machines": [],
"milks": [],
"waters": [
{
"id": 1,
"quantity": 30,
"temperature": 90,
"pivot": {
"drink_name": "espresso",
"ingredient_id": 1,
"ingredient_type": "App\\Models\\Water"
}
}
]
}
D
id, weight, grind
id, quantity, temperature
drink_name, description, ingredient_type, ingredient_id
class Drink extends Model {
public function coffees(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphedByMany(Coffee::class, 'ingredient');
}
public function waters(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphedByMany(Water::class, 'ingredient');
}
}
class Coffee extends Model {
public function drinks(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphToMany(Drink::class, 'ingredient');
}
}
class Water extends Model {
public function drinks(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphToMany(Drink::class, 'ingredient');
}
}
public function show(string $recipe){
return Drink::with( 'coffees', 'waters')->findOrFail($recipe);
}
json
{
"name": "espresso",
"coffees": [
{
"id": 1,
"weight": 7,
"grind": "fine",
"pivot": {
"drink_name": "espresso",
"ingredient_id": 1,
"ingredient_type": "App\\Models\\Coffee"
}
}
],
"machines": [],
"milks": [],
"waters": [
{
"id": 1,
"quantity": 30,
"temperature": 90,
"pivot": {
"drink_name": "espresso",
"ingredient_id": 1,
"ingredient_type": "App\\Models\\Water"
}
}
]
}
Gt
id, weight, grind
id, quantity, temperature
drink_name, description, ingredient_type, ingredient_id
class Drink extends Model {
public function coffees(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphedByMany(Coffee::class, 'ingredient');
}
public function waters(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphedByMany(Water::class, 'ingredient');
}
}
class Coffee extends Model {
public function drinks(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphToMany(Drink::class, 'ingredient');
}
}
class Water extends Model {
public function drinks(): \Illuminate\Database\Eloquent\Relations\MorphToMany {
return $this->morphToMany(Drink::class, 'ingredient');
}
}
public function show(string $recipe){
return Drink::with( 'coffees', 'waters')->findOrFail($recipe);
}
json
{
"name": "espresso",
"coffees": [
{
"id": 1,
"weight": 7,
"grind": "fine",
"pivot": {
"drink_name": "espresso",
"ingredient_id": 1,
"ingredient_type": "App\\Models\\Coffee"
}
}
],
"machines": [],
"milks": [],
"waters": [
{
"id": 1,
"quantity": 30,
"temperature": 90,
"pivot": {
"drink_name": "espresso",
"ingredient_id": 1,
"ingredient_type": "App\\Models\\Water"
}
}
]
}
Gt