52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Ingredient\Repositories;
|
|
|
|
use Modules\Ingredient\Models\Ingredient;
|
|
|
|
class IngredientRepository implements IngredientInterface
|
|
{
|
|
public function findAll()
|
|
{
|
|
return Ingredient::when(true, function ($query) {
|
|
|
|
})->paginate(20);
|
|
}
|
|
|
|
public function getIngredientById($IngredientId)
|
|
{
|
|
return Ingredient::findOrFail($IngredientId);
|
|
}
|
|
|
|
public function getIngredientByEmail($email)
|
|
{
|
|
return Ingredient::where('email', $email)->first();
|
|
}
|
|
|
|
public function getIngredientsByCategory($ingredientCategoryId)
|
|
{
|
|
return Ingredient::where('ingredient_category_id', $ingredientCategoryId)->pluck('name', 'id');
|
|
}
|
|
|
|
public function delete($IngredientId)
|
|
{
|
|
Ingredient::destroy($IngredientId);
|
|
}
|
|
|
|
public function create($IngredientDetails)
|
|
{
|
|
return Ingredient::create($IngredientDetails);
|
|
}
|
|
|
|
public function update($IngredientId, array $newDetails)
|
|
{
|
|
return Ingredient::whereId($IngredientId)->update($newDetails);
|
|
}
|
|
|
|
public function pluck()
|
|
{
|
|
return Ingredient::pluck('name', 'id');
|
|
}
|
|
|
|
}
|
|
|