leave type module setup
This commit is contained in:
@ -33,8 +33,7 @@ class LeaveController extends Controller
|
||||
{
|
||||
$data['leaves'] = $this->leaveRepository->findAll();
|
||||
$data['employeeList'] = $this->employeeRepository->pluck();
|
||||
|
||||
return view('leave::index', $data);
|
||||
return view('leave::leave.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +43,7 @@ class LeaveController extends Controller
|
||||
{
|
||||
$data['title'] = 'Create Leave';
|
||||
$data['employeeList'] = $this->employeeRepository->pluck();
|
||||
return view('leave::create', $data);
|
||||
return view('leave::leave.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +66,7 @@ class LeaveController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('leave::show');
|
||||
return view('leave::leave.show');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +78,7 @@ class LeaveController extends Controller
|
||||
|
||||
$data['leave'] = $this->leaveRepository->getLeaveById($id);
|
||||
|
||||
return view('leave::edit', $data);
|
||||
return view('leave::leave.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
80
Modules/Leave/app/Http/Controllers/LeaveTypeController.php
Normal file
80
Modules/Leave/app/Http/Controllers/LeaveTypeController.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Leave\Repositories\LeaveInterface;
|
||||
use Modules\Leave\Repositories\LeaveTypeInterface;
|
||||
|
||||
class LeaveTypeController extends Controller
|
||||
{
|
||||
|
||||
private $leaveRepository;
|
||||
private $leaveTypeRepository;
|
||||
|
||||
public function __construct(LeaveInterface $leaveRepository, LeaveTypeInterface $leaveTypeRepository)
|
||||
{
|
||||
$this->leaveRepository = $leaveRepository;
|
||||
$this->leaveTypeRepository = $leaveTypeRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['leaveTypes'] = $this->leaveTypeRepository->findAll();
|
||||
return view('leave::leave-type.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Leave Type';
|
||||
|
||||
return view('leave::leave-type.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('leave::leave-type.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('leave::leave-type.edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
26
Modules/Leave/app/Http/Requests/LeaveTypeRequest.php
Normal file
26
Modules/Leave/app/Http/Requests/LeaveTypeRequest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LeaveTypeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Leave extends Model
|
||||
{
|
||||
protected $table = 'leaves';
|
||||
protected $table = 'tbl_leaves';
|
||||
protected $primaryKey = 'leave_id';
|
||||
protected $guarded = [];
|
||||
|
||||
|
22
Modules/Leave/app/Models/LeaveType.php
Normal file
22
Modules/Leave/app/Models/LeaveType.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Leave\Database\factories\LeaveTypeFactory;
|
||||
|
||||
class LeaveType extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [];
|
||||
|
||||
protected static function newFactory(): LeaveTypeFactory
|
||||
{
|
||||
//return LeaveTypeFactory::new();
|
||||
}
|
||||
}
|
@ -6,7 +6,8 @@ use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Leave\Repositories\LeaveInterface;
|
||||
use Modules\Leave\Repositories\LeaveRepository;
|
||||
|
||||
use Modules\Leave\Repositories\LeaveTypeInterface;
|
||||
use Modules\Leave\Repositories\LeaveTypeRepository;
|
||||
|
||||
class LeaveServiceProvider extends ServiceProvider
|
||||
{
|
||||
@ -33,6 +34,8 @@ class LeaveServiceProvider extends ServiceProvider
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->bind(LeaveInterface::class, LeaveRepository::class);
|
||||
$this->app->bind(LeaveTypeInterface::class, LeaveTypeRepository::class);
|
||||
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
@ -60,7 +63,7 @@ class LeaveServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
|
||||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
@ -76,7 +79,7 @@ class LeaveServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
|
||||
$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);
|
||||
}
|
||||
|
||||
@ -85,14 +88,14 @@ class LeaveServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/'.$this->moduleNameLower);
|
||||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-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','')));
|
||||
$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);
|
||||
}
|
||||
|
||||
@ -108,8 +111,8 @@ class LeaveServiceProvider extends ServiceProvider
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
|
||||
$paths[] = $path.'/modules/'.$this->moduleNameLower;
|
||||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
|
12
Modules/Leave/app/Repositories/LeaveTypeInterface.php
Normal file
12
Modules/Leave/app/Repositories/LeaveTypeInterface.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Repositories;
|
||||
|
||||
interface LeaveTypeInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getLeaveById($leaveId);
|
||||
public function delete($leaveId);
|
||||
public function create(array $LeaveDetails);
|
||||
public function update($leaveId, array $newDetails);
|
||||
}
|
34
Modules/Leave/app/Repositories/LeaveTypeRepository.php
Normal file
34
Modules/Leave/app/Repositories/LeaveTypeRepository.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Repositories;
|
||||
|
||||
use Modules\Leave\Models\LeaveType;
|
||||
|
||||
class LeaveTypeRepository implements LeaveTypeInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return LeaveType::get();
|
||||
}
|
||||
|
||||
public function getLeaveById($leaveId)
|
||||
{
|
||||
return LeaveType::findOrFail($leaveId);
|
||||
}
|
||||
|
||||
public function delete($leaveId)
|
||||
{
|
||||
LeaveType::destroy($leaveId);
|
||||
}
|
||||
|
||||
public function create(array $leaveDetails)
|
||||
{
|
||||
return LeaveType::create($leaveDetails);
|
||||
}
|
||||
|
||||
public function update($leaveId, array $newDetails)
|
||||
{
|
||||
return LeaveType::where('leave_id', $leaveId)->update($newDetails);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user