first commit
This commit is contained in:
0
Modules/Asset/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Asset/app/Http/Controllers/.gitkeep
Normal file
102
Modules/Asset/app/Http/Controllers/AssetCategoryController.php
Normal file
102
Modules/Asset/app/Http/Controllers/AssetCategoryController.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Admin\Services\AdminService;
|
||||
use Modules\Asset\Repositories\AssetCategoryInterface;
|
||||
use Modules\Employee\Repositories\EmployeeRepository;
|
||||
|
||||
class AssetCategoryController extends Controller
|
||||
{
|
||||
private $assetCategoryRepository;
|
||||
private $adminService;
|
||||
private $employeeRepository;
|
||||
|
||||
|
||||
|
||||
public function __construct(AssetCategoryInterface $assetCategoryRepository, AdminService $adminService, EmployeeRepository $employeeRepository)
|
||||
{
|
||||
$this->assetCategoryRepository = $assetCategoryRepository;
|
||||
$this->adminService = $adminService;
|
||||
$this->employeeRepository = $employeeRepository;
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = "Asset Category Lists";
|
||||
$data['assetCategoryLists'] = $this->assetCategoryRepository->findAll();
|
||||
return view('asset::assetcategories.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = "Create AssetCategory";
|
||||
$data['editable'] = false;
|
||||
$data['assetCategoryLists'] = $this->assetCategoryRepository->pluck();
|
||||
$data['departmentList'] = $this->adminService->pluckDepartments();
|
||||
$data['employeeList'] = $this->employeeRepository->pluck();
|
||||
|
||||
|
||||
|
||||
|
||||
return view('asset::assetCategories.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->assetCategoryRepository->create($request->all());
|
||||
toastr()->success('AssetCategory Created Successfully.');
|
||||
return redirect()->route('assetCategory.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('asset::assetcategories.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = "Edit AssetCategory";
|
||||
$data['editable'] = true;
|
||||
$data['assetCategory'] = $this->assetCategoryRepository->getAssetCategoryById($id);
|
||||
return view('asset::assetcategories.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$this->assetCategoryRepository->update($id, $request->all());
|
||||
toastr()->success('AssetCategory Updated Successfully.');
|
||||
return redirect()->route('assetCategory.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
98
Modules/Asset/app/Http/Controllers/AssetController.php
Normal file
98
Modules/Asset/app/Http/Controllers/AssetController.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Asset\Repositories\AssetCategoryInterface;
|
||||
use Modules\Asset\Repositories\AssetCategoryRepository;
|
||||
use Modules\Asset\Repositories\AssetInterface;
|
||||
use Modules\Asset\Repositories\AssetRepository;
|
||||
use Modules\Employee\Repositories\EmployeeRepository;
|
||||
|
||||
class AssetController extends Controller
|
||||
{
|
||||
private $assetRepository;
|
||||
private $assetCategoryRepository;
|
||||
private $employeeRepository;
|
||||
|
||||
|
||||
|
||||
public function __construct(AssetInterface $assetRepository, AssetCategoryInterface $assetCategoryRepository, EmployeeRepository $employeeRepository)
|
||||
{
|
||||
$this->assetRepository = $assetRepository;
|
||||
$this->assetCategoryRepository = $assetCategoryRepository;
|
||||
$this->employeeRepository = $employeeRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = "Asset Lists";
|
||||
$data['assetLists'] = $this->assetRepository->findAll();
|
||||
return view('asset::assets.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = "Create Asset";
|
||||
$data['editable'] = false;
|
||||
$data['assetCategoryLists'] = $this->assetCategoryRepository->pluck();
|
||||
$data['employeeList'] = $this->employeeRepository->pluck();
|
||||
return view('asset::assets.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->assetRepository->create($request->all());
|
||||
toastr()->success('Asset Created Successfully.');
|
||||
return redirect()->route('asset.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('asset::assets.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = "Edit Asset";
|
||||
$data['editable'] = true;
|
||||
$data['assetCategoryLists'] = $this->assetCategoryRepository->pluck();
|
||||
$data['asset'] = $this->assetRepository->getAssetById($id);
|
||||
return view('asset::assets.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$this->assetRepository->update($id, $request->all());
|
||||
toastr()->success('Asset Updated Successfully.');
|
||||
return redirect()->route('asset.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
91
Modules/Asset/app/Http/Controllers/AssetDemandController.php
Normal file
91
Modules/Asset/app/Http/Controllers/AssetDemandController.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\asset\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Asset\Repositories\AssetDemandInterface;
|
||||
use Modules\Asset\Repositories\AssetDemandRepository;
|
||||
use Modules\Asset\Repositories\AssetInterface;
|
||||
use Modules\Asset\Repositories\AssetRepository;
|
||||
|
||||
class AssetDemandController extends Controller
|
||||
{
|
||||
private $assetDemandRepository;
|
||||
private $assetRepository;
|
||||
|
||||
public function __construct(AssetDemandInterface $assetDemandRepository, AssetInterface $assetRepository)
|
||||
{
|
||||
$this->assetDemandRepository = $assetDemandRepository;
|
||||
$this->assetRepository = $assetRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = "AssetDemand Lists";
|
||||
$data['assetDemandLists'] = $this->assetDemandRepository->findAll();
|
||||
return view('asset::assetdemands.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = "Create assetDemand";
|
||||
$data['editable'] = false;
|
||||
$data['availableAssetLists'] = $this->assetRepository->pluckAvailable();
|
||||
return view('asset::assetdemands.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->assetDemandRepository->create($request->all());
|
||||
toastr()->success('assetDemand Created Successfully.');
|
||||
return redirect()->route('assetDemand.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('asset::assetdemands.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = "Edit assetDemand";
|
||||
$data['editable'] = true;
|
||||
$data['assetDemand'] = $this->assetDemandRepository->getassetDemandById($id);
|
||||
return view('asset::assetdemands.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$this->assetDemandRepository->update($id, $request->all());
|
||||
toastr()->success('assetDemand Updated Successfully.');
|
||||
return redirect()->route('assetDemand.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
0
Modules/Asset/app/Http/Requests/.gitkeep
Normal file
0
Modules/Asset/app/Http/Requests/.gitkeep
Normal file
0
Modules/Asset/app/Models/.gitkeep
Normal file
0
Modules/Asset/app/Models/.gitkeep
Normal file
58
Modules/Asset/app/Models/Asset.php
Normal file
58
Modules/Asset/app/Models/Asset.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Asset\Database\factories\AssetFactory;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
class Asset extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'tbl_assets';
|
||||
protected $primaryKey = 'asset_id';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'asset_category_id',
|
||||
'name',
|
||||
'purchased_date',
|
||||
'purchased_from',
|
||||
'manufacturer',
|
||||
'model',
|
||||
'serial_number',
|
||||
'supplier',
|
||||
'condition',
|
||||
'warranty',
|
||||
'value',
|
||||
'asset_user',
|
||||
'status',
|
||||
'description',
|
||||
'remarks',
|
||||
'is_available',
|
||||
'approved_date',
|
||||
'approved_by',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_available' => 'boolean',
|
||||
];
|
||||
|
||||
public function assetCategory(){
|
||||
return $this->belongsTo(AssetCategory::class,'asset_category_id');
|
||||
}
|
||||
|
||||
public function employee(){
|
||||
return $this->belongsTo(Employee::class,'asset_user');
|
||||
}
|
||||
|
||||
public function approver(){
|
||||
return $this->belongsTo(Employee::class,'approved_by');
|
||||
}
|
||||
|
||||
}
|
24
Modules/Asset/app/Models/AssetCategory.php
Normal file
24
Modules/Asset/app/Models/AssetCategory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Asset\Database\factories\AssetCategoryFactory;
|
||||
|
||||
class AssetCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'tbl_asset_categories';
|
||||
protected $primaryKey = 'asset_category_id';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'status',
|
||||
'description',
|
||||
'remarks'
|
||||
];
|
||||
}
|
31
Modules/Asset/app/Models/AssetDemand.php
Normal file
31
Modules/Asset/app/Models/AssetDemand.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Asset\Database\factories\AssetDemandFactory;
|
||||
|
||||
class AssetDemand extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'tbl_asset_demands';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'department_id',
|
||||
'designation_id',
|
||||
'employee_id',
|
||||
'asset_id',
|
||||
'request_date',
|
||||
'status',
|
||||
'reason',
|
||||
'description',
|
||||
'remarks',
|
||||
'createdby',
|
||||
'updatedBy'
|
||||
];
|
||||
}
|
0
Modules/Asset/app/Observers/.gitkeep
Normal file
0
Modules/Asset/app/Observers/.gitkeep
Normal file
0
Modules/Asset/app/Providers/.gitkeep
Normal file
0
Modules/Asset/app/Providers/.gitkeep
Normal file
124
Modules/Asset/app/Providers/AssetServiceProvider.php
Normal file
124
Modules/Asset/app/Providers/AssetServiceProvider.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Asset\Repositories\AssetCategoryInterface;
|
||||
use Modules\Asset\Repositories\AssetCategoryRepository;
|
||||
use Modules\Asset\Repositories\AssetDemandInterface;
|
||||
use Modules\Asset\Repositories\AssetDemandRepository;
|
||||
use Modules\Asset\Repositories\AssetInterface;
|
||||
use Modules\Asset\Repositories\AssetRepository;
|
||||
|
||||
|
||||
class AssetServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Asset';
|
||||
|
||||
protected string $moduleNameLower = 'asset';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
$this->app->bind(AssetDemandInterface::class, AssetDemandRepository::class);
|
||||
$this->app->bind(AssetInterface::class, AssetRepository::class);
|
||||
$this->app->bind(AssetCategoryInterface::class, AssetCategoryRepository::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/'.$this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder','')));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
|
||||
$paths[] = $path.'/modules/'.$this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
49
Modules/Asset/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/Asset/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')->group(module_path('Asset', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Asset', '/routes/api.php'));
|
||||
}
|
||||
}
|
0
Modules/Asset/app/Repositories/.gitkeep
Normal file
0
Modules/Asset/app/Repositories/.gitkeep
Normal file
13
Modules/Asset/app/Repositories/AssetCategoryInterface.php
Normal file
13
Modules/Asset/app/Repositories/AssetCategoryInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Repositories;
|
||||
|
||||
interface AssetCategoryInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function pluck();
|
||||
public function getAssetCategoryById($assetCategoryId);
|
||||
public function delete($assetCategoryId);
|
||||
public function create(array $assetCategoryDetails);
|
||||
public function update($assetCategoryId, array $newDetails);
|
||||
}
|
39
Modules/Asset/app/Repositories/AssetCategoryRepository.php
Normal file
39
Modules/Asset/app/Repositories/AssetCategoryRepository.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Repositories;
|
||||
|
||||
use Modules\Asset\Models\AssetCategory;
|
||||
|
||||
|
||||
class AssetCategoryRepository implements AssetCategoryInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return AssetCategory::get();
|
||||
}
|
||||
|
||||
public function getAssetCategoryById($assetCategoryId)
|
||||
{
|
||||
return AssetCategory::findOrFail($assetCategoryId);
|
||||
}
|
||||
|
||||
public function delete($assetCategoryId)
|
||||
{
|
||||
AssetCategory::destroy($assetCategoryId);
|
||||
}
|
||||
|
||||
public function create(array $assetCategoryDetails)
|
||||
{
|
||||
return AssetCategory::create($assetCategoryDetails);
|
||||
}
|
||||
|
||||
public function update($assetCategoryId, array $newDetails)
|
||||
{
|
||||
return AssetCategory::where('asset_category_id', $assetCategoryId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck(){
|
||||
return AssetCategory::pluck('name','asset_category_id');
|
||||
}
|
||||
|
||||
}
|
12
Modules/Asset/app/Repositories/AssetDemandInterface.php
Normal file
12
Modules/Asset/app/Repositories/AssetDemandInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Repositories;
|
||||
|
||||
interface AssetDemandInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getAssetDemandById($assetDemandId);
|
||||
public function delete($assetDemandId);
|
||||
public function create(array $assetDemandDetails);
|
||||
public function update($assetDemandId, array $newDetails);
|
||||
}
|
36
Modules/Asset/app/Repositories/AssetDemandRepository.php
Normal file
36
Modules/Asset/app/Repositories/AssetDemandRepository.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Repositories;
|
||||
|
||||
use Modules\Asset\Models\AssetDemand;
|
||||
use Modules\Asset\Repositories\AssetDemandInterface;
|
||||
|
||||
|
||||
class AssetDemandRepository implements AssetDemandInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return AssetDemand::get();
|
||||
}
|
||||
|
||||
public function getAssetDemandById($assetDemandId)
|
||||
{
|
||||
return AssetDemand::findOrFail($assetDemandId);
|
||||
}
|
||||
|
||||
public function delete($assetDemandId)
|
||||
{
|
||||
AssetDemand::destroy($assetDemandId);
|
||||
}
|
||||
|
||||
public function create(array $assetDemandDetails)
|
||||
{
|
||||
return AssetDemand::create($assetDemandDetails);
|
||||
}
|
||||
|
||||
public function update($assetDemandId, array $newDetails)
|
||||
{
|
||||
return AssetDemand::where('id', $assetDemandId)->update($newDetails);
|
||||
}
|
||||
|
||||
}
|
13
Modules/Asset/app/Repositories/AssetInterface.php
Normal file
13
Modules/Asset/app/Repositories/AssetInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Asset\Repositories;
|
||||
|
||||
interface AssetInterface
|
||||
{
|
||||
public function pluckAvailable();
|
||||
public function findAll();
|
||||
public function getAssetById($assetId);
|
||||
public function delete($assetId);
|
||||
public function create(array $assetDetails);
|
||||
public function update($assetId, array $newDetails);
|
||||
}
|
40
Modules/Asset/app/Repositories/AssetRepository.php
Normal file
40
Modules/Asset/app/Repositories/AssetRepository.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user