first change

This commit is contained in:
2025-07-27 17:40:56 +05:45
commit f8b9a6725b
3152 changed files with 229528 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
<?php
namespace Modules\Product\Repositories;
use Modules\Product\Interfaces\ProductInterface;
use Modules\Product\Models\Product;
class ProductRepository implements ProductInterface
{
public function findAll()
{
return Product::get();
}
public function getProductById($productId)
{
return Product::findOrFail($productId);
}
public function getProductList()
{
$products = Product::with('client:id,name')->get();
$keyed = $products->mapWithKeys(function (Product $item) {
return [$item->id => $item->name.' ('.$item->client?->name.')'];
});
return $keyed->all();
}
public function create(array $productDetails)
{
return Product::create($productDetails);
}
public function update($productId, array $newDetails)
{
return Product::whereId($productId)->update($newDetails);
}
public function delete($productId)
{
return Product::destroy($productId);
}
public function pluck()
{
return Product::pluck('name', 'id');
}
public function count()
{
return Product::count();
}
public function client()
{
return Product::with('client');
}
}