StocksNew/Modules/Product/app/Repositories/ProductRepository.php

52 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2024-08-27 12:03:06 +00:00
<?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();
}
2024-09-17 10:49:40 +00:00
public function getProductsByCategory($categoryId)
{
return Product::where('category_id', $categoryId)->pluck('name', 'id');
}
2024-08-27 12:03:06 +00:00
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');
}
}
2024-09-11 06:47:15 +00:00