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