changes
This commit is contained in:
0
Modules/Setting/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Setting/app/Http/Controllers/.gitkeep
Normal file
106
Modules/Setting/app/Http/Controllers/SettingController.php
Normal file
106
Modules/Setting/app/Http/Controllers/SettingController.php
Normal 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']);
|
||||
}
|
||||
}
|
0
Modules/Setting/app/Http/Requests/.gitkeep
Normal file
0
Modules/Setting/app/Http/Requests/.gitkeep
Normal file
0
Modules/Setting/app/Models/.gitkeep
Normal file
0
Modules/Setting/app/Models/.gitkeep
Normal file
15
Modules/Setting/app/Models/Setting.php
Normal file
15
Modules/Setting/app/Models/Setting.php
Normal 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'];
|
||||
}
|
0
Modules/Setting/app/Observers/.gitkeep
Normal file
0
Modules/Setting/app/Observers/.gitkeep
Normal file
0
Modules/Setting/app/Providers/.gitkeep
Normal file
0
Modules/Setting/app/Providers/.gitkeep
Normal file
32
Modules/Setting/app/Providers/EventServiceProvider.php
Normal file
32
Modules/Setting/app/Providers/EventServiceProvider.php
Normal 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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
49
Modules/Setting/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/Setting/app/Providers/RouteServiceProvider.php
Normal 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'));
|
||||
}
|
||||
}
|
120
Modules/Setting/app/Providers/SettingServiceProvider.php
Normal file
120
Modules/Setting/app/Providers/SettingServiceProvider.php
Normal 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;
|
||||
}
|
||||
}
|
0
Modules/Setting/app/Repositories/.gitkeep
Normal file
0
Modules/Setting/app/Repositories/.gitkeep
Normal file
15
Modules/Setting/app/Repositories/SettingInterface.php
Normal file
15
Modules/Setting/app/Repositories/SettingInterface.php
Normal 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();
|
||||
|
||||
}
|
46
Modules/Setting/app/Repositories/SettingRepository.php
Normal file
46
Modules/Setting/app/Repositories/SettingRepository.php
Normal 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');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user