ClearBowl/api/app/Repositories/ProductsRepository.php

27 lines
519 B
PHP

<?php
namespace App\Repositories;
use App\Models\Product;
class ProductsRepository implements ProductsRepositoryInterface
{
public function create($data)
{
return Product::create($data);
}
public function paginate(array $filters)
{
$query = Product::query();
if(isset($filters['search'])){
$search = ucfirst($filters['search']);
$query->where('name', 'like', "${search}%");
}
return $query->paginate($filters['limit']);
}
}