firstcommit
This commit is contained in:
0
Modules/FAQ/app/Http/Controllers/.gitkeep
Normal file
0
Modules/FAQ/app/Http/Controllers/.gitkeep
Normal file
131
Modules/FAQ/app/Http/Controllers/FAQController.php
Normal file
131
Modules/FAQ/app/Http/Controllers/FAQController.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\FAQ\app\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\FAQ\app\Http\Requests\CreateFaqRequest;
|
||||
use Modules\FAQ\app\Repositories\FaqRepository;
|
||||
|
||||
class FAQController extends Controller
|
||||
{
|
||||
protected $faqRepository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->faqRepository = new FaqRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$perPage = $request->has('per-page') ? $request->input('per-page') : null;
|
||||
$filter = $request->has('filter') ? $request->input('filter') : [];
|
||||
$faqs = $this->faqRepository->allfaqs($perPage, $filter);
|
||||
|
||||
return view('faq::index', compact('faqs'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('faq::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(CreateFaqRequest $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$validated = $request->validated();
|
||||
|
||||
$this->faqRepository->storeFaq($validated);
|
||||
|
||||
toastr()->success('Faq created successfully!');
|
||||
|
||||
return redirect()->route('cms.faqs.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('faq::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($uuid)
|
||||
{
|
||||
$faq = $this->faqRepository->findFaqByUuid($uuid);
|
||||
if (! $faq) {
|
||||
toastr()->success('Faq not found');
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
return view('faq::edit', compact('faq'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(CreateFaqRequest $request, $uuid): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$validated = $request->validated();
|
||||
$faq = $this->faqRepository->updateFaq($validated, $uuid);
|
||||
if (! $faq) {
|
||||
toastr()->success('Faq not found');
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
return redirect()->route('cms.faqs.index')->with('success', 'Faq updated successfully');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
|
||||
return redirect()->back()->with('error', 'An error occurred');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$faq = $this->faqRepository->deleteFaq($uuid);
|
||||
if (! $faq) {
|
||||
toastr()->error('Faq not found');
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
toastr()->success('FAQ deleted successfully.');
|
||||
|
||||
return redirect()->route('cms.faqs.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong');
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/FAQ/app/Http/Middleware/.gitkeep
Normal file
0
Modules/FAQ/app/Http/Middleware/.gitkeep
Normal file
0
Modules/FAQ/app/Http/Requests/.gitkeep
Normal file
0
Modules/FAQ/app/Http/Requests/.gitkeep
Normal file
51
Modules/FAQ/app/Http/Requests/CreateFaqRequest.php
Normal file
51
Modules/FAQ/app/Http/Requests/CreateFaqRequest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\FAQ\app\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateFaqRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'question' => 'required|string|max:1000',
|
||||
'answer' => 'required|string|max:1000',
|
||||
'ordering' => 'required|integer|min:1',
|
||||
'status' => 'required|in:active,inactive',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'question.required' => 'The question field is required.',
|
||||
'question.string' => 'The question field must be a string.',
|
||||
'question.max' => 'The question may not be greater than 1000 characters.',
|
||||
|
||||
'answer.required' => 'The answer field is required.',
|
||||
'answer.string' => 'The answer field must be a string.',
|
||||
'answer.max' => 'The answer may not be greater than 1000 characters.',
|
||||
|
||||
'ordering.required' => 'The ordering field is required.',
|
||||
'ordering.integer' => 'The ordering field must be an integer.',
|
||||
'ordering.min' => 'The ordering field must be at least 1.',
|
||||
|
||||
'status.required' => 'The status field is required.',
|
||||
'status.in' => 'The status field must be either "active" or "inactive".',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
// return auth()->user()->can('users.create');
|
||||
}
|
||||
}
|
0
Modules/FAQ/app/Models/.gitkeep
Normal file
0
Modules/FAQ/app/Models/.gitkeep
Normal file
30
Modules/FAQ/app/Models/Faq.php
Normal file
30
Modules/FAQ/app/Models/Faq.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\FAQ\app\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Modules\FAQ\Database\factories\FaqFactory;
|
||||
|
||||
class Faq extends Model
|
||||
{
|
||||
// use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'question',
|
||||
'answer',
|
||||
'ordering',
|
||||
'status'
|
||||
];
|
||||
|
||||
// protected static function newFactory(): FaqFactory
|
||||
// {
|
||||
// //return FaqFactory::new();
|
||||
// }
|
||||
}
|
0
Modules/FAQ/app/Providers/.gitkeep
Normal file
0
Modules/FAQ/app/Providers/.gitkeep
Normal file
114
Modules/FAQ/app/Providers/FAQServiceProvider.php
Normal file
114
Modules/FAQ/app/Providers/FAQServiceProvider.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\FAQ\app\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class FAQServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'FAQ';
|
||||
|
||||
protected string $moduleNameLower = 'faq';
|
||||
|
||||
/**
|
||||
* 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(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.'\\'.config('modules.paths.generator.component-class.path'));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
59
Modules/FAQ/app/Providers/RouteServiceProvider.php
Normal file
59
Modules/FAQ/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\FAQ\app\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*/
|
||||
protected string $moduleNamespace = 'Modules\FAQ\app\Http\Controllers';
|
||||
|
||||
/**
|
||||
* 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')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('FAQ', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('FAQ', '/routes/api.php'));
|
||||
}
|
||||
}
|
103
Modules/FAQ/app/Repositories/FaqRepository.php
Normal file
103
Modules/FAQ/app/Repositories/FaqRepository.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\FAQ\app\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\FAQ\app\Models\Faq;
|
||||
|
||||
class FaqRepository
|
||||
{
|
||||
//-- Retrieve all Services
|
||||
public function allfaqs($perPage = null, $filter = [], $sort = ['by' => 'id', 'sort' => 'DESC'])
|
||||
{
|
||||
return Faq::when(array_keys($filter, true), function ($query) use ($filter) {
|
||||
if (! empty($filter['question'])) {
|
||||
$query->where('question', $filter['question']);
|
||||
}
|
||||
if (! empty($filter['answer'])) {
|
||||
$query->where('answer', 'like', '%'.$filter['answer'].'%');
|
||||
}
|
||||
})
|
||||
->orderBy($sort['by'], $sort['sort'])
|
||||
->paginate($perPage ?: env('PAGE_LIMIT', 999));
|
||||
}
|
||||
|
||||
//-- Find Service by uuid
|
||||
public function findFaqByUuid($uuid)
|
||||
{
|
||||
return Faq::where('uuid', $uuid)->first();
|
||||
}
|
||||
|
||||
public function storeFaq(array $validated)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$faq = new Faq();
|
||||
$faq->uuid = Str::uuid();
|
||||
$faq->question = $validated['question'];
|
||||
$faq->answer = $validated['answer'];
|
||||
$faq->ordering = $validated['ordering'];
|
||||
$faq->status = $validated['status'];
|
||||
$faq->save();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $faq;
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
DB::rollback();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateFaq($validated, $uuid)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$faq = $this->findFaqByUuid($uuid);
|
||||
|
||||
if (! $faq) {
|
||||
return null;
|
||||
}
|
||||
$faq->question = $validated['question'];
|
||||
$faq->answer = $validated['answer'];
|
||||
$faq->ordering = $validated['ordering'];
|
||||
$faq->ordering = $validated['ordering'];
|
||||
$faq->status = $validated['status'];
|
||||
$faq->save();
|
||||
|
||||
return $faq;
|
||||
DB::commit();
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
DB::rollBack();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//-- Delete Testimonial
|
||||
public function deleteFaq(string $uuid)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$faq = $this->findFaqByUuid($uuid);
|
||||
if (! $faq) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$faq->delete();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $faq;
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
DB::rollBack();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
31
Modules/FAQ/composer.json
Normal file
31
Modules/FAQ/composer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "nwidart/faq",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\FAQ\\": "",
|
||||
"Modules\\FAQ\\App\\": "app/",
|
||||
"Modules\\FAQ\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\FAQ\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\FAQ\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/FAQ/config/.gitkeep
Normal file
0
Modules/FAQ/config/.gitkeep
Normal file
5
Modules/FAQ/config/config.php
Normal file
5
Modules/FAQ/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'FAQ',
|
||||
];
|
0
Modules/FAQ/database/factories/.gitkeep
Normal file
0
Modules/FAQ/database/factories/.gitkeep
Normal file
0
Modules/FAQ/database/migrations/.gitkeep
Normal file
0
Modules/FAQ/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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('faqs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid();
|
||||
$table->string('question');
|
||||
$table->string('answer', 1000);
|
||||
$table->integer('ordering');
|
||||
$table->string('status')->default('active');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('faqs');
|
||||
}
|
||||
};
|
0
Modules/FAQ/database/seeders/.gitkeep
Normal file
0
Modules/FAQ/database/seeders/.gitkeep
Normal file
42
Modules/FAQ/database/seeders/FAQDatabaseSeeder.php
Normal file
42
Modules/FAQ/database/seeders/FAQDatabaseSeeder.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\FAQ\database\seeders;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\FAQ\app\Models\Faq;
|
||||
|
||||
class FAQDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$faqs = [
|
||||
[
|
||||
'uuid' => Str::uuid(),
|
||||
'question' => 'Do I need to complete the Philippines eTravel declaration?',
|
||||
'answer' => 'The Philippines eTravel system is mandatory for all passengers traveling to and from the Philippines. You cannot enter or leave the country without an approved declaration.',
|
||||
'ordering' => 20,
|
||||
'status' => 'active'
|
||||
],
|
||||
[
|
||||
'uuid' => Str::uuid(),
|
||||
'question' => 'Can I use my time machine to travel to the past and meet dinosaurs?',
|
||||
'answer' => "While the idea of meeting dinosaurs is exciting, unfortunately, time travel technology doesn't exist yet. It's purely a concept in science fiction. However, you can always learn about dinosaurs through books, museums, and documentaries to satisfy your curiosity about these ancient creatures!",
|
||||
'ordering' => 2,
|
||||
'status' => 'active'
|
||||
]
|
||||
];
|
||||
foreach ($faqs as $faq) {
|
||||
$faq = Faq::create([
|
||||
'uuid' => Str::uuid(),
|
||||
'question' => $faq['question'],
|
||||
'answer' => $faq['answer'],
|
||||
'ordering' => $faq['ordering'],
|
||||
'status' => $faq['status'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/FAQ/lang/.gitkeep
Normal file
0
Modules/FAQ/lang/.gitkeep
Normal file
11
Modules/FAQ/module.json
Normal file
11
Modules/FAQ/module.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "FAQ",
|
||||
"alias": "faq",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\FAQ\\app\\Providers\\FAQServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/FAQ/package.json
Normal file
15
Modules/FAQ/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/FAQ/resources/assets/.gitkeep
Normal file
0
Modules/FAQ/resources/assets/.gitkeep
Normal file
0
Modules/FAQ/resources/assets/js/app.js
Normal file
0
Modules/FAQ/resources/assets/js/app.js
Normal file
0
Modules/FAQ/resources/assets/sass/app.scss
Normal file
0
Modules/FAQ/resources/assets/sass/app.scss
Normal file
0
Modules/FAQ/resources/views/.gitkeep
Normal file
0
Modules/FAQ/resources/views/.gitkeep
Normal file
47
Modules/FAQ/resources/views/create.blade.php
Normal file
47
Modules/FAQ/resources/views/create.blade.php
Normal file
@@ -0,0 +1,47 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Create FAQ
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'FAQ',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'FAQs',
|
||||
'link' => null,
|
||||
],
|
||||
[
|
||||
'title' => 'Add FAQ',
|
||||
'link' => null,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
|
||||
@endsection
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-xxl">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex align-items-center justify-content-between">
|
||||
<h5 class="mb-0">Add Faq</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form
|
||||
action="{{ route('cms.faqs.store')}}"
|
||||
method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('faq::partial.form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
49
Modules/FAQ/resources/views/edit.blade.php
Normal file
49
Modules/FAQ/resources/views/edit.blade.php
Normal file
@@ -0,0 +1,49 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Update FAQ
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'FAQ',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'FAQs',
|
||||
'link' => null,
|
||||
],
|
||||
[
|
||||
'title' => 'Update FAQ',
|
||||
'link' => null,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
|
||||
@endsection
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-xxl">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex align-items-center justify-content-between">
|
||||
<h5 class="mb-0">Update Faq</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('cms.faqs.update', ['uuid' => $faq->uuid]) }}" method="POST"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
@include('faq::partial.form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
134
Modules/FAQ/resources/views/index.blade.php
Normal file
134
Modules/FAQ/resources/views/index.blade.php
Normal file
@@ -0,0 +1,134 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
FAQ
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'FAQ',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'FAQs',
|
||||
'link' => null,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h4 class="card-header">List of FAQ</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="flex-column flex-md-row">
|
||||
<div class="dt-action-buttons text-end pt-3 px-3">
|
||||
<div class="dt-buttons btn-group flex-wrap">
|
||||
<a href="{{ route('cms.faqs.create') }}"
|
||||
class="btn btn-secondary create-new btn-primary d-none d-sm-inline-block text-white">
|
||||
<i class="bx bx-plus me-sm-1"></i>
|
||||
Add New
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-datatable table-responsive">
|
||||
<table class="datatables-users table border-top">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>S.N</th>
|
||||
<th>Question</th>
|
||||
<th>Answer</th>
|
||||
<th>Ordering</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="table-border-bottom-0">
|
||||
@if(count($faqs) > 0)
|
||||
@foreach ($faqs ?? [] as $faq)
|
||||
<tr>
|
||||
<td>
|
||||
#{{ $loop->iteration }}
|
||||
</td>
|
||||
<td>
|
||||
{{ Str::words($faq->question, 4, '...') }}
|
||||
</td>
|
||||
<td>
|
||||
{{ Str::words($faq->answer, 7, '...') }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $faq->ordering }}
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
class="badge bg-label-{{ $faq->status == 'active' ? 'success' : 'danger' }}">
|
||||
{{ $faq->status }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn p-0 dropdown-toggle hide-arrow"
|
||||
data-bs-toggle="dropdown">
|
||||
<i class="bx bx-dots-vertical-rounded"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('cms.faqs.edit', ['uuid' => $faq->uuid]) }}"><i
|
||||
class="bx bx-edit-alt me-1"></i>
|
||||
Edit</a>
|
||||
|
||||
{{-- <div class="dropdown-item btn-delete" data-name="[ {{ $faq->question }} ]"
|
||||
data-action="{{ route('cms.faqs.delete', ['uuid' => $faq->uuid]) }}"
|
||||
>
|
||||
<i class="bx bx-trash me-1"></i> Delete
|
||||
</div> --}}
|
||||
<form method="POST" action="{{ route('cms.faqs.delete', ['uuid' => $faq->uuid]) }}"
|
||||
id="deleteForm_{{ $faq->uuid }}" class="dropdown-item">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="border-0 bg-transparent deleteBtn"
|
||||
style="color:inherit"><i class="bx bx-trash me-1"></i>
|
||||
Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td colspan="6">No record found.</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="px-3">
|
||||
{{ $faqs->links('admin::layouts.partials.pagination') }}
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
{{-- style --}}
|
||||
@push('required-styles')
|
||||
@include('admin::vendor.dataTables.style')
|
||||
@endpush
|
||||
|
||||
{{-- script --}}
|
||||
@push('required-scripts')
|
||||
@include('admin::vendor.dataTables.script')
|
||||
@endpush
|
29
Modules/FAQ/resources/views/layouts/master.blade.php
Normal file
29
Modules/FAQ/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>FAQ 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-faq', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-faq', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
60
Modules/FAQ/resources/views/partial/form.blade.php
Normal file
60
Modules/FAQ/resources/views/partial/form.blade.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="basic-default-name">Question</label>
|
||||
<input type="text" class="form-control" name="question" value="{{ old('question', $faq->question ?? '') }}"
|
||||
placeholder="e.g. How to add about us page? " required />
|
||||
@error('question')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="basic-default-name">Answer</label>
|
||||
<textarea name="" id="mainTextarea" class="d-none">{{ !empty($faq) ? $faq->answer : '' }}</textarea>
|
||||
<textarea name="answer" class="form-control full-editor" id="editorTextarea" rows='5' required
|
||||
placeholder="e.g. First login as admin, then click on the pages from cms and fillup form and submit. "></textarea>
|
||||
@error('answer')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3 col-md-6"">
|
||||
<label class="form-label" for="basic-default-name">Ordering</label>
|
||||
<input type="number" class="form-control" name="ordering"
|
||||
value="{{ old('ordering', $faq->ordering ?? '') }}" placeholder="e.g. 30" required />
|
||||
@error('ordering')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="basic-default-company">Status</label>
|
||||
<select class="select2 form-select" id="basic-default-company select2Basic"
|
||||
aria-label="Default select example" name="status" required>
|
||||
<option value="active"{{ ($faq->status ?? '') == 'active' ? 'selected' : '' }}>Active</option>
|
||||
<option value="inactive"{{ ($faq->status ?? '') == 'inactive' ? 'selected' : '' }}>Inactive</option>
|
||||
</select>
|
||||
@error('status')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
@if (empty($faq))
|
||||
Save Faq
|
||||
@else
|
||||
Update Faq
|
||||
@endif
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('required-styles')
|
||||
@include('admin::vendor.full_editor.style')
|
||||
@include('admin::vendor.select2.style')
|
||||
@endpush
|
||||
|
||||
@push('required-scripts')
|
||||
@include('admin::vendor.textareaContentDisplay.script')
|
||||
@include('admin::vendor.full_editor.script')
|
||||
@include('admin::vendor.select2.script')
|
||||
@endpush
|
0
Modules/FAQ/routes/.gitkeep
Normal file
0
Modules/FAQ/routes/.gitkeep
Normal file
19
Modules/FAQ/routes/api.php
Normal file
19
Modules/FAQ/routes/api.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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')->name('api.')->group(function () {
|
||||
Route::get('faq', fn (Request $request) => $request->user())->name('faq');
|
||||
});
|
40
Modules/FAQ/routes/web.php
Normal file
40
Modules/FAQ/routes/web.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\FAQ\app\Http\Controllers\FAQController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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(
|
||||
[
|
||||
'prefix' => 'apanel',
|
||||
'middleware' => ['auth'],
|
||||
'as' => 'cms.',
|
||||
],
|
||||
function () {
|
||||
Route::group(
|
||||
[
|
||||
'prefix' => 'cms',
|
||||
'as' => 'faqs.',
|
||||
'controller' => 'FAQController',
|
||||
],
|
||||
function () {
|
||||
Route::get('faqs', 'index')->name('index');
|
||||
Route::get('faqs/create', 'create')->name('create');
|
||||
Route::post('faqs/store', 'store')->name('store');
|
||||
Route::get('faqs/{uuid}/edit', 'edit')->name('edit');
|
||||
Route::put('faqs/{uuid}/update', 'update')->name('update');
|
||||
Route::delete('faqs/{uuid}/delete', 'destroy')->name('delete');
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
0
Modules/FAQ/tests/Feature/.gitkeep
Normal file
0
Modules/FAQ/tests/Feature/.gitkeep
Normal file
0
Modules/FAQ/tests/Unit/.gitkeep
Normal file
0
Modules/FAQ/tests/Unit/.gitkeep
Normal file
26
Modules/FAQ/vite.config.js
Normal file
26
Modules/FAQ/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-faq',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-faq',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss',
|
||||
// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js',
|
||||
//];
|
Reference in New Issue
Block a user