41 lines
760 B
PHP
41 lines
760 B
PHP
|
<?php
|
||
|
|
||
|
namespace Modules\Asset\Repositories;
|
||
|
|
||
|
use Modules\Asset\Models\Asset;
|
||
|
|
||
|
|
||
|
class AssetRepository implements AssetInterface
|
||
|
{
|
||
|
public function findAll()
|
||
|
{
|
||
|
return Asset::get();
|
||
|
}
|
||
|
|
||
|
public function getAssetById($assetId)
|
||
|
{
|
||
|
return Asset::findOrFail($assetId);
|
||
|
}
|
||
|
|
||
|
public function delete($assetId)
|
||
|
{
|
||
|
Asset::destroy($assetId);
|
||
|
}
|
||
|
|
||
|
public function create(array $assetDetails)
|
||
|
{
|
||
|
return Asset::create($assetDetails);
|
||
|
}
|
||
|
|
||
|
public function update($assetId, array $newDetails)
|
||
|
{
|
||
|
return Asset::where('asset_id', $assetId)->update($newDetails);
|
||
|
}
|
||
|
|
||
|
public function pluckAvailable()
|
||
|
{
|
||
|
return Asset::where('is_available', 1)->pluck('name', 'asset_id');
|
||
|
}
|
||
|
|
||
|
}
|