50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?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');
|
|
}
|
|
|
|
}
|