This commit is contained in:
Sampanna Rimal
2024-09-11 12:32:15 +05:45
parent 82fab174dc
commit afb2c202d6
170 changed files with 3352 additions and 363 deletions

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"
}
}

View File

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($setting, 'PUT')->route('setting.update', $setting->id)->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }}
@include('setting::setting.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,164 @@
<div class="row">
<div class="col-lg-9">
<div class="card">
<div class="card-body">
<div class="row gy-1">
<div class="col-md-12">
{{ html()->label('Title')->class('form-label') }}
{{ html()->text('title')->class('form-control')->placeholder('Enter Title')->required() }}
</div>
<div class="col-md-12">
{{ html()->label('Description')->class('form-label') }}
{{ html()->textarea('description')->class('form-control')->placeholder('Enter Description')->required() }}
</div>
<div class="col-md-6">
{{ html()->label('url1')->class('form-label') }}
{{ html()->text('url1')->class('form-control')->placeholder('Enter url1') }}
</div>
<div class="col-md-6">
{{ html()->label('url2')->class('form-label') }}
{{ html()->text('url2')->class('form-control')->placeholder('Enter url2') }}
</div>
<div class="col-md-6">
{{ html()->label('email')->class('form-label') }}
{{ html()->text('email')->class('form-control')->placeholder('Enter email') }}
</div>
<div class="col-md-6">
{{ html()->label('phone')->class('form-label') }}
{{ html()->text('phone')->class('form-control')->placeholder('Enter phone') }}
</div>
<div class="col-md-6">
{{ html()->label('secondary_phone')->class('form-label') }}
{{ html()->text('secondary_phone')->class('form-control')->placeholder('Enter secondary_phone') }}
</div>
<div class="col-md-12">
{{ html()->label('google_map')->class('form-label') }}
{{ html()->text('google_map')->class('form-control')->placeholder('Enter google_map') }}
</div>
<div class="col-md-6">
{{ html()->label('fb')->class('form-label') }}
{{ html()->text('fb')->class('form-control')->placeholder('Enter fb') }}
</div>
<div class="col-md-6">
{{ html()->label('insta')->class('form-label') }}
{{ html()->text('insta')->class('form-control')->placeholder('Enter insta') }}
</div>
<div class="col-md-6">
{{ html()->label('twitter')->class('form-label') }}
{{ html()->text('twitter')->class('form-control')->placeholder('Enter twitter') }}
</div>
<div class="col-md-6">
{{ html()->label('tiktok')->class('form-label') }}
{{ html()->text('tiktok')->class('form-control')->placeholder('Enter tiktok') }}
</div>
<div class="col-md-6">
{{ html()->label('copyright_text')->class('form-label') }}
{{ html()->text('copyright_text')->class('form-control')->placeholder('Enter copyright_text') }}
</div>
<div class="col-md-6">
{{ html()->label('content1')->class('form-label') }}
{{ html()->text('content1')->class('form-control')->placeholder('Enter content1') }}
</div>
<div class="col-md-6">
{{ html()->label('content2')->class('form-label') }}
{{ html()->text('content2')->class('form-control')->placeholder('Enter content2') }}
</div>
<div class="col-md-6">
{{ html()->label('content3')->class('form-label') }}
{{ html()->text('content3')->class('form-control')->placeholder('Enter content3') }}
</div>
<div class="col-md-6">
{{ html()->label('seo_title')->class('form-label') }}
{{ html()->text('seo_title')->class('form-control')->placeholder('Enter seo_title') }}
</div>
<div class="col-md-12">
{{ html()->label('seo_description')->class('form-label') }}
{{ html()->textarea('seo_description')->class('form-control')->placeholder('Enter seo_description')->required() }}
</div>
<div class="col-md-12">
{{ html()->label('seo_keywords')->class('form-label') }}
{{ html()->textarea('seo_keywords')->class('form-control')->placeholder('Enter seo_keywords')->required() }}
</div>
<div class="col-md-12">
{{ html()->label('og_tags')->class('form-label') }}
{{ html()->textarea('og_tags')->class('form-control')->placeholder('Enter og_tags')->required() }}
</div>
</div>
<!-- end card -->
</div>
<!-- end card -->
</div>
<div class="mb-3 text-end">
<a href="{{ route('stock.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-3">
<div class="card">
<div class="card-body">
<div class="row gy-2">
<div class="card-header mb-0">
<div class="page-title-box d-sm-flex align-items-center justify-content-center">
<h4 class="mb-sm-0">Images</h4>
</div>
</div>
<div class="col-md-12">
{{ html()->label('primary_logo')->class('form-label') }}
{{ html()->file('primary_logo')->class('form-control') }}
</div>
<div class="col-md-12">
{{ html()->label('secondary_logo')->class('form-label') }}
{{ html()->file('secondary_logo')->class('form-control') }}
</div>
<div class="col-md-12">
{{ html()->label('thumb')->class('form-label') }}
{{ html()->file('thumb')->class('form-control') }}
</div>
<div class="col-md-12">
{{ html()->label('icon')->class('form-label') }}
{{ html()->file('icon')->class('form-control') }}
</div>
<div class="col-md-12">
{{ html()->label('og_image')->class('form-label') }}
{{ html()->file('og_image')->class('form-control') }}
</div>
<div class="col-md-12">
{{ html()->label('no_image')->class('form-label') }}
{{ html()->file('no_image')->class('form-control') }}
</div>
<div class="mb-3 text-end">
<a href="{{ route('stock.index') }}" class="btn btn-danger w-sm">Cancel</a>
<button type="submit" class="btn btn-success w-sm">Save</button>
</div>
</div>
</div>
</div>
</div>

View File

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

View File

View File

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

View File

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

View File

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