47 lines
866 B
PHP
47 lines
866 B
PHP
|
<?php
|
||
|
|
||
|
namespace Modules\Stock\Repositories;
|
||
|
|
||
|
use Modules\Stock\Models\Stock;
|
||
|
|
||
|
class StockRepository implements StockInterface
|
||
|
{
|
||
|
public function findAll()
|
||
|
{
|
||
|
return Stock::when(true, function ($query) {
|
||
|
|
||
|
})->paginate(20);
|
||
|
}
|
||
|
|
||
|
public function getStockById($StockId)
|
||
|
{
|
||
|
return Stock::findOrFail($StockId);
|
||
|
}
|
||
|
|
||
|
public function getStockByEmail($email)
|
||
|
{
|
||
|
return Stock::where('email', $email)->first();
|
||
|
}
|
||
|
|
||
|
public function delete($StockId)
|
||
|
{
|
||
|
Stock::destroy($StockId);
|
||
|
}
|
||
|
|
||
|
public function create($StockDetails)
|
||
|
{
|
||
|
return Stock::create($StockDetails);
|
||
|
}
|
||
|
|
||
|
public function update($StockId, array $newDetails)
|
||
|
{
|
||
|
return Stock::whereId($StockId)->update($newDetails);
|
||
|
}
|
||
|
|
||
|
public function pluck()
|
||
|
{
|
||
|
return Stock::pluck('title', 'id');
|
||
|
}
|
||
|
|
||
|
}
|