StocksNew/Modules/Supplier/app/Repositories/SupplierRepository.php

50 lines
1.1 KiB
PHP
Raw Normal View History

2024-08-27 12:03:06 +00:00
<?php
namespace Modules\Supplier\Repositories;
use Modules\Supplier\Models\Supplier;
class SupplierRepository implements SupplierInterface
{
public function findAll()
{
return Supplier::when(true, function ($query) {
// if (auth()->user()->hasRole('Supplier')) {
// $user = \Auth::user();
// $query->where('id', $user->Supplier_id);
// }
})->paginate(20);
}
public function getSupplierById($SupplierId)
{
return Supplier::findOrFail($SupplierId);
}
public function getSupplierByEmail($email)
{
return Supplier::where('email', $email)->first();
}
public function delete($SupplierId)
{
Supplier::destroy($SupplierId);
}
public function create($SupplierDetails)
{
return Supplier::create($SupplierDetails);
}
public function update($SupplierId, array $newDetails)
{
return Supplier::whereId($SupplierId)->update($newDetails);
}
public function pluck()
{
return Supplier::pluck('supplier_name', 'id');
}
}