StocksNew/Modules/Stock/app/Repositories/StockRepository.php

52 lines
1007 B
PHP
Raw Normal View History

2024-09-11 06:47:15 +00:00
<?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();
}
2024-09-17 10:49:40 +00:00
public function getStocksByProduct($productId)
{
return Stock::where('product_id', $productId)->pluck('title', 'id');
}
2024-09-11 06:47:15 +00:00
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');
}
}