first commit
This commit is contained in:
49
Modules/Supplier/app/Repositories/SupplierRepository.php
Normal file
49
Modules/Supplier/app/Repositories/SupplierRepository.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?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');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user