firstcommit

This commit is contained in:
2024-05-16 09:31:08 +05:45
commit 34d9672cb8
1396 changed files with 86482 additions and 0 deletions

View File

@ -0,0 +1,132 @@
<?php
namespace Modules\Billing\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Billing\Repositories\BillingComponentInterface;
use Modules\Admin\Repositories\FieldInterface;
use Illuminate\Support\Str;
class BillingComponentController extends Controller
{
private $fieldRepository;
private $billingComponentRepository;
public function __construct(
FieldInterface $fieldRepository,
BillingComponentInterface $billingComponentRepository
) {
$this->fieldRepository = $fieldRepository;
$this->billingComponentRepository = $billingComponentRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'Billing Component List';
$data['billingComponentList'] = $this->billingComponentRepository->findAll();
return view('billing::billingComponent.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Billing Component';
$data['editable'] = false;
return view('billing::billingComponent.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$request->mergeIfMissing([
'alias' => Str::slug($request->title),
]);
try {
$this->billingComponentRepository->create($request->all());
toastr()->success('BillingComponent Created Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('billingComponent.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('billing::billingComponent.show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Billing Component';
$data['editable'] = true;
$data['billingComponent'] = $this->billingComponentRepository->getBillingComponentById($id);
return view('billing::billingComponent.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$request->mergeIfMissing([
'alias' => Str::slug($request->title),
]);
$inputData = $request->except(['_method', '_token']);
try {
$this->billingComponentRepository->update($id, $inputData);
toastr()->success('BillingComponent Update Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('billingComponent.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$this->billingComponentRepository->delete($id);
toastr()->success('BillingComponent Deleted Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json([
'status' => true,
]);
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace Modules\Billing\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class BillingController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
return view('billing::index');
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('billing::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
//
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('billing::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('billing::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,29 @@
<?php
namespace Modules\Billing\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Billing\Database\Factories\BillingComponentFactory;
class BillingComponent extends Model
{
use HasFactory;
protected $table = 'tbl_billing_components';
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'title',
'alias',
'unit',
'price',
'taxable',
'createdBy',
'updatedBy',
'remarks',
'status'
];
}

View File

View File

View File

@ -0,0 +1,123 @@
<?php
namespace Modules\Billing\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Modules\Billing\Repositories\BillingComponentInterface;
use Modules\Billing\Repositories\BillingComponentRepository;
class BillingServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Billing';
protected string $moduleNameLower = 'billing';
/**
* 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(EventServiceProvider::class);
$this->app->register(RouteServiceProvider::class);
$this->app->bind(BillingComponentInterface::class, BillingComponentRepository::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.
*
* @return array<string>
*/
public function provides(): array
{
return [];
}
/**
* @return array<string>
*/
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,32 @@
<?php
namespace Modules\Billing\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event handler mappings for the application.
*
* @var array<string, array<int, string>>
*/
protected $listen = [];
/**
* Indicates if events should be discovered.
*
* @var bool
*/
protected static $shouldDiscoverEvents = true;
/**
* Configure the proper event listeners for email verification.
*
* @return void
*/
protected function configureEmailVerification(): void
{
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace Modules\Billing\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('Billing', '/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('Billing', '/routes/api.php'));
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace Modules\Billing\Repositories;
interface BillingComponentInterface
{
public function findAll();
public function getBillingComponentById($billingComponentId);
public function delete($billingComponentId);
public function create(array $billingComponentDetails);
public function update($billingComponentId, array $newDetails);
public function pluck();
}

View File

@ -0,0 +1,39 @@
<?php
namespace Modules\Billing\Repositories;
use Modules\Billing\Models\BillingComponent;
class BillingComponentRepository implements BillingComponentInterface
{
public function findAll()
{
return BillingComponent::get();
}
public function getBillingComponentById($billingComponentId)
{
return BillingComponent::findOrFail($billingComponentId);
}
public function delete($billingComponentId)
{
BillingComponent::destroy($billingComponentId);
}
public function create(array $billingComponentDetails)
{
return BillingComponent::create($billingComponentDetails);
}
public function update($billingComponentId, array $newDetails)
{
return BillingComponent::whereId($billingComponentId)->update($newDetails);
}
public function pluck()
{
return BillingComponent::pluck('title', 'id');
}
}

View File

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

View File

View File

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

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_billing_components', function (Blueprint $table) {
$table->id();
$table->string('title')->nullable();
$table->string('alias')->nullable();
$table->string('unit')->nullable();
$table->double('price')->nullable();
$table->boolean('taxable')->nullable();
$table->unsignedBigInteger('createdBy')->nullable();
$table->unsignedBigInteger('updatedBy')->nullable();
$table->text('remarks')->nullable();
$table->integer('status')->default(11);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tbl_billing_components');
}
};

View File

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

View File

@ -0,0 +1,11 @@
{
"name": "Billing",
"alias": "billing",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Billing\\Providers\\BillingServiceProvider"
],
"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,18 @@
@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 -->
{{ html()->form('POST')->route('billingComponent.store')->class(['needs-validation'])->attributes(['novalidate'])->open() }}
@include('billing::billingComponent.partials.action')
{{ html()->form()->close() }}
</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($billingComponent, 'PUT')->route('billingComponent.update', $billingComponent->id)->class(['needs-validation'])->attributes(['novalidate'])->open() }}
@include('billing::billingComponent.partials.action')
{{ html()->form()->close() }}
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,67 @@
@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('billingComponent.create') }}" class="btn btn-success waves-effect waves-light"><i
class="ri-add-fill me-1 align-bottom"></i> Create</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">Title</span></th>
<th class="tb-col"><span class="overline-title">Alias</span></th>
<th class="tb-col"><span class="overline-title">Unit</span></th>
<th class="tb-col"><span class="overline-title">Price</span></th>
<th class="tb-col"><span class="overline-title">Taxable</span></th>
<th class="tb-col" data-sortable="false"><span class="overline-title">Action</span>
</th>
</tr>
</thead>
<tbody>
@foreach ($billingComponentList as $index => $item)
<tr>
<td class="tb-col">{{ $index + 1 }}</td>
<td class="tb-col">{{ $item->title }}</td>
<td class="tb-col">{{ $item->alias }}</td>
<td class="tb-col">{{ $item->unit }}</td>
<td class="tb-col">{{ $item->price }}</td>
<td class="tb-col">{{ $item->taxable }}</td>
<td class="tb-col">
<div class="hstack flex-wrap gap-3">
<a href="javascript:void(0);" class="link-info fs-15 view-item-btn"
data-bs-toggle="modal" data-bs-target="#viewModal">
<i class="ri-eye-line"></i>
</a>
<a href="{{ route('billingComponent.edit', $item->id) }}"
class="link-success fs-15 edit-item-btn"><i class="ri-edit-2-line"></i></a>
<a href="javascript:void(0);"
data-link="{{ route('billingComponent.destroy', $item->id) }}"
data-id="{{ $item->id }}"
class="link-danger fs-15 remove-item-btn"><i
class="ri-delete-bin-line"></i></a>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,39 @@
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<div class="row gy-3">
<div class="col-md-6">
{{ html()->label('Title')->class('form-label') }}
{{ html()->text('title')->class('form-control')->placeholder('Title')->required() }}
</div>
<div class="col-md-6">
{{ html()->label('Unit')->class('form-label') }}
{{ html()->text('unit')->class('form-control')->placeholder('Enter Unit')->required() }}
</div>
<div class="col-md-6">
{{ html()->label('Price')->class('form-label') }}
{{ html()->number('price')->class('form-control')->placeholder('Price per unit')->required() }}
</div>
<div class="col-md-6">
{{ html()->label('Taxable')->class('form-label') }}
{{ html()->select('taxable',['1' => 'Taxable', '0' => 'Non Taxable'])->class('form-control select2')->placeholder('Yes/No') }}
</div>
<div class="col-md-12">
{{ html()->label('Remarks')->class('form-label') }}
{{ html()->textarea('remarks')->class('form-control ckeditor-classic') }}
</div>
<x-form-buttons :editable="$editable" label="Add" href="{{route('billingComponent.index')}}" />
</div>
</div>
</div>
<!-- end card -->
</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

@ -0,0 +1,7 @@
@extends('billing::layouts.master')
@section('content')
<h1>Hello World</h1>
<p>Module: {!! config('billing.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>Billing 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-billing', 'resources/assets/sass/app.scss') }} --}}
</head>
<body>
@yield('content')
{{-- Vite JS --}}
{{-- {{ module_vite('build-billing', 'resources/assets/js/app.js') }} --}}
</body>

View File

View File

@ -0,0 +1,19 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Billing\Http\Controllers\BillingController;
/*
*--------------------------------------------------------------------------
* 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('billing', BillingController::class)->names('billing');
});

View File

@ -0,0 +1,21 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Billing\Http\Controllers\BillingComponentController;
use Modules\Billing\Http\Controllers\BillingController;
/*
|--------------------------------------------------------------------------
| 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('billing', BillingController::class)->names('billing');
Route::resource('billing-component', BillingComponentController::class)->names('billingComponent');
});

View File

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