first commit
This commit is contained in:
0
Modules/Payroll/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Payroll/app/Http/Controllers/.gitkeep
Normal file
95
Modules/Payroll/app/Http/Controllers/PaymentController.php
Normal file
95
Modules/Payroll/app/Http/Controllers/PaymentController.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Payroll\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Employee\Repositories\EmployeeInterface;
|
||||
use Modules\Employee\Repositories\EmployeeRepository;
|
||||
use Modules\Payroll\Repositories\PaymentInterface;
|
||||
use Modules\Payroll\Repositories\PaymentRepository;
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
private $paymentRepository;
|
||||
private $employeeRepository;
|
||||
|
||||
public function __construct(PaymentInterface $paymentRepository, EmployeeInterface $employeeRepository)
|
||||
{
|
||||
$this->paymentRepository = $paymentRepository;
|
||||
$this->employeeRepository = $employeeRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = "Payment Lists";
|
||||
$data['paymentLists'] = $this->paymentRepository->findAll();
|
||||
return view('payroll::payments.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = "Create Payment";
|
||||
$data['editable'] = false;
|
||||
$data['employeeLists'] = $this->employeeRepository->pluck();
|
||||
return view('payroll::payments.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->paymentRepository->create($request->all());
|
||||
toastr()->success('Payment Created Successfully.');
|
||||
return redirect()->route('payment.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('payroll::payments.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = "Edit Payment";
|
||||
$data['editable'] = true;
|
||||
$data['payment'] = $this->paymentRepository->getPaymentById($id);
|
||||
return view('payroll::payments.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->paymentRepository->update($id, $request->all());
|
||||
toastr()->success('Payment Updated Successfully.');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('payment.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
67
Modules/Payroll/app/Http/Controllers/PayrollController.php
Normal file
67
Modules/Payroll/app/Http/Controllers/PayrollController.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Payroll\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class PayrollController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('payroll::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('payroll::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('payroll::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('payroll::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
0
Modules/Payroll/app/Http/Requests/.gitkeep
Normal file
0
Modules/Payroll/app/Http/Requests/.gitkeep
Normal file
0
Modules/Payroll/app/Models/.gitkeep
Normal file
0
Modules/Payroll/app/Models/.gitkeep
Normal file
42
Modules/Payroll/app/Models/Payment.php
Normal file
42
Modules/Payroll/app/Models/Payment.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Payroll\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Employee\Models\Employee;
|
||||
use Modules\Payroll\Database\factories\PaymentFactory;
|
||||
|
||||
class Payment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "tbl_payments";
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'account_no',
|
||||
'paid_date',
|
||||
'paid_amount',
|
||||
'payment_mode',
|
||||
'status',
|
||||
'description',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
];
|
||||
|
||||
const PAYMENT_MODE = [
|
||||
'check' => 'Check',
|
||||
'online' => 'Online',
|
||||
'cash' => 'Cash'
|
||||
];
|
||||
|
||||
public function employee(){
|
||||
return $this->belongsTo(Employee::class,'employee_id');
|
||||
}
|
||||
|
||||
}
|
0
Modules/Payroll/app/Observers/.gitkeep
Normal file
0
Modules/Payroll/app/Observers/.gitkeep
Normal file
0
Modules/Payroll/app/Providers/.gitkeep
Normal file
0
Modules/Payroll/app/Providers/.gitkeep
Normal file
118
Modules/Payroll/app/Providers/PayrollServiceProvider.php
Normal file
118
Modules/Payroll/app/Providers/PayrollServiceProvider.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Payroll\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Payroll\Repositories\PaymentInterface;
|
||||
use Modules\Payroll\Repositories\PaymentRepository;
|
||||
|
||||
class PayrollServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Payroll';
|
||||
|
||||
protected string $moduleNameLower = 'payroll';
|
||||
|
||||
/**
|
||||
* 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(PaymentInterface::class, PaymentRepository::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/Payroll/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/Payroll/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Payroll\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('Payroll', '/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('Payroll', '/routes/api.php'));
|
||||
}
|
||||
}
|
0
Modules/Payroll/app/Repositories/.gitkeep
Normal file
0
Modules/Payroll/app/Repositories/.gitkeep
Normal file
12
Modules/Payroll/app/Repositories/PaymentInterface.php
Normal file
12
Modules/Payroll/app/Repositories/PaymentInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Payroll\Repositories;
|
||||
|
||||
interface PaymentInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getPaymentById($paymentId);
|
||||
public function delete($paymentId);
|
||||
public function create(array $paymentDetails);
|
||||
public function update($paymentId, array $newDetails);
|
||||
}
|
34
Modules/Payroll/app/Repositories/PaymentRepository.php
Normal file
34
Modules/Payroll/app/Repositories/PaymentRepository.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Payroll\Repositories;
|
||||
|
||||
use Modules\Payroll\Models\Payment;
|
||||
|
||||
|
||||
class PaymentRepository implements PaymentInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Payment::get();
|
||||
}
|
||||
|
||||
public function getPaymentById($paymentId)
|
||||
{
|
||||
return Payment::findOrFail($paymentId);
|
||||
}
|
||||
|
||||
public function delete($paymentId)
|
||||
{
|
||||
Payment::destroy($paymentId);
|
||||
}
|
||||
|
||||
public function create(array $paymentDetails)
|
||||
{
|
||||
return Payment::create($paymentDetails);
|
||||
}
|
||||
|
||||
public function update($paymentId, array $newDetails)
|
||||
{
|
||||
return Payment::where('id', $paymentId)->update($newDetails);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user