first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View 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)
{
//
}
}

View 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)
{
//
}
}

View File

View 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');
}
}

View File

View File

View 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;
}
}

View 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'));
}
}

View 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);
}

View 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);
}
}

View File

@ -0,0 +1,30 @@
{
"name": "nwidart/payroll",
"description": "",
"authors": [
{
"name": "Nicolas Widart",
"email": "n.widart@gmail.com"
}
],
"extra": {
"laravel": {
"providers": [],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\Payroll\\": "app/",
"Modules\\Payroll\\Database\\Factories\\": "database/factories/",
"Modules\\Payroll\\Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Modules\\Payroll\\Tests\\": "tests/"
}
}
}

View File

View File

@ -0,0 +1,5 @@
<?php
return [
'name' => 'Payroll',
];

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tbl_payments', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('employee_id')->nullable();
$table->text('account_no')->nullable();
$table->date('payment_date')->nullable();
$table->decimal('payment_amount')->nullable();
$table->string('payment_mode')->nullable();
$table->integer('status')->default(11);
$table->mediumText('description');
$table->mediumText('remarks');
$table->unsignedBigInteger('createdBy');
$table->unsignedBigInteger('updatedBy');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tbl_payments');
}
};

View File

@ -0,0 +1,16 @@
<?php
namespace Modules\Payroll\database\seeders;
use Illuminate\Database\Seeder;
class PayrollDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// $this->call([]);
}
}

View File

@ -0,0 +1,11 @@
{
"name": "Payroll",
"alias": "payroll",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Payroll\\Providers\\PayrollServiceProvider"
],
"files": []
}

View File

@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.5",
"sass": "^1.69.5",
"postcss": "^8.3.7",
"vite": "^4.0.0"
}
}

View File

View File

@ -0,0 +1,7 @@
@extends('payroll::layouts.master')
@section('content')
<h1>Hello World</h1>
<p>Module: {!! config('payroll.name') !!}</p>
@endsection

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Payroll Module - {{ config('app.name', 'Laravel') }}</title>
<meta name="description" content="{{ $description ?? '' }}">
<meta name="keywords" content="{{ $keywords ?? '' }}">
<meta name="author" content="{{ $author ?? '' }}">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
{{-- Vite CSS --}}
{{-- {{ module_vite('build-payroll', 'resources/assets/sass/app.scss') }} --}}
</head>
<body>
@yield('content')
{{-- Vite JS --}}
{{-- {{ module_vite('build-payroll', 'resources/assets/js/app.js') }} --}}
</body>

View File

@ -0,0 +1,23 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
@include('layouts.partials.breadcrumb', ['title' => $title])
<!-- end page title -->
<div class='card'>
<div class='card-body'>
{{ html()->form('POST')->route('payment.store')->class(['needs-validation'])->attributes(['novalidate'])->open() }}
@include('payroll::payments.partials.action')
{{ html()->form()->close() }}
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,23 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
@include('layouts.partials.breadcrumb', ['title' => $title])
<!-- end page title -->
<div class='card'>
<div class='card-body'>
{{ html()->modelForm($payments, 'PUT')->route('payments.update', $payments->payments_id)->class(['needs-validation'])->attributes(['novalidate'])->open() }}
@include('payroll::paymentss.partials.action')
{{ html()->form()->close() }}
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,79 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
@include('layouts.partials.breadcrumb', ['title' => $title])
<!-- end page title -->
<div class="card">
<div class="card-header align-items-center d-flex">
<h5 class="card-title flex-grow-1 mb-0">{{ $title }}</h5>
<div class="flex-shrink-0">
<a href="{{ route('payment.create') }}" class="btn btn-success waves-effect waves-light"><i
class="ri-add-fill me-1 align-bottom"></i> Create Payment</a>
</div>
</div>
<div class="card-body">
<table id="buttons-datatables" class="display table-sm table-bordered table">
<thead class="table-light">
<tr>
<th class="tb-col"><span class="overline-title">S.N</span></th>
<th class="tb-col"><span class="overline-title">Department</span></th>
<th class="tb-col"><span class="overline-title">Employee Name</span></th>
<th class="tb-col"><span class="overline-title">Payment Date</span></th>
<th class="tb-col"><span class="overline-title">Payment Amount</span></th>
<th class="tb-col"><span class="overline-title">Payment Mode</span></th>
<th class="tb-col"><span class="overline-title">Status</span></th>
<th class="tb-col" data-sortable="false"><span class="overline-title">Action</span>
</th>
</tr>
</thead>
<tbody>
@foreach ($paymentLists as $index => $item)
<tr>
<td class="tb-col">{{ $index + 1 }}</td>
<td class="tb-col">{{ $item->department_id }}</td>
<td class="tb-col">{{ $item->employee_id }}</td>
<td class="tb-col">{{ $item->payment_date }}</td>
<td class="tb-col">{{ $item->payment_amount }}</td>
<td class="tb-col">{{ $item->payment_mode }}</td>
<td class="tb-col">{{ $item->status }}</td>
<td class="tb-col">
<div class="dropdown d-inline-block">
<button class="btn btn-soft-secondary btn-sm dropdown" type="button" data-bs-toggle="dropdown"
aria-expanded="false">
<i class="ri-more-fill align-middle"></i>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li><a href="{{ route('payment.show', [$item->payment_category_id]) }}" class="dropdown-item"><i
class="ri-eye-fill text-muted me-2 align-bottom"></i> View</a>
</li>
<li><a href="{{ route('payment.edit', [$item->payment_category_id]) }}"
class="dropdown-item edit-item-btn"><i
class="ri-pencil-fill text-muted me-2 align-bottom"></i>
Edit</a>
</li>
<li>
<a href="{{ route('appreciation.destroy', [$item->payment_category_id]) }}"
class="dropdown-item remove-item-btn" onclick="confirmDelete(this.href)">
<i class="ri-delete-bin-fill text-muted me-2 align-bottom"></i> Delete
</a>
</li>
</ul>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,41 @@
<div class="row gy-3">
<div class="col-lg-4 col-md-6">
{{ html()->label('Employee')->class('form-label') }}
{{ html()->select('employee_id', $employeeLists)->class('form-select select2')->placeholder('Employee Name') }}
</div>
<div class="col-lg-4 col-md-6">
{{ html()->label('Account Number')->class('form-label') }}
{{ html()->text('account_no')->class('form-control')->placeholder('Bank Account Number') }}
</div>
<div class="col-lg-4 col-md-6">
{{ html()->label('Payment Date')->class('form-label') }}
{{ html()->date('payment_date')->class('form-control')}}
</div>
<div class="col-lg-4 col-md-6">
{{ html()->label('Payment Amount')->class('form-label') }}
{{ html()->number('payment_amount')->class('form-control')->placeholder('total Amount in RS.')}}
</div>
<div class="col-lg-4 col-md-6">
{{ html()->label('Payment Mode')->class('form-label') }}
{{ html()->select('payment_mode', \Modules\Payroll\Models\Payment::PAYMENT_MODE)->class('form-select select2')->placeholder('Payment Mode') }}
</div>
<div class="col-lg-12 col-md-12">
{{ html()->label('Description')->class('form-label') }}
{{ html()->textarea('description')->class('form-control')->placeholder('Payment Description')->attributes(['rows' => 3]) }}
</div>
<div class="col-lg-12 col-md-12">
{{ html()->label('Remarks')->class('form-label') }}
{{ html()->textarea('remarks')->class('form-control')->attributes(['rows' => 3]) }}
</div>
<div class="text-end">
{{ html()->button($editable ? 'Update' : 'Add Payment', 'submit')->class('btn btn-success') }}
</div>
</div>

