47 lines
856 B
PHP
47 lines
856 B
PHP
|
<?php
|
||
|
|
||
|
namespace Modules\Ingredient\Repositories;
|
||
|
|
||
|
use Modules\Ingredient\Models\Unit;
|
||
|
|
||
|
class UnitRepository implements UnitInterface
|
||
|
{
|
||
|
public function findAll()
|
||
|
{
|
||
|
return Unit::when(true, function ($query) {
|
||
|
|
||
|
})->paginate(20);
|
||
|
}
|
||
|
|
||
|
public function getUnitById($UnitId)
|
||
|
{
|
||
|
return Unit::findOrFail($UnitId);
|
||
|
}
|
||
|
|
||
|
public function getUnitByEmail($email)
|
||
|
{
|
||
|
return Unit::where('email', $email)->first();
|
||
|
}
|
||
|
|
||
|
public function delete($UnitId)
|
||
|
{
|
||
|
Unit::destroy($UnitId);
|
||
|
}
|
||
|
|
||
|
public function create($UnitDetails)
|
||
|
{
|
||
|
return Unit::create($UnitDetails);
|
||
|
}
|
||
|
|
||
|
public function update($UnitId, array $newDetails)
|
||
|
{
|
||
|
return Unit::whereId($UnitId)->update($newDetails);
|
||
|
}
|
||
|
|
||
|
public function pluck()
|
||
|
{
|
||
|
return Unit::pluck('title', 'id');
|
||
|
}
|
||
|
|
||
|
}
|