first commit
This commit is contained in:
46
Modules/Product/app/Repositories/ProductRepository.php
Normal file
46
Modules/Product/app/Repositories/ProductRepository.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\Repositories;
|
||||
|
||||
use Modules\Product\Models\Product;
|
||||
|
||||
class ProductRepository implements ProductInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Product::when(true, function ($query) {
|
||||
|
||||
})->paginate(20);
|
||||
}
|
||||
|
||||
public function getProductById($ProductId)
|
||||
{
|
||||
return Product::findOrFail($ProductId);
|
||||
}
|
||||
|
||||
public function getProductByEmail($email)
|
||||
{
|
||||
return Product::where('email', $email)->first();
|
||||
}
|
||||
|
||||
public function delete($ProductId)
|
||||
{
|
||||
Product::destroy($ProductId);
|
||||
}
|
||||
|
||||
public function create($ProductDetails)
|
||||
{
|
||||
return Product::create($ProductDetails);
|
||||
}
|
||||
|
||||
public function update($ProductId, array $newDetails)
|
||||
{
|
||||
return Product::whereId($ProductId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck()
|
||||
{
|
||||
return Product::pluck('name', 'id');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user