Compare commits

...

2 Commits

Author SHA1 Message Date
Sampanna Rimal
afb2c202d6 changes 2024-09-11 12:32:15 +05:45
Sampanna Rimal
82fab174dc changes 2024-09-04 12:22:04 +05:45
294 changed files with 7299 additions and 1398 deletions

2
.env
View File

@ -1,4 +1,4 @@
APP_NAME=OMIS APP_NAME=StocksNew
APP_ENV=local APP_ENV=local
APP_KEY=base64:VoHTBVxg0gnGqmljdwxqtxkcqVUq+9nYYYtHGX4APKU= APP_KEY=base64:VoHTBVxg0gnGqmljdwxqtxkcqVUq+9nYYYtHGX4APKU=
APP_DEBUG=true APP_DEBUG=true

View File

@ -96,7 +96,8 @@ class OrderController extends Controller
$data = []; $data = [];
$numInc = $request->numberInc; $numInc = $request->numberInc;
$script = true; $script = true;
$productList= $this->productRepository->pluck(); $productList= $this->productRepository->pluck('id');
dd($productList);
return response()->json([ return response()->json([
'view' => view('order::order.clone-product', compact('data', 'numInc', 'script', 'productList'))->render(), 'view' => view('order::order.clone-product', compact('data', 'numInc', 'script', 'productList'))->render(),

View File

@ -0,0 +1,84 @@
<?php
namespace Modules\Order\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Order\Models\PaymentMode;
use Modules\Order\Repositories\PaymentModeRepository;
class PaymentModeController extends Controller
{
private $paymentModeRepository;
public function __construct(PaymentModeRepository $paymentModeRepository)
{
$this->paymentModeRepository = $paymentModeRepository;
}
public function index()
{
$data['title'] = 'Payment Modes';
$data['paymentModes'] = $this->paymentModeRepository->findAll();
return view('order::paymentMode.index', $data);
}
public function create()
{
$data['title'] = 'Create Payment Mode';
$data['status'] = PaymentMode::STATUS;
return view('order::paymentMode.create', $data);
}
public function store(Request $request): RedirectResponse
{
$request->request->add(['slug' => slugify($request->title)]);
$inputData = $request->all();
$this->paymentModeRepository->create($inputData);
toastr()->success('Payment Mode Created Successfully');
return redirect()->route('paymentMode.index');
}
public function show($id)
{
$data['title'] = 'Show Payment Mode';
$data['status'] = PaymentMode::STATUS;
$data['paymentMode'] = $this->paymentModeRepository->getPaymentModeById($id);
return view('order::paymentMode.show', $data);
}
public function edit($id)
{
$data['title'] = 'Edit Payment Mode';
$data['status'] = PaymentMode::STATUS;
$data['paymentMode'] = $this->paymentModeRepository->getPaymentModeById($id);
return view('order::paymentMode.edit', $data);
}
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
$this->paymentModeRepository->update($id, $inputData);
return redirect()->route('paymentMode.index');
}
public function destroy($id)
{
try {
$stock = $this->paymentModeRepository->getPaymentModeById($id);
$stock->delete();
toastr()->success('Payment Mode Deleted Successfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json(['status' => true, 'message' => 'Payment Mode Deleted Successfully']);
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Modules\Order\Models;
use App\Traits\StatusTrait;
use Illuminate\Database\Eloquent\Model;
class PaymentMode extends Model
{
USE StatusTrait;
protected $table = 'tbl_paymentmodes';
protected $guarded = [];
protected $appends = ['status_name'];
}

View File

@ -0,0 +1,15 @@
<?php
namespace Modules\Order\Repositories;
interface PaymentModeInterface
{
public function findAll();
public function getPaymentModeById($PaymentModeId);
public function getPaymentModeByEmail($email);
public function delete($PaymentModeId);
public function create($PaymentModeDetails);
public function update($PaymentModeId, array $newDetails);
public function pluck();
}

View File

@ -0,0 +1,46 @@
<?php
namespace Modules\Order\Repositories;
use Modules\Order\Models\PaymentMode;
class PaymentModeRepository implements PaymentModeInterface
{
public function findAll()
{
return PaymentMode::when(true, function ($query) {
})->paginate(20);
}
public function getPaymentModeById($PaymentModeId)
{
return PaymentMode::findOrFail($PaymentModeId);
}
public function getPaymentModeByEmail($email)
{
return PaymentMode::where('email', $email)->first();
}
public function delete($PaymentModeId)
{
PaymentMode::destroy($PaymentModeId);
}
public function create($PaymentModeDetails)
{
return PaymentMode::create($PaymentModeDetails);
}
public function update($PaymentModeId, array $newDetails)
{
return PaymentMode::whereId($PaymentModeId)->update($newDetails);
}
public function pluck()
{
return PaymentMode::pluck('name', 'id');
}
}

View File

@ -2,7 +2,7 @@
<div class="row gy-2 mb-2"> <div class="row gy-2 mb-2">
<div class="col-md-4"> <div class="col-md-4">
{{ html()->label('Product')->class('form-label') }} {{ html()->label('Product')->class('form-label') }}
{{ html()->select('product_id', $productList)->class('form-control')->placeholder('Enter Product Name')->required() }} {{ html()->select('product_id[]', $productList)->class('form-control')->placeholder('Enter Product Name')->required() }}
</div> </div>
<div class="col-md-2"> <div class="col-md-2">

View File

@ -0,0 +1,111 @@
<?php
namespace Modules\Product\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Product\Models\FabricCategory;
use Modules\Product\Repositories\FabricCategoryRepository;
class FabricCategoryController extends Controller
{
private $fabricCategoryRepository;
/**
* Display a listing of the resource.
*/
public function __construct(
FabricCategoryRepository $fabricCategoryRepository)
{
$this->fabricCategoryRepository = $fabricCategoryRepository;
}
public function index()
{
$data['title'] = 'Fabric Categories List';
$data['fabric_categories'] = $this->fabricCategoryRepository->findAll();
return view('product::fabric_category.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Fabric Categories';
$data['status'] = FabricCategory::STATUS;
return view('product::fabric_category.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$request->request->add(['slug' => slugify($request->title)]);
$inputData = $request->all();
$this->fabricCategoryRepository->create($inputData);
toastr()->success('Category Created Succesfully');
return redirect()->route('fabricCategory.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'Show Fabric Category';
$data['status'] = FabricCategory::STATUS;
$data['fabric_category'] = $this->fabricCategoryRepository->getFabricCategoryById($id);
return view('product::fabric_category.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Fabric Category';
$data['status'] = FabricCategory::STATUS;
$data['fabric_category'] = $this->fabricCategoryRepository->getFabricCategoryById($id);
return view('product::fabric_category.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
$this->fabricCategoryRepository->update($id, $inputData);
return redirect()->route('fabricCategory.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$FabricCategoryModel = $this->fabricCategoryRepository->getFabricCategoryById($id);
$FabricCategoryModel->delete();
toastr()->success('Fabric Category Delete Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json(['status' => true, 'message' => 'Fabric Category Delete Succesfully']);
}
}

View File

@ -5,8 +5,10 @@ namespace Modules\Product\Http\Controllers;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Modules\Product\Models\FabricCategory;
use Modules\Product\Models\Product; use Modules\Product\Models\Product;
use Modules\Product\Repositories\CategoryRepository; use Modules\Product\Repositories\CategoryRepository;
use Modules\Product\Repositories\FabricCategoryRepository;
use Modules\Product\Repositories\ProductInterface; use Modules\Product\Repositories\ProductInterface;
use Modules\Product\Repositories\ProductRepository; use Modules\Product\Repositories\ProductRepository;
use Modules\Product\Repositories\SubCategoryRepository; use Modules\Product\Repositories\SubCategoryRepository;
@ -19,6 +21,7 @@ class ProductController extends Controller
private $productRepository; private $productRepository;
private $categoryRepository; private $categoryRepository;
private $subCategoryRepository; private $subCategoryRepository;
private $fabricCategoryRepository;
private $warehouseRepository; private $warehouseRepository;
private $supplierRepository; private $supplierRepository;
@ -29,11 +32,13 @@ class ProductController extends Controller
CategoryRepository $categoryRepository, CategoryRepository $categoryRepository,
SubCategoryRepository $subCategoryRepository, SubCategoryRepository $subCategoryRepository,
SupplierRepository $supplierRepository, SupplierRepository $supplierRepository,
FabricCategoryRepository $fabricCategoryRepository,
WarehouseRepository $warehouseRepository) WarehouseRepository $warehouseRepository)
{ {
$this->productRepository = $productRepository; $this->productRepository = $productRepository;
$this->categoryRepository = $categoryRepository; $this->categoryRepository = $categoryRepository;
$this->subCategoryRepository = $subCategoryRepository; $this->subCategoryRepository = $subCategoryRepository;
$this->fabricCategoryRepository = $fabricCategoryRepository;
$this->supplierRepository = $supplierRepository; $this->supplierRepository = $supplierRepository;
$this->warehouseRepository = $warehouseRepository; $this->warehouseRepository = $warehouseRepository;
} }
@ -52,6 +57,7 @@ class ProductController extends Controller
{ {
$data['title'] = 'Create Product'; $data['title'] = 'Create Product';
$data['category'] = $this->categoryRepository->pluck(); $data['category'] = $this->categoryRepository->pluck();
$data['fabricCategory'] = $this->fabricCategoryRepository->pluck();
$data['subCategory'] = $this->subCategoryRepository->pluck(); $data['subCategory'] = $this->subCategoryRepository->pluck();
$data['supplier'] = $this->supplierRepository->pluck(); $data['supplier'] = $this->supplierRepository->pluck();
$data['warehouse'] = $this->warehouseRepository->pluck(); $data['warehouse'] = $this->warehouseRepository->pluck();
@ -92,6 +98,7 @@ class ProductController extends Controller
$data['title'] = 'Show Product'; $data['title'] = 'Show Product';
$data['category'] = $this->categoryRepository->pluck(); $data['category'] = $this->categoryRepository->pluck();
$data['subCategory'] = $this->subCategoryRepository->pluck(); $data['subCategory'] = $this->subCategoryRepository->pluck();
$data['fabricCategory'] = $this->fabricCategoryRepository->pluck();
$data['supplier'] = $this->supplierRepository->pluck(); $data['supplier'] = $this->supplierRepository->pluck();
$data['warehouse'] = $this->warehouseRepository->pluck(); $data['warehouse'] = $this->warehouseRepository->pluck();
$data['product'] = $this->productRepository->getProductById($id); $data['product'] = $this->productRepository->getProductById($id);
@ -127,4 +134,18 @@ class ProductController extends Controller
return response()->json(['status' => true, 'message' => 'Product Delete Succesfully']); return response()->json(['status' => true, 'message' => 'Product Delete Succesfully']);
} }
public function getProductDetail(Request $request)
{
try {
$productModel = $this->productRepository->getProductById($request->id);
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json([
'status' => true,
'data' => $productModel,
]);
}
} }

View File

@ -0,0 +1,16 @@
<?php
namespace Modules\Product\Models;
use App\Traits\StatusTrait;
use Illuminate\Database\Eloquent\Model;
class FabricCategory extends Model
{
USE StatusTrait;
protected $table = 'tbl_fabriccategories';
protected $guarded = [];
protected $appends = ['status_name'];
}

View File

@ -6,6 +6,7 @@ use App\Traits\StatusTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Modules\Supplier\Models\Supplier; use Modules\Supplier\Models\Supplier;
class Product extends Model class Product extends Model
{ {
USE StatusTrait; USE StatusTrait;
@ -25,10 +26,16 @@ class Product extends Model
return $this->belongsTo(SubCategory::class, 'sub_category_id'); return $this->belongsTo(SubCategory::class, 'sub_category_id');
} }
public function fabricCategory()
{
return $this->belongsTo(FabricCategory::class, 'fabriccategory_id');
}
public function warehouse() public function warehouse()
{ {
return $this->belongsTo(Warehouse::class, 'warehouse_id'); return $this->belongsTo(Warehouse::class, 'warehouse_id');
} }
public function supplier() public function supplier()
{ {
return $this->belongsTo(Supplier::class, 'supplier_id'); return $this->belongsTo(Supplier::class, 'supplier_id');

View File

@ -4,6 +4,10 @@ namespace Modules\Product\Providers;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Modules\Product\Repositories\CategoryInterface;
use Modules\Product\Repositories\CategoryRepository;
use Modules\Product\Repositories\FabricCategoryInterface;
use Modules\Product\Repositories\FabricCategoryRepository;
use Modules\Product\Repositories\ProductInterface; use Modules\Product\Repositories\ProductInterface;
use Modules\Product\Repositories\ProductRepository; use Modules\Product\Repositories\ProductRepository;
@ -33,6 +37,9 @@ class ProductServiceProvider extends ServiceProvider
{ {
$this->app->bind(ProductInterface::class,ProductRepository::class); $this->app->bind(ProductInterface::class,ProductRepository::class);
$this->app->register(RouteServiceProvider::class); $this->app->register(RouteServiceProvider::class);
$this->app->bind(CategoryInterface::class,CategoryRepository::class);
$this->app->bind(FabricCategoryInterface::class,FabricCategoryRepository::class);
} }
/** /**

View File

@ -0,0 +1,15 @@
<?php
namespace Modules\Product\Repositories;
interface FabricCategoryInterface
{
public function findAll();
public function getFabricCategoryById($FabricCategoryId);
public function getFabricCategoryByEmail($email);
public function delete($FabricCategoryId);
public function create($FabricCategoryDetails);
public function update($FabricCategoryId, array $newDetails);
public function pluck();
}

View File

@ -0,0 +1,46 @@
<?php
namespace Modules\Product\Repositories;
use Modules\Product\Models\FabricCategory;
class FabricCategoryRepository implements FabricCategoryInterface
{
public function findAll()
{
return FabricCategory::when(true, function ($query) {
})->paginate(20);
}
public function getFabricCategoryById($FabricCategoryId)
{
return FabricCategory::findOrFail($FabricCategoryId);
}
public function getFabricCategoryByEmail($email)
{
return FabricCategory::where('email', $email)->first();
}
public function delete($FabricCategoryId)
{
FabricCategory::destroy($FabricCategoryId);
}
public function create($FabricCategoryDetails)
{
return FabricCategory::create($FabricCategoryDetails);
}
public function update($FabricCategoryId, array $newDetails)
{
return FabricCategory::whereId($FabricCategoryId)->update($newDetails);
}
public function pluck()
{
return FabricCategory::pluck('title', 'id');
}
}

View File

@ -44,3 +44,4 @@ class ProductRepository implements ProductInterface
} }
} }

View File

@ -14,9 +14,12 @@ return new class extends Migration
Schema::create('tbl_products', function (Blueprint $table) { Schema::create('tbl_products', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name');
$table->string('code');
$table->longText('desc')->nullable(); $table->longText('desc')->nullable();
$table->decimal('price', 10, 2); $table->longText('remarks')->nullable();
$table->integer('qty'); $table->decimal('price', 10, 2)->nullable();
$table->integer('qty')->nullable();
$table->unsignedBigInteger('fabriccategory_id')->nullable();
$table->unsignedBigInteger('category_id')->nullable(); $table->unsignedBigInteger('category_id')->nullable();
$table->unsignedBigInteger('sub_category_id')->nullable(); $table->unsignedBigInteger('sub_category_id')->nullable();
$table->unsignedBigInteger('supplier_id')->nullable(); $table->unsignedBigInteger('supplier_id')->nullable();

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTblFabriccategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tbl_fabriccategories', function (Blueprint $table) {
$table->id();
$table->string('title')->nullable();
$table->string('slug')->nullable();
$table->text('description')->nullable();
$table->string('color')->nullable();
$table->integer('display_order')->nullable();
$table->text('remarks')->nullable();
$table->integer('status')->default(11);
$table->dateTime('created_at')->nullable();
$table->integer('createdby')->nullable();
$table->dateTime('updated_at')->nullable();
$table->integer('updatedby')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tbl_fabriccategories');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTblMasterunitsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tbl_masterunits', function (Blueprint $table) {
$table->id();
$table->string('title')->nullable();
$table->string('slug')->nullable();
$table->text('description')->nullable();
$table->integer('display_order')->nullable();
$table->integer('status')->default(11);
$table->text('remarks')->nullable();
$table->dateTime('created_at')->nullable();
$table->integer('createdby')->nullable();
$table->dateTime('updated_at')->nullable();
$table->integer('updatedby')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tbl_masterunits');
}
}

View File

@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTblStocksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tbl_stocks', function (Blueprint $table) {
$table->id();
$table->integer('stocklocation_id')->nullable();
$table->string('title')->nullable();
$table->string('slug')->nullable();
$table->integer('product_id')->nullable();
$table->string('s')->nullable();
$table->string('m')->nullable();
$table->string('l')->nullable();
$table->string('xl')->nullable();
$table->string('xxl')->nullable();
$table->string('xxxl')->nullable();
$table->string('fs')->nullable();
$table->integer('display_order')->nullable();
$table->integer('status')->default(11);
$table->text('remarks')->nullable();
$table->dateTime('created_at')->nullable();
$table->integer('createdby')->nullable();
$table->dateTime('updated_at')->nullable();
$table->integer('updatedby')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tbl_stocks');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTblPaymentmodesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tbl_paymentmodes', function (Blueprint $table) {
$table->id();
$table->string('title')->nullable();
$table->string('slug')->nullable();
$table->text('description')->nullable();
$table->integer('display_order')->nullable();
$table->integer('status')->default(11);
$table->text('remarks')->nullable();
$table->dateTime('created_at')->nullable();
$table->integer('createdby')->nullable();
$table->dateTime('updated_at')->nullable();
$table->integer('updatedby')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tbl_paymentmodes');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTblStocklocationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tbl_stocklocations', function (Blueprint $table) {
$table->id();
$table->string('title')->nullable();
$table->string('slug')->nullable();
$table->text('description')->nullable();
$table->integer('display_order')->nullable();
$table->integer('status')->default(11);
$table->text('remarks')->nullable();
$table->timestamps();
$table->integer('createdby')->nullable();
$table->integer('updatedby')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tbl_stocklocations');
}
}

View File

@ -0,0 +1,16 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
@include('layouts.partials.breadcrumb', ['title' => $title])
{{ html()->form('POST')->route('fabricCategory.store')->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }}
@include('product::fabric_category.partials.action')
{{ html()->form()->close() }}
</div>
</div>
@endsection
@push('js')
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
@endpush

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 -->
{{ html()->modelForm($fabric_category, 'PUT')->route('fabricCategory.update', $fabric_category->id)->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }}
@include('product::fabric_category.partials.action')
{{ html()->closeModelForm() }}
</div>
<!-- container-fluid -->
</div>
@endsection
@push('js')
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
@endpush

View File

@ -0,0 +1,72 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
@include('layouts.partials.breadcrumb', ['title' => $title])
<div class="mb-2 text-end">
@can('fabricCategory.create')
<a href="{{ route('fabricCategory.create') }}" class="btn btn-success btn-md waves-effect waves-light"><i
class="ri-add-fill me-1 align-bottom"></i> Add</a>
@endcan
</div>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table id="buttons-datatables" class="display table-sm table-bordered table" style="width:100%">
<thead>
<tr>
<th>S.N</th>
<th>Title</th>
<th>Slug</th>
<th>Color</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@forelse ($fabric_categories as $key => $fabricCategory)
<tr>
<td>{{ $key + 1 }}</td>
<td>{{ $fabricCategory->title }}</td>
<td>{{ $fabricCategory->slug }}</td>
<td>{{ $fabricCategory->color }}</td>
<td>{!! $fabricCategory->status_name !!}</td>
<td>
<div class="hstack flex-wrap gap-3">
@can('fabricCategory.show')
<a href="{{ route('fabricCategory.show', $fabricCategory->id) }}" class="link-info fs-15">
<i class="ri-eye-line"></i>
</a>
@endcan
@can('fabricCategory.edit')
<a href="{{ route('fabricCategory.edit', $fabricCategory->id) }}"
class="link-success fs-15 edit-item-btn"><i class="ri-edit-2-line"></i></a>
@endcan
@can('fabricCategory.destroy')
<a href="javascript:void(0);"
data-link="{{ route('fabricCategory.destroy', $fabricCategory->id) }}"
data-id="{{ $fabricCategory->id }}" class="link-danger fs-15 remove-item-btn"><i
class="ri-delete-bin-line"></i></a>
@endcan
</div>
</td>
</tr>
@empty
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!--end row-->
</div>
</div>
@endsection

View File

@ -0,0 +1,60 @@
<div class="row">
<div class="col-lg-8">
<div class="card">
<div class="card-body">
<div class="row gy-1">
<div class="col-md-6">
{{ html()->label('Title')->class('form-label') }}
{{ html()->text('title')->class('form-control')->placeholder('Enter Title')->required() }}
</div>
<div class="col-md-6">
{{ html()->label('Color')->class('form-label') }}
{{ html()->text('color')->class('form-control')->placeholder('Enter Color')->required() }}
</div>
<div class="col-md-12">
{{ html()->label('Description')->class('form-label') }}
{{ html()->text('description')->class('form-control')->placeholder('Enter Description') }}
</div>
<div class="col-md-12">
{{ html()->label('Remarks')->class('form-label') }}
{{ html()->text('remarks')->class('form-control')->placeholder('Enter Remarks') }}
</div>
</div>
</div>
</div>
<!-- end card -->
<div class="mb-3 text-end">
<a href="{{ route('fabricCategory.index') }}" class="btn btn-danger w-sm">Cancel</a>
<button type="submit" class="btn btn-success w-sm">Save</button>
</div>
</div>
<!-- end col -->
<div class="col-lg-4">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">Publish</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
{{ html()->label('Status')->class('form-label') }}
{{-- {{ html()->select('status', '11')->class('form-control')->placeholder('Select Status') }}
--}}
{{ html()->select('status', $status)->class('form-control')->placeholder('Select Status')->required() }}
</div>
</div>
</div>
<!-- end card body -->
</div>
<!-- end card -->
</div>
</div>

View File

@ -0,0 +1,45 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
@include('layouts.partials.breadcrumb', ['title' => $title])
<div class="row">
<div class="col-md-8">
<div class="card card-body p-4">
<div>
<div class="table-responsive">
<table class="table-borderless mb-0 table">
<tbody>
<tr>
<th><span class="fw-medium">Title</span></th>
<td>{{ $fabric_category->title }}</td>
</tr>
<tr>
<th><span class="fw-medium">Description</span></th>
<td>{{ $fabric_category->description }}</td>
</tr>
<tr>
<th><span class="fw-medium">Remarks</span></th>
<td>{{ $fabric_category->remarks }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="mb-3 text-end">
<a href="{{ route('fabricCategory.index') }}" class="btn btn-secondary w-sm">Back</a>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('js')
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
@endpush

View File

@ -22,28 +22,23 @@
<thead> <thead>
<tr> <tr>
<th>S.N</th> <th>S.N</th>
<th>Name</th> <th>Title</th>
<th>Price</th> <th>Fabric Category</th>
<th>Quantity</th> <th>Product Category</th>
<th>Category</th> <th>Product Code</th>
<th>Sub Category</th>
<th>Supplier</th>
<th>Warehouse</th>
<th>Status</th> <th>Status</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@forelse ($products as $key => $product) @forelse ($products as $key => $product)
{{-- @dd($product->fabricCategory) --}}
<tr> <tr>
<td>{{ $key + 1 }}</td> <td>{{ $key + 1 }}</td>
<td>{{ $product->name }}</td> <td>{{ $product->name }}</td>
<td>{{ $product->price }}</td> <td>{{ optional($product->fabricCategory)->title }}</td>
<td>{{ $product->qty }}</td>
<td>{{ optional($product->category)->title }}</td> <td>{{ optional($product->category)->title }}</td>
<td>{{ optional($product->subCategory)->title }}</td> <td>{{ $product->code }}</td>
<td>{{ optional($product->supplier)->supplier_name }}</td>
<td>{{ optional($product->warehouse)->title }}</td>
<td>{!! $product->status_name !!}</td> <td>{!! $product->status_name !!}</td>
<td> <td>
<div class="hstack flex-wrap gap-3"> <div class="hstack flex-wrap gap-3">

View File

@ -9,40 +9,30 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
{{ html()->label('Price')->class('form-label') }} {{ html()->label('Product Code')->class('form-label') }}
{{ html()->text('price')->class('form-control')->placeholder('Enter Price')->required() }} {{ html()->text('code')->class('form-control')->placeholder('Enter Product Code')->required() }}
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
{{ html()->label('Quantity')->class('form-label') }} {{ html()->label('Fabric Category')->class('form-label') }}
{{ html()->text('qty')->class('form-control')->placeholder('Enter Quantity')->required() }} {{ html()->select('fabriccategory_id', $fabricCategory)->class('form-select select2')->placeholder('Select Fabric Category')->id('fabric_category_id') }}
</div> </div>
<div class="col-md-4"> <div class="col-md-6">
{{ html()->label('Category')->class('form-label') }} {{ html()->label('Category')->class('form-label') }}
{{ html()->select('category_id', $category)->class('form-select select2')->placeholder('Select Category')->id('category_id') }} {{ html()->select('category_id', $category)->class('form-select select2')->placeholder('Select Category')->id('category_id') }}
</div> </div>
<div class="col-md-4">
{{ html()->label('Sub Category')->class('form-label') }}
{{ html()->select('sub_category_id', $subCategory)->class('form-select select2')->placeholder('Select Sub Category')->id('sub_category_id') }}
</div>
<div class="col-md-4">
{{ html()->label('Supplier')->class('form-label') }}
{{ html()->select('supplier_id', $supplier)->class('form-select select2')->placeholder('Select Supplier') }}
</div>
<div class="col-md-4">
{{ html()->label('Warehouse')->class('form-label') }}
{{ html()->select('warehouse_id', $warehouse)->class('form-select select2')->placeholder('Select Warehouse') }}
</div>
<div class="col-md-12"> <div class="col-md-12">
{{ html()->label('Description')->class('form-label') }} {{ html()->label('Description')->class('form-label') }}
{{ html()->textarea('desc')->class('form-control')->placeholder('Enter Description')->required() }} {{ html()->textarea('desc')->class('form-control')->placeholder('Enter Description')->required() }}
</div> </div>
<div class="col-md-12">
{{ html()->label('Remarks')->class('form-label') }}
{{ html()->textarea('remarks')->class('form-control')->placeholder('Enter Remarks')->required() }}
</div>
</div> </div>
<!-- end card --> <!-- end card -->
</div> </div>
@ -73,14 +63,14 @@
</div> </div>
@push('js') @push('js')
<script> {{-- <script>
$(document).on('change', '#category_id', function(e) { $(document).on('change', '#category_id', function(e) {
e.preventDefault(); e.preventDefault();
var category_id = $(this).val(); var category_id = $(this).val();
if (category_id) { if (category_id) {
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "{{ route('getSubCategories') }}", url: "{{ route('getSubCategories') }}" ,
data: { data: {
'category_id': category_id 'category_id': category_id
}, },
@ -94,5 +84,5 @@
}); });
} }
}); });
</script> </script> --}}
@endpush @endpush

View File

@ -17,31 +17,23 @@
<td>{{ $product->name }}</td> <td>{{ $product->name }}</td>
</tr> </tr>
<tr> <tr>
<th><span class="fw-medium">Price</span></th> <th><span class="fw-medium">Product Code</span></th>
<td>{{ $product->price }}</td> <td>{{ $product->code }}</td>
</tr>
<tr>
<th><span class="fw-medium">Quantity</span></th>
<td>{{ $product->qty }}</td>
</tr> </tr>
<tr> <tr>
<th><span class="fw-medium">Category</span></th> <th><span class="fw-medium">Category</span></th>
<td>{{ optional($product->category)->title }}</td> <td>{{ optional($product->category)->title }}</td>
</tr> </tr>
<tr> <tr>
<th><span class="fw-medium">Sub Category</span></th> <th><span class="fw-medium">Fabric Category</span></th>
<td>{{ optional($product->subCategory)->title }}</td> <td>{{ optional($product->fabricCategory)->title }}</td>
</tr> </tr>
<tr> <tr>
<th><span class="fw-medium">Supplier</span></th> <th><span class="fw-medium">Description</span></th>
<td>{{ optional($product->supplier)->supplier_name }}</td> <td>{{ optional($product->desc) }}</td>
</tr> </tr>
<tr> <tr>
<th><span class="fw-medium">Warehouse</span></th> <th><span class="fw-medium">Status</span></th>
<td>{{ optional($product->warehouse)->title }}</td>
</tr>
<tr>
<th><span class="fw-medium">Status</span></th>
<td>{{ $product->status }}</td> <td>{{ $product->status }}</td>
</tr> </tr>
</tbody> </tbody>

View File

@ -2,6 +2,7 @@
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Modules\Product\Http\Controllers\CategoryController; use Modules\Product\Http\Controllers\CategoryController;
use Modules\Product\Http\Controllers\FabricCategoryController;
use Modules\Product\Http\Controllers\ProductController; use Modules\Product\Http\Controllers\ProductController;
use Modules\Product\Http\Controllers\SubCategoryController; use Modules\Product\Http\Controllers\SubCategoryController;
use Modules\Product\Http\Controllers\WarehouseController; use Modules\Product\Http\Controllers\WarehouseController;
@ -22,7 +23,9 @@ Route::group([], function () {
Route::resource('category', CategoryController::class)->names('category'); Route::resource('category', CategoryController::class)->names('category');
Route::resource('sub-category', SubCategoryController::class)->names('subCategory'); Route::resource('sub-category', SubCategoryController::class)->names('subCategory');
Route::resource('warehouse', WarehouseController::class)->names('warehouse'); Route::resource('warehouse', WarehouseController::class)->names('warehouse');
Route::resource('fabricCategory', FabricCategoryController::class)->names('fabricCategory');
Route::get('get-sub-categories', [SubCategoryController::class, 'getSubCategories'])->name('getSubCategories'); Route::get('get-sub-categories', [SubCategoryController::class, 'getSubCategories'])->name('getSubCategories');
Route::get('product-details', [ProductController::class, 'getProductDetail'])->name('get-product-detail');
}); });

View File

@ -0,0 +1,135 @@
<?php
namespace Modules\SalesEntry\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Admin\Repositories\FieldInterface;
use Modules\Customer\Repositories\CustomerInterface;
use Modules\Product\Repositories\CategoryInterface;
use Modules\Product\Repositories\ProductInterface;
use Modules\SalesEntry\Models\SalesEntry;
use Modules\SalesEntry\Repositories\SalesEntryInterface;
use Modules\Stock\Repositories\StockInterface;
class SalesEntryController extends Controller
{
private $productRepository;
private $customerRepository;
private $salesEntryRepository;
private $categoryRepository;
private $stockRepository;
private $fieldRepository;
public function __construct( ProductInterface $productRepository,
CustomerInterface $customerRepository,
SalesEntryInterface $salesEntryRepository,
CategoryInterface $categoryRepository,
StockInterface $stockRepository,
FieldInterface $fieldRepository )
{
$this->productRepository = $productRepository;
$this->customerRepository = $customerRepository;
$this->salesEntryRepository = $salesEntryRepository;
$this->categoryRepository = $categoryRepository;
$this->stockRepository = $stockRepository;
$this->fieldRepository = $fieldRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'Sales Entries';
$data['salesEntries'] = SalesEntry::all();
return view('salesEntry::salesEntry.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'New Sales Entry';
$data['categoryList'] = $this->categoryRepository->pluck();
$data['stockList'] = $this->stockRepository->pluck();
$data['productList'] = $this->productRepository->pluck();
$data['customerList'] = $this->customerRepository->pluck();
$data['sizes'] = $this->fieldRepository->getDropdownByAlias('size');
$data['paymentModes'] = $this->fieldRepository->getDropdownByAlias('payment-mode');
$data['editable'] = false;
return view('salesEntry::salesEntry.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$this->salesEntryRepository->create($request);
return redirect()->route('salesEntry.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('salesEntry::salesEntry.show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['customerList'] = $this->customerRepository->pluck();
$data['categoryList'] = $this->categoryRepository->pluck();
$data['stockList'] = $this->stockRepository->pluck();
$data['productList'] = $this->productRepository->pluck();
$data['sizes'] = $this->fieldRepository->getDropdownByAlias('size');
$data['paymentModes'] = $this->fieldRepository->getDropdownByAlias('payment-mode');
$data['order'] = SalesEntry::with('orderDetails')->find($id);
$data['id'] = $id;
$data['editable'] = true;
$data['title'] = "Edit Sales Entry";
return view('salesEntry::salesEntry.edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$this->salesEntryRepository->update($id,$request);
return redirect()->route('salesEntry.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
return $this->salesEntryRepository->delete($id);
}
public function cloneSalesProduct(Request $request)
{
$data = [];
$numInc = $request->numberInc;
$script = true;
$productList= $this->productRepository->pluck('id');
$stockList= $this->stockRepository->pluck('id');
$categoryList= $this->categoryRepository->pluck('id');
return response()->json([
'view' => view('salesEntry::salesEntry.clone-product', compact('data', 'numInc', 'script', 'productList'))->render(),
]);
}
}

View File

View File

@ -0,0 +1,33 @@
<?php
namespace Modules\SalesEntry\Models;
use App\Traits\StatusTrait;
use Illuminate\Database\Eloquent\Model;
use Modules\Customer\Models\Customer;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Modules\SalesEntry\Models\SalesEntryDetail;
class SalesEntry extends Model
{
USE StatusTrait;
protected $table = 'tbl_salesentries';
protected $guarded = [];
protected $appends = ['status_name'];
public function salesEntryDetails():HasMany{
return $this->hasMany(SalesEntryDetail::class,'salesentry_id');
}
public function customer():BelongsTo{
return $this->belongsTo(Customer::class);
}
public static function getFillableField(){
return (new self())->fillable;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Modules\SalesEntry\Models;
use App\Traits\StatusTrait;
use Illuminate\Database\Eloquent\Model;
use Modules\SalesEntry\Models\SalesEntry;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Modules\Supplier\Models\Supplier;
class SalesEntryDetail extends Model
{
USE StatusTrait;
protected $table = 'tbl_salesentrydetails';
protected $guarded = [];
protected $appends = ['status_name'];
public function order(): BelongsTo
{
return $this->belongsTo(SalesEntry::class);
}
}

View File

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

View File

@ -0,0 +1,123 @@
<?php
namespace Modules\SalesEntry\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Modules\SalesEntry\Repositories\SalesEntryInterface;
use Modules\SalesEntry\Repositories\SalesEntryRepository;
class SalesEntryServiceProvider extends ServiceProvider
{
protected string $moduleName = 'SalesEntry';
protected string $moduleNameLower = 'salesEntry';
/**
* 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(SalesEntryInterface::class, SalesEntryRepository::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,17 @@
<?php
namespace Modules\SalesEntry\Repositories;
use Illuminate\Http\Request;
interface SalesEntryInterface
{
public function findAll();
public function getSalesEntryById($SalesEntryId);
public function getSalesEntryByEmail($email);
public function delete($SalesEntryId);
public function create(Request $request);
public function update($SalesEntryId, Request $request);
public function pluck();
}

View File

@ -0,0 +1,119 @@
<?php
namespace Modules\SalesEntry\Repositories;
use Flasher\Laravel\Http\Request;
use Modules\SalesEntry\Models\SalesEntry;
use Modules\SalesEntry\Models\SalesEntryDetail;
use Illuminate\Support\Facades\DB;
class SalesEntryRepository implements SalesEntryInterface
{
public function findAll()
{
return SalesEntry::when(true, function ($query) {
})->paginate(20);
}
public function getSalesEntryById($SalesEntryId)
{
return SalesEntry::findOrFail($SalesEntryId);
}
public function getSalesEntryByEmail($email)
{
return SalesEntry::where('email', $email)->first();
}
public function delete($SalesEntryId)
{
DB::transaction(function() use ($SalesEntryId) {
SalesEntryDetail::where('salesentry_id', $SalesEntryId)->delete();
SalesEntry::destroy($SalesEntryId);
});
}
public function create($request)
{
$salesEntryDetails = $request->except(SalesEntry::getFillableField());
$salesEntry = $request->only(SalesEntry::getFillableField());
$salesEntryData = SalesEntry::create($salesEntry);
$request->merge(['salesentry_id' => $salesEntryData->id]);
foreach ($salesEntryDetails['product_id'] as $key => $productId) {
$data = [
'salesentry_id' => $request->input('salesentry_id'),
'product_id' => $productId,
'unit' => $salesEntryDetails['unit'][$key],
'rate' => $salesEntryDetails['rate'][$key],
'quantity' => $salesEntryDetails['qty'][$key],
'amount' => $salesEntryDetails['amt'][$key],
'desc' => $salesEntryDetails['desc'][$key],
];
SalesEntryDetail::create($data);
}
}
public function update($SalesEntryId, $request)
{
$fillableFields = SalesEntry::getFillableField();
$salesEntryData = $request->only($fillableFields);
$salesEntry = SalesEntry::find($SalesEntryId);
$salesEntry->update($salesEntryData);
$additionalExcludes = ['_method', '_token'];
$excludeFields = array_merge($fillableFields, $additionalExcludes);
$data = $request->except($excludeFields);
$updatedCombinations = [];
if (isset($data['product_id'])) {
foreach ($data['product_id'] as $key => $productId) {
$obj = [
'salesentry_id' => $SalesEntryId,
'product_id' => $productId,
'unit' => $data['unit'][$key],
'rate' => $data['rate'][$key],
'quantity' => $data['qty'][$key],
'amount' => $data['amt'][$key],
'desc' => $data['desc'][$key],
];
$combinationKey = "{$SalesEntryId}_{$productId}_{$data['unit'][$key]}";
$salesEntryDetail = $salesEntry->salesEntryDetails()->where('product_id', $productId)->where('unit', $data['unit'][$key])->first();
if ($salesEntryDetail) {
$salesEntryDetail->update($obj);
} else {
SalesEntryDetail::create($obj);
}
$updatedCombinations[] = $combinationKey;
}
}
$salesEntry->salesEntryDetails()->each(function ($salesEntryDetail) use ($updatedCombinations) {
$combinationKey = "{$salesEntryDetail->salesEntry_id}_{$salesEntryDetail->product_id}_{$salesEntryDetail->unit}";
if (!in_array($combinationKey, $updatedCombinations)) {
$salesEntryDetail->delete();
}
});
return $salesEntry;
}
public function pluck()
{
return SalesEntry::pluck('name', 'id');
}
}

View File

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

View File

View File

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

View File

@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tbl_salesentries', function (Blueprint $table) {
$table->id();
$table->string('title')->nullable();
$table->string('slug')->nullable();
$table->date('sales_date')->nullable();
$table->unsignedBigInteger('customer_id')->nullable();
$table->unsignedBigInteger('product_id')->nullable();
$table->unsignedBigInteger('category_id')->nullable();
$table->unsignedBigInteger('stock_id')->nullable();
$table->unsignedBigInteger('size_id')->nullable();
$table->string('payment')->nullable();
$table->unsignedBigInteger('paymentmode_id')->nullable();
$table->string('paymentref')->nullable();
$table->decimal('sub_total', 10, 2)->nullable();
$table->decimal('tax', 10, 2)->nullable();
$table->decimal('discount_amt', 10, 2)->nullable();
$table->decimal('total_amt', 10, 2)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tbl_salesentries');
}
};

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tbl_salesentrydetails', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('salesentry_id')->nullable();
$table->unsignedBigInteger('product_id')->nullable();
$table->unsignedBigInteger('category_id')->nullable();
$table->unsignedBigInteger('stock_id')->nullable();
$table->unsignedBigInteger('size_id')->nullable();
$table->string('unit')->nullable();
$table->integer('rate')->nullable();
$table->integer('quantity')->nullable();
$table->decimal('amount', 6);
$table->text('desc')->nullable();
$table->integer('status')->nullable();
$table->text('remarks')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tbl_salesentrydetails');
}
};

View File

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

View File

@ -0,0 +1,11 @@
{
"name": "SalesEntry",
"alias": "salesentry",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\SalesEntry\\Providers\\SalesEntryServiceProvider"
],
"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

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

View File

@ -0,0 +1,46 @@
<div class="card card-body product-card card-border-secondary mb-2 border">
<div class="row gy-2 mb-2">
<div class="col-md-4">
{{ html()->label('Product')->class('form-label') }}
@if (isset($editable) && $editable)
{{ html()->select('product_id[]', $productList, $item->product_id)->class('form-select product_id')->attributes(['id' => 'product_id'])->placeholder('Enter Product Name')->required() }}
@else
@endif
{{ html()->select('product_id[]', $productList)->class('form-select product_id')->attributes(['id' => 'product_id'])->placeholder('Enter Product Name')->required() }}
</div>
<div class="col-md-2">
{{ html()->label('Unit')->class('form-label') }}
{{ html()->text('unit[]', isset($editable) && $editable ? $item->unit : null)->class('form-control unit')->placeholder('Enter Unit')->required()->attributes(['id' => 'unit']) }}
</div>
<div class="col-md-2">
{{ html()->label('Rate')->class('form-label') }}
{{ html()->text('rate[]', isset($editable) && $editable ? $item->rate : null)->class('form-control product-price cleave-numeral rate~~')->placeholder('Enter Rate')->attributes(['id' => 'rate']) }}
</div>
<div class="col-md-2">
{{ html()->label('Quantity')->class('form-label') }}
{{ html()->text('qty[]', isset($editable) && $editable ? $item->quantity : null)->class('form-control product-quantity cleave-numeral qty')->placeholder('Enter QTY')->attributes(['id' => 'qty']) }}
</div>
<div class="col-md-2">
{{ html()->label('Amount')->class('form-label') }}
{{ html()->text('amt[]', isset($editable) && $editable ? $item->amount : null)->class('form-control product-line-price bg-light')->placeholder('Enter Amount')->isReadOnly() }}
</div>
<div class="col-md-6">
{{ html()->label('Description')->class('form-label') }}
{{ html()->text('desc[]', isset($editable) && $editable ? $item->desc : null)->class('form-control')->placeholder('Enter Description') }}
</div>
<div class="col-md-6 d-flex justify-content-end align-items-end">
<button type="button" class="btn btn-danger btn-icon waves-effect btn-remove waves-light"><i
class="ri-delete-bin-5-line"></i></button>
</div>
</div>
</div>

View File

@ -0,0 +1,27 @@
@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">
<form action="{{ route('salesEntry.store') }}" class="needs-validation" novalidate method="post">
@csrf
@include('salesEntry::salesEntry.partials.action')
</form>
</div>
</div>
</div>
<!-- container-fluid -->
</div>
@endsection
@push('js')
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
@endpush

View File

@ -0,0 +1,47 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
<h4 class="mb-sm-0">{{ $title }}</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
<li class="breadcrumb-item active">{{ $title }}</li>
</ol>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
{{ html()->modelForm($order, 'PUT')->route('order.update', $id)->class(['needs-validation'])->attributes(['novalidate'])->open() }}
@include('order::order.partials.action')
{{ html()->closeModelForm() }}
</div>
</div>
</div>
</div>
<!--end row-->
</div>
<!-- container-fluid -->
</div>
@endsection
@push('js')
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
@endpush

View File

@ -0,0 +1,68 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<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('salesEntry.create') }}" class="btn btn-success waves-effect waves-light"><i
class="ri-add-fill me-1 align-bottom"></i> Add</a>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="buttons-datatables" class="display table-sm table-bordered table"
style="width:100%">
<thead>
<tr>
<th>S.N</th>
<th>Customer</th>
<th>Sales Date</th>
<th>Total Amount</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@forelse ($salesEntries as $key => $item)
<tr>
<td>{{ $key + 1 }}</td>
<td>{{ $item->customer->customer_name }}</td>
<td>{{ $item->sales_date }}</td>
<td>{{ $item->total_amt }}</td>
<td>
<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('salesEntry.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('salesEntry.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>
@empty
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!--end row-->
</div>
</div>
@endsection

View File

@ -0,0 +1,219 @@
<div class="row gy-1">
<h5 class="text-primary text-center">Order Details</h5>
<div class="border border-dashed"></div>
<div class="col-md-4">
{{ html()->label('Sales Date')->class('form-label') }}
{{ html()->date('sales_date')->class('form-control')->placeholder('Choose Sales Date')->required() }}
{{ html()->div('Please choose Sales date')->class('invalid-feedback') }}
</div>
<div class="col-md-8">
{{ html()->label('Customer')->class('form-label') }}
{{ html()->select('customer_id', $customerList)->class('form-control')->placeholder('Select Customer')->required() }}
{{ html()->div('Please select customer')->class('invalid-feedback') }}
</div>
</div>
{{-- <div class="row mt-2">
<p class="text-primary">Shipping Details</p>
<div class="border border-dashed"></div>
<div class="col-md-4">
{{ html()->label('Address')->class('form-label') }}
{{ html()->text('address')->class('form-control')->placeholder('Enter Address') }}
</div>
<div class="col-md-4">
{{ html()->label('Shipping Date')->class('form-label') }}
{{ html()->date('shiiping_date')->class('form-control')->placeholder('Enter Temporary Address') }}
</div>
</div> --}}
<div class="row gy-1 gx-2 mt-1">
<div class="d-flex justify-content-end">
<button type="button" class="btn btn-info btn-icon add-btn text-end"><i class="ri-add-line"></i></button>
</div>
@if ($editable && $salesEntry->salesEntryDetail->isNotEmpty())
@foreach ($salesEntry->salesEntryDetail as $item)
@include('salesEntry::salesEntry.clone-product')
@endforeach
@else
@include('salesEntry::salesEntry.clone-product')
@endif
<div class="appendProductCard"></div>
</div>
<div class="d-flex justify-content-end w-30 mb-2">
<table class="table-borderless align-middle">
<tbody>
{{-- <tr>
<th scope="row">Sub Total</th>
<td style="width:150px;">
<input type="text" name="sub_total" class="form-control bg-light border-0" id="subtotal"
placeholder="$0.00" readonly="">
</td>
</tr>
<tr>
<th scope="row">Estimated Tax (11%)</th>
<td>
<input type="text" name="tax" class="form-control bg-light border-0" id="tax"
placeholder="$0.00" readonly="">
</td>
</tr>
<tr>
<th scope="row">Discount</th>
<td>
<input type="text" name="discount_amt" class="form-control bg-light border-0" id="discount"
placeholder="$0.00" readonly="">
</td>
</tr> --}}
<tr class="border-top border-top-dashed">
<th scope="row">Total Amount</th>
<td>
<input type="text" name="total_amt" class="form-control bg-light border-0" id="total"
placeholder="$0.00" readonly="">
</td>
</tr>
</tbody>
</table>
</div>
<div class="row gy-1 my-2">
<h5 class="text-primary text-center">Payment Details</h5>
<div class="border border-dashed"></div>
<div class="col-md-4">
{{ html()->label('Payment')->class('form-label') }}
{{ html()->text('payment')->class('form-control')->placeholder('Enter Payment') }}
</div>
<div class="col-md-4">
{{ html()->label('Mode of Payment')->class('form-label') }}
{{ html()->select('paymentmode_id', $paymentModes)->class('form-select select2')->placeholder('Select Payment Mode') }}
</div>
<div class="col-md-4">
{{ html()->label('Payment Reference')->class('form-label') }}
{{ html()->text('paymentref')->class('form-control')->placeholder('Enter Payment Reference') }}
</div>
</div>
<div class="mb-4 text-end">
<button type="submit" class="btn btn-success w-sm">Save</button>
</div>
@push('js')
<script src="{{ asset('assets/libs/cleave.js/cleave.min.js') }}"></script>
<script src="{{ asset('assets/js/pages/form-masks.init.js') }}"></script>
<script>
$("body").on('click', '.add-btn', function(e) {
e.preventDefault();
numberInc = $('.product-card').length
$.ajax({
type: 'get',
url: '{{ url('clone-sales-product') }}',
data: {
numberInc: numberInc
},
success: function(response) {
$('.appendProductCard').append(response.view)
// $('#salesEntry-container').html(response.view).fadeIn()
},
error: function(xhr) {
},
});
});
$("body").on('click', '.btn-remove', function() {0
if ($('.product-card').length > 1) {
$(this).parents(".product-card").remove();
}
recalculate();
});
$(window).on('load', function() {
recalculate();
})
function amountKeyup() {
$("body").on('keyup', '.product-price', function() {
var priceInput = $(this);
var qtyInput = priceInput.closest(".row").find(".product-quantity");
var linePrice = priceInput.closest(".row").find(".product-line-price");
updateQuantity(priceInput.val(), qtyInput.val(), linePrice);
});
$("body").on('keyup', '.product-quantity', function() {
var priceInput = $(this);
var qtyInput = priceInput.closest(".row").find(".product-price");
var linePrice = priceInput.closest(".row").find(".product-line-price");
updateQuantity(priceInput.val(), qtyInput.val(), linePrice);
});
}
amountKeyup()
function updateQuantity(rate, qty, linePriceInput) {
var amount = (rate * qty).toFixed(2);
linePriceInput.val(amount);
recalculate();
}
function recalculate() {
var subtotal = 0;
$(".product-line-price").each(function() {
if ($(this).val()) {
subtotal += parseFloat($(this).val());
}
});
// var tax = subtotal * 0.125;
// var discount = subtotal * 0.15;
// var shipping = subtotal > 0 ? 65 : 0;
// var total = subtotal + tax + shipping - discount;
// $("#subtotal").val(subtotal.toFixed(2));
// $("#tax").val(tax.toFixed(2));
// $("#discount").val(discount.toFixed(2));
// $("#shipping").val(shipping.toFixed(2));
$("#total").val(subtotal.toFixed(2));
}
$(document).ready(function() {
$('body').on('change', '.product_id', function() {
var selectedId = $(this).find(':selected').val();
var formRow = $(this).closest('.row');
if (selectedId) {
$.ajax({
type: 'GET',
url: '{{ route('get-product-detail') }}',
data: {
id: selectedId
},
success: function(response) {
var qtyInput = formRow.find('#qty').val(response.data.qty);
formRow.find('#unit').val(response.data.unit);
var priceInput = formRow.find('#rate').val(response.data.price);
var linePrice = priceInput.closest(".row").find(".product-line-price");
updateQuantity(priceInput.val(), qtyInput.val(), linePrice);
},
error: function(xhr) {
}
});
}
});
});
</script>
@endpush

View File

@ -0,0 +1,16 @@
<div class="modal fade" id="viewModal" tabindex="-1" aria-labelledby="viewModalLabel" aria-modal="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalgridLabel">View Leave</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="{{ route('leave.store') }}" class="needs-validation" novalidate method="post">
@csrf
@include('leave::leave.partials.action')
</form>
</div>
</div>
</div>
</div>

View File

View File

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

View File

@ -0,0 +1,20 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\SalesEntry\Http\Controllers\SalesEntryController;
/*
|--------------------------------------------------------------------------
| 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('salesEntry', SalesEntryController::class)->names('salesEntry');
Route::get('clone-sales-product', [SalesEntryController::class, 'cloneSalesProduct'])->name('salesEntry.cloneSalesProduct');
});

View File

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

View File

@ -0,0 +1,106 @@
<?php
namespace Modules\Setting\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Setting\Models\Setting;
use Modules\Setting\Repositories\SettingRepository;
class SettingController extends Controller
{
private $settingRepository;
/**
* Display a listing of the resource.
*/
public function __construct(
SettingRepository $settingRepository) {
$this->settingRepository = $settingRepository;
}
public function index()
{
$data['title'] = 'Categories List';
$data['categories'] = $this->settingRepository->findAll();
return view('setting::setting.edit', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Setting';
$data['status'] = Setting::STATUS;
return view('setting::setting.edit', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$inputData = $request->all();
$this->settingRepository->create($inputData);
toastr()->success('Setting Created Succesfully');
$data['setting'] = $this->settingRepository->getSettingById($request->id);
return redirect()->route('setting.edit');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'Show Setting';
$data['status'] = Setting::STATUS;
$data['setting'] = $this->settingRepository->getSettingById($id);
return view('setting::setting.edit', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Setting';
$data['status'] = Setting::STATUS;
$data['setting'] = $this->settingRepository->getSettingById($id);
return view('setting::setting.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
$this->settingRepository->update($id, $inputData);
$data['setting'] = $this->settingRepository->getSettingById($id);
return redirect()->route('setting.edit',$data);
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$SettingModel = $this->settingRepository->getSettingById($id);
$SettingModel->delete();
toastr()->success('Product Delete Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json(['status' => true, 'message' => 'Setting Delete Succesfully']);
}
}

View File

View File

@ -0,0 +1,15 @@
<?php
namespace Modules\Setting\Models;
use App\Traits\StatusTrait;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
use StatusTrait;
protected $table = 'tbl_settings';
protected $guarded = [];
protected $appends = ['status_name'];
}

View File

View File

View File

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

View File

@ -0,0 +1,120 @@
<?php
namespace Modules\Setting\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class SettingServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Setting';
protected string $moduleNameLower = 'setting';
/**
* 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);
}
/**
* 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,15 @@
<?php
namespace Modules\Setting\Repositories;
interface SettingInterface
{
public function findAll();
public function getSettingById($SettingId);
public function getSettingByEmail($email);
public function delete($SettingId);
public function create($SettingDetails);
public function update($SettingId, array $newDetails);
public function pluck();
}

View File

@ -0,0 +1,46 @@
<?php
namespace Modules\Setting\Repositories;
use Modules\Setting\Models\Setting;
class SettingRepository implements SettingInterface
{
public function findAll()
{
return Setting::when(true, function ($query) {
})->paginate(20);
}
public function getSettingById($SettingId)
{
return Setting::findOrFail($SettingId);
}
public function getSettingByEmail($email)
{
return Setting::where('email', $email)->first();
}
public function delete($SettingId)
{
Setting::destroy($SettingId);
}
public function create($SettingDetails)
{
return Setting::create($SettingDetails);
}
public function update($SettingId, array $newDetails)
{
return Setting::whereId($SettingId)->update($newDetails);
}
public function pluck()
{
return Setting::pluck('title', 'id');
}
}

View File

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

View File

View File

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

View File

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

View File

@ -0,0 +1,11 @@
{
"name": "Setting",
"alias": "setting",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Setting\\Providers\\SettingServiceProvider"
],
"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"
}
}

Some files were not shown because too many files have changed in this diff Show More