first change
This commit is contained in:
0
Modules/Product/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Product/app/Http/Controllers/.gitkeep
Normal file
125
Modules/Product/app/Http/Controllers/ProductController.php
Normal file
125
Modules/Product/app/Http/Controllers/ProductController.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Client\Interfaces\ClientInterface;
|
||||
use Modules\Product\Interfaces\ProductInterface;
|
||||
use Modules\Product\Models\Product;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
private $product;
|
||||
private $client;
|
||||
|
||||
public function __construct(ProductInterface $product, ClientInterface $client)
|
||||
{
|
||||
$this->product = $product;
|
||||
$this->client = $client;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data['title'] = 'Product';
|
||||
$data['status'] = Product::STATUS;
|
||||
$data['clients'] = $this->client->pluck();
|
||||
if ($request->ajax()) {
|
||||
$model = Product::query();
|
||||
|
||||
return DataTables::eloquent($model)
|
||||
->addIndexColumn()
|
||||
->setRowClass('{{"text-center align-middle"}}')
|
||||
->addColumn('client', function (Product $product) {
|
||||
return $product->client?->name;
|
||||
})
|
||||
->addColumn('status', '{!! $status_name !!}')
|
||||
->addColumn('action', 'product::products.datatables.action-btn')
|
||||
->rawColumns(['client', 'action', 'status','desc'])
|
||||
->make(true);
|
||||
// ->toJson();
|
||||
}
|
||||
return view('product::products.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Product';
|
||||
$data['editable'] = false;
|
||||
|
||||
return view('product::products.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->product->create($request->all());
|
||||
return redirect()->route('product.index')->with('sucess', 'Product has been created!');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'Product List';
|
||||
$data['product'] = $this->product->getProductById($id);
|
||||
return view('product::products.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Product';
|
||||
$data['editable'] = true;
|
||||
$data['status'] = Product::STATUS;
|
||||
$data['product'] = $this->product->getProductById($id);
|
||||
$data['clients'] = $this->client->pluck();
|
||||
return view('product::products.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->product->update($id, $request->except(['_token', '_method']));
|
||||
return redirect()->route('product.index')->with('success', 'Product has been updated!');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->product->delete($id);
|
||||
return response()->json(['status' => 200, 'message' => 'Product has been deleted!'], 200);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json(['status' => 500, 'message' => 'Product to delete!', 'error' => $th->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
16
Modules/Product/app/Interfaces/ProductInterface.php
Normal file
16
Modules/Product/app/Interfaces/ProductInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\Interfaces;
|
||||
|
||||
interface ProductInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getProductById($productId);
|
||||
public function getProductList();
|
||||
public function create(array $productDetails);
|
||||
public function update($productId, array $newDetails);
|
||||
public function delete($productId);
|
||||
public function pluck();
|
||||
public function count();
|
||||
public function client();
|
||||
}
|
32
Modules/Product/app/Models/Product.php
Normal file
32
Modules/Product/app/Models/Product.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\Models;
|
||||
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Client\Models\Client;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
use StatusTrait, CreatedUpdatedBy;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'usps',
|
||||
'client_id',
|
||||
'status',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo(Client::class, 'client_id');
|
||||
}
|
||||
}
|
0
Modules/Product/app/Providers/.gitkeep
Normal file
0
Modules/Product/app/Providers/.gitkeep
Normal file
32
Modules/Product/app/Providers/EventServiceProvider.php
Normal file
32
Modules/Product/app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
123
Modules/Product/app/Providers/ProductServiceProvider.php
Normal file
123
Modules/Product/app/Providers/ProductServiceProvider.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Product\Interfaces\ProductInterface;
|
||||
use Modules\Product\Repositories\ProductRepository;
|
||||
|
||||
class ProductServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Product';
|
||||
|
||||
protected string $moduleNameLower = 'product';
|
||||
|
||||
/**
|
||||
* 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->bind(ProductInterface::class, ProductRepository::class);
|
||||
$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;
|
||||
}
|
||||
}
|
49
Modules/Product/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/Product/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\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('Product', '/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('Product', '/routes/api.php'));
|
||||
}
|
||||
}
|
60
Modules/Product/app/Repositories/ProductRepository.php
Normal file
60
Modules/Product/app/Repositories/ProductRepository.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\Repositories;
|
||||
|
||||
use Modules\Product\Interfaces\ProductInterface;
|
||||
use Modules\Product\Models\Product;
|
||||
|
||||
class ProductRepository implements ProductInterface
|
||||
{
|
||||
|
||||
public function findAll()
|
||||
{
|
||||
return Product::get();
|
||||
}
|
||||
|
||||
public function getProductById($productId)
|
||||
{
|
||||
return Product::findOrFail($productId);
|
||||
}
|
||||
|
||||
public function getProductList()
|
||||
{
|
||||
$products = Product::with('client:id,name')->get();
|
||||
|
||||
$keyed = $products->mapWithKeys(function (Product $item) {
|
||||
return [$item->id => $item->name.' ('.$item->client?->name.')'];
|
||||
});
|
||||
|
||||
return $keyed->all();
|
||||
}
|
||||
|
||||
public function create(array $productDetails)
|
||||
{
|
||||
return Product::create($productDetails);
|
||||
}
|
||||
|
||||
public function update($productId, array $newDetails)
|
||||
{
|
||||
return Product::whereId($productId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function delete($productId)
|
||||
{
|
||||
return Product::destroy($productId);
|
||||
}
|
||||
public function pluck()
|
||||
{
|
||||
return Product::pluck('name', 'id');
|
||||
}
|
||||
public function count()
|
||||
{
|
||||
return Product::count();
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return Product::with('client');
|
||||
}
|
||||
|
||||
}
|
30
Modules/Product/composer.json
Normal file
30
Modules/Product/composer.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "nwidart/product",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Product\\": "app/",
|
||||
"Modules\\Product\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\Product\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\Product\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Product/config/.gitkeep
Normal file
0
Modules/Product/config/.gitkeep
Normal file
5
Modules/Product/config/config.php
Normal file
5
Modules/Product/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Product',
|
||||
];
|
0
Modules/Product/database/factories/.gitkeep
Normal file
0
Modules/Product/database/factories/.gitkeep
Normal file
0
Modules/Product/database/migrations/.gitkeep
Normal file
0
Modules/Product/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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('products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->nullable();
|
||||
$table->longText('description')->nullable();
|
||||
$table->text('usps')->nullable();
|
||||
$table->unsignedBigInteger('client_id')->nullable();
|
||||
$table->integer('status')->default(11);
|
||||
$table->unsignedBigInteger('createdby')->nullable();
|
||||
$table->unsignedBigInteger('updatedby')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('products');
|
||||
}
|
||||
};
|
0
Modules/Product/database/seeders/.gitkeep
Normal file
0
Modules/Product/database/seeders/.gitkeep
Normal file
16
Modules/Product/database/seeders/ProductDatabaseSeeder.php
Normal file
16
Modules/Product/database/seeders/ProductDatabaseSeeder.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ProductDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// $this->call([]);
|
||||
}
|
||||
}
|
11
Modules/Product/module.json
Normal file
11
Modules/Product/module.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Product",
|
||||
"alias": "product",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Product\\Providers\\ProductServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/Product/package.json
Normal file
15
Modules/Product/package.json
Normal 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"
|
||||
}
|
||||
}
|
0
Modules/Product/resources/assets/.gitkeep
Normal file
0
Modules/Product/resources/assets/.gitkeep
Normal file
0
Modules/Product/resources/assets/js/app.js
Normal file
0
Modules/Product/resources/assets/js/app.js
Normal file
0
Modules/Product/resources/assets/sass/app.scss
Normal file
0
Modules/Product/resources/assets/sass/app.scss
Normal file
0
Modules/Product/resources/views/.gitkeep
Normal file
0
Modules/Product/resources/views/.gitkeep
Normal file
7
Modules/Product/resources/views/index.blade.php
Normal file
7
Modules/Product/resources/views/index.blade.php
Normal file
@@ -0,0 +1,7 @@
|
||||
@extends('product::layouts.master')
|
||||
|
||||
@section('content')
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<p>Module: {!! config('product.name') !!}</p>
|
||||
@endsection
|
29
Modules/Product/resources/views/layouts/master.blade.php
Normal file
29
Modules/Product/resources/views/layouts/master.blade.php
Normal 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>Product 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-product', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-product', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
16
Modules/Product/resources/views/products/create.blade.php
Normal file
16
Modules/Product/resources/views/products/create.blade.php
Normal file
@@ -0,0 +1,16 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
|
||||
<x-dashboard.breadcumb :title="$title" />
|
||||
|
||||
|
||||
{{ html()->form('POST')->route('product.store')->class(['needs-validation'])->attributes(['novalidate'])->open() }}
|
||||
|
||||
@include('product::products.partials.action')
|
||||
|
||||
{{ html()->form()->close() }}
|
||||
|
||||
|
||||
</div>
|
||||
@endsection
|
@@ -0,0 +1,18 @@
|
||||
<div class="hstack flex-wrap gap-3">
|
||||
@can('product.show')
|
||||
<a href="javascript:void(0)" data-link="{{ route('product.show', $id) }}" class="link-secondary fs-15 view-item-btn"><i
|
||||
class="ri-eye-fill"></i>
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
@can('product.edit')
|
||||
<a href="{{ route('product.edit', $id) }}" class="link-primary fs-15 edit-item-btn"><i class="ri-edit-2-fill"></i>
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
@can('product.destroy')
|
||||
<a href="javascript:void(0);" data-link="{{ route('product.destroy', $id) }}" data-id="{{ $id }}"
|
||||
class="link-danger fs-15 remove-item-btn"><i class="ri-delete-bin-fill"></i></a>
|
||||
@endcan
|
||||
|
||||
</div>
|
14
Modules/Product/resources/views/products/edit.blade.php
Normal file
14
Modules/Product/resources/views/products/edit.blade.php
Normal file
@@ -0,0 +1,14 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
|
||||
<x-dashboard.breadcumb :title="$title" />
|
||||
|
||||
|
||||
{{ html()->modelForm($product, 'PUT')->route('product.update', $product->id)->class(['needs-validation'])->attributes(['novalidate'])->open() }}
|
||||
@include('product::products.partials.action')
|
||||
{{ html()->form()->close() }}
|
||||
|
||||
|
||||
</div>
|
||||
@endsection
|
42
Modules/Product/resources/views/products/form.blade.php
Normal file
42
Modules/Product/resources/views/products/form.blade.php
Normal file
@@ -0,0 +1,42 @@
|
||||
@if(isset($product) && $product->id)
|
||||
{{ html()->modelForm($product, 'PUT')->route('product.update', $product->id)->class(['needs-validation'])->attributes(['novalidate'])->open() }}
|
||||
@else
|
||||
{{ html()->form('POST')->route('product.store')->class(['needs-validation'])->attributes(['novalidate'])->open() }}
|
||||
@endif
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row gy-3">
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Name')->class('form-label') }}
|
||||
{{ html()->text('name')->class('form-control')->value($product->name ?? null)->placeholder('Product Name')->required() }}
|
||||
{{ html()->div('Please enter product name')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Client')->class('form-label') }}
|
||||
{{ html()->select('client_id', $clients)->class('form-select select2')->value(!empty($product) ? $product?->client?->id : null)->placeholder('Select Client')->required() }}
|
||||
{{ html()->div('Please select client')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Status')->class('form-label') }}
|
||||
{{ html()->select('status', $status)->value($product->status ?? null)->class('form-select') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Description')->class('form-label') }}
|
||||
{{ html()->textarea('description')->value($product->description ?? null)->class('form-control') }}
|
||||
</div>
|
||||
|
||||
<x-form-buttons :editable="false" :label="isset($product) ? 'Update' : 'Save'" href="{{ route('product.index') }}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end card -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ html()->form()->close() }}
|
72
Modules/Product/resources/views/products/index.blade.php
Normal file
72
Modules/Product/resources/views/products/index.blade.php
Normal file
@@ -0,0 +1,72 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
|
||||
<x-dashboard.breadcumb :title="$title" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-xl-3">
|
||||
@include('product::products.form')
|
||||
</div>
|
||||
|
||||
<div class="col-lg-8 col-xl-9">
|
||||
<div class="card">
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
@php
|
||||
$columns = [
|
||||
[
|
||||
'title' => 'SN',
|
||||
'data' => 'DT_RowIndex',
|
||||
'name' => 'DT_RowIndex',
|
||||
'orderable' => false,
|
||||
'searchable' => false,
|
||||
],
|
||||
['title' => 'Client', 'data' => 'client', 'name' => 'client'],
|
||||
['title' => 'Name', 'data' => 'name', 'name' => 'name'],
|
||||
['title' => 'Status', 'data' => 'status', 'name' => 'status'],
|
||||
[
|
||||
'title' => 'Action',
|
||||
'data' => 'action',
|
||||
'orderable' => false,
|
||||
'searchable' => false,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
|
||||
<x-data-table-script :route="route('product.index')" :columns="$columns" />
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="viewModal" tabindex="-1" aria-labelledby="showgridLabel" aria-modal="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="showgridLabel">Product Detail</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
$(document).on("click", '.view-item-btn', function(e) {
|
||||
e.preventDefault();
|
||||
const url = $(this).attr('data-link');
|
||||
$.get(url, function(res) {
|
||||
$('#viewModal').modal('show');
|
||||
$('#viewModal .modal-body').html(res);
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
31
Modules/Product/resources/views/products/show.blade.php
Normal file
31
Modules/Product/resources/views/products/show.blade.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card-body p-2">
|
||||
<div class="table-responsive">
|
||||
<table class="table-borderless mb-0 table table-sm">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Client Name:</span></th>
|
||||
<td>{{ $product->client?->name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Product Name:</span></th>
|
||||
<td>{{ $product->name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Description:</span></th>
|
||||
<td>{!! $product->description !!}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Status:</span></th>
|
||||
<td>{!! $product->status_name !!}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<button type="button" class="btn btn-info" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
0
Modules/Product/routes/.gitkeep
Normal file
0
Modules/Product/routes/.gitkeep
Normal file
19
Modules/Product/routes/api.php
Normal file
19
Modules/Product/routes/api.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Product\Http\Controllers\ProductController;
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------
|
||||
* 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('product', ProductController::class)->names('product');
|
||||
});
|
19
Modules/Product/routes/web.php
Normal file
19
Modules/Product/routes/web.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Product\Http\Controllers\ProductController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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(['middleware' => ['web', 'auth', 'permission'], 'prefix' => 'admin/'], function () {
|
||||
Route::resource('product', ProductController::class)->names('product');
|
||||
});
|
0
Modules/Product/tests/Feature/.gitkeep
Normal file
0
Modules/Product/tests/Feature/.gitkeep
Normal file
0
Modules/Product/tests/Unit/.gitkeep
Normal file
0
Modules/Product/tests/Unit/.gitkeep
Normal file
26
Modules/Product/vite.config.js
Normal file
26
Modules/Product/vite.config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: '../../public/build-product',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-product',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/Product/resources/assets/sass/app.scss',
|
||||
// 'Modules/Product/resources/assets/js/app.js',
|
||||
//];
|
Reference in New Issue
Block a user