View File

@ -0,0 +1,48 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
@include('layouts.partials.breadcrumb', ['title' => $title])
<!-- end page title -->
<div class='card'>
<div class="card-header align-items-center d-flex">
<h5 class="card-title flex-grow-1 mb-0">View Detail</h5>
<div class="flex-shrink-0">
<a href="{{ route('designations.index') }}" class="btn btn-success waves-effect waves-light"><i
class="ri-add-fill me-1 align-bottom"></i> Back to List</a>
</div>
</div>
<div class='card-body'>
<p><b>Title :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span>{{ $data->title }}</span></p>
<p><b>Alias :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span>{{ $data->alias }}</span></p>
<p><b>Status :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span
class="{{ $data->status == 1 ? 'text-success' : 'text-danger' }}">{{ $data->status == 1 ? 'Active' : 'Inactive' }}</span>
</p>
<p><b>Remarks :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span>{{ $data->remarks }}</span></p>
<p><b>Display Order :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span>{{ $data->display_order }}</span></p>
<p><b>Createdby :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span>{{ $data->createdby }}</span></p>
<p><b>Updatedby :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span>{{ $data->updatedby }}</span></p>
<p><b>Job Description :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span>{{ $data->job_description }}</span></p>
<p><b>Departments Id :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span>{{ $data->departments_id }}</span></p>
<div class="d-flex justify-content-between">
<div>
<p><b>Created On :</b>&nbsp;&nbsp;&nbsp;<span>{{ $data->created_at }}</span></p>
<p><b>Created By :</b>&nbsp;&nbsp;&nbsp;<span>{{ $data->createdBy }}</span></p>
</div>
<div>
<p><b>Updated On :</b>&nbsp;&nbsp;&nbsp;<span>{{ $data->updated_at }}</span></p>
<p><b>Updated By :</b>&nbsp;&nbsp;&nbsp;<span>{{ $data->updatedBy }}</span></p>
</div>
</div>
</div>
</div>
</div>
</div>
@endSection

View File

View File

@ -0,0 +1,19 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Payroll\Http\Controllers\PayrollController;
/*
*--------------------------------------------------------------------------
* API Routes
*--------------------------------------------------------------------------
*
* Here is where you can register API routes for your application. These
* routes are loaded by the RouteServiceProvider within a group which
* is assigned the "api" middleware group. Enjoy building your API!
*
*/
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
Route::apiResource('payroll', PayrollController::class)->names('payroll');
});

View File

@ -0,0 +1,21 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Payroll\Http\Controllers\PaymentController;
use Modules\Payroll\Http\Controllers\PayrollController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::group([], function () {
Route::resource('payroll', PayrollController::class)->names('payroll');
Route::resource('payment', PaymentController::class)->names('payment');
});

View File

@ -0,0 +1,26 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
build: {
outDir: '../../public/build-payroll',
emptyOutDir: true,
manifest: true,
},
plugins: [
laravel({
publicDirectory: '../../public',
buildDirectory: 'build-payroll',
input: [
__dirname + '/resources/assets/sass/app.scss',
__dirname + '/resources/assets/js/app.js'
],
refresh: true,
}),
],
});
//export const paths = [
// 'Modules/Payroll/resources/assets/sass/app.scss',
// 'Modules/Payroll/resources/assets/js/app.js',
//];