firstcommit

This commit is contained in:
2025-08-17 16:23:14 +05:45
commit 76bf4c0a18
2648 changed files with 362795 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
<?php
namespace Modules\Testimonial\app\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Modules\Testimonial\app\Http\Requests\CreateTestimonialRequest;
use Modules\Testimonial\app\Repositories\TestimonialRepository;
class TestimonialController extends Controller
{
protected $testimonialRepository;
public function __construct()
{
$this->testimonialRepository = new TestimonialRepository;
}
/**
* 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') : [];
$testimonials = $this->testimonialRepository->allTestimonials($perPage, $filter);
return view('testimonial::index', compact('testimonials'));
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('testimonial::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(CreateTestimonialRequest $request): RedirectResponse
{
try {
$validated = $request->validated();
$this->testimonialRepository->storeTestimonial($validated);
toastr()->success('Testimonial created successfully!');
return redirect()->route('cms.testimonials.index');
} catch (\Throwable $th) {
report($th);
toastr()->error('Something went wrong.');
return back();
}
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('testimonial::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($uuid)
{
$testimonial = $this->testimonialRepository->findTestimonialByUuid($uuid);
if (!$testimonial) {
toastr()->error('Testimonial not found');
return back();
}
return view('testimonial::edit', compact('testimonial'));
}
/**
* Update the specified resource in storage.
*/
public function update(CreateTestimonialRequest $request, $uuid): RedirectResponse
{
try {
$validated = $request->validated();
$testimonial = $this->testimonialRepository->updateTestimonial($validated, $uuid);
if (!$testimonial) {
toastr()->error('Testimonial not found !');
return null;
}
toastr()->success('Testimonial updated successfully.');
return redirect()->route('cms.testimonials.index');
} catch (\Throwable $th) {
report($th);
toastr()->error('Something went wrong.');
return redirect()->back();
}
}
/**
* Remove the specified resource from storage.
*/
public function destroy($uuid)
{
DB::beginTransaction();
try {
$testimonial = $this->testimonialRepository->deleteTestimonial($uuid);
if (!$testimonial) {
toastr()->error('Testimonial not found');
return back();
}
DB::commit();
toastr()->success('Testimonial deleted successfully.');
return redirect()->route('cms.testimonials.index');
} catch (\Throwable $th) {
DB::rollback();
report($th);
return back()->error('Something went wrong');
}
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Modules\Testimonial\app\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CreateTestimonialRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'name' => 'required|string|max:255',
'designation' => 'sometimes|nullable',
'ordering' => 'required|integer|min:1',
'statement' => 'required|string',
'link' => 'sometimes|nullable|string',
'status' => 'required|in:active,inactive',
'image' => 'sometimes|nullable|image|mimes:jpeg,png,jpg,gif',
];
}
public function messages()
{
return [
'name.required' => 'The name field is required.',
'name.string' => 'The name field must be a string.',
'name.max' => 'The name may not be greater than 255 characters.',
'ordering.required' => 'The ordering field is required.',
'ordering.integer' => 'The ordering field must be an integer.',
'ordering.min' => 'The ordering field must be a positive number.',
'statement.required' => 'The statement field is required.',
'statement.string' => 'The statement field must be a string.',
'link.string' => 'The link field must be a string.',
'status.required' => 'The status field is required.',
'status.in' => 'The status field must be either "active" or "inactive".',
'image.image' => 'The image must be an image file.',
'image.mimes' => 'The image must be a file of type: jpeg, png, jpg, gif.',
];
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
// return auth()->user()->can('users.create');
}
}

View File

View File

@@ -0,0 +1,43 @@
<?php
namespace Modules\Testimonial\app\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Testimonial\Database\factories\TestimonialFactory;
class Testimonial extends Model
{
const FILE_PATH = 'uploads/testimonials/';
// use HasFactory;
use SoftDeletes;
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'uuid',
'name',
'designation',
'ordering',
'statement',
'image',
'image_path',
'status',
'link',
];
protected static function newFactory(): TestimonialFactory
{
//return TestimonialFactory::new();
}
public function getFullImageAttribute()
{
return $this->image ? asset('storage/' . Self::FILE_PATH . $this->image) : null;
}
}

View File

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

View File

@@ -0,0 +1,114 @@
<?php
namespace Modules\Testimonial\app\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class TestimonialServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Testimonial';
protected string $moduleNameLower = 'testimonial';
/**
* 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;
}
}

View File

@@ -0,0 +1,130 @@
<?php
namespace Modules\Testimonial\app\Repositories;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Modules\Banner\app\Services\FileManagementService;
use Modules\Testimonial\app\Models\Testimonial;
class TestimonialRepository
{
//-- Retrieve all Services
public function allTestimonials($perPage = null, $filter = [], $sort = ['by' => 'id', 'sort' => 'DESC'])
{
return Testimonial::when(array_keys($filter, true), function ($query) use ($filter) {
if (! empty($filter['name'])) {
$query->where('name', $filter['name']);
}
if (! empty($filter['designation'])) {
$query->where('designation', 'like', '%'.$filter['designation'].'%');
}
})
->orderBy($sort['by'], $sort['sort'])
->paginate($perPage ?: env('PAGE_LIMIT', 999));
}
//-- Find Service by uuid
public function findTestimonialByUuid($uuid)
{
return Testimonial::where('uuid', $uuid)->first();
}
public function storeTestimonial(array $validated)
{
DB::beginTransaction();
try {
$testimonial = new Testimonial();
$testimonial->uuid = Str::uuid();
$testimonial->name = $validated['name'];
$testimonial->designation = $validated['designation'];
$testimonial->ordering = $validated['ordering'];
$testimonial->statement = $validated['statement'];
$testimonial->statement = $validated['statement'];
$testimonial->link = $validated['link'];
$testimonial->save();
if (isset($validated['image']) && $validated['image']->isValid()) {
FileManagementService::storeFile(
file: $validated['image'],
uploadedFolderName: 'testimonials',
model: $testimonial
);
}
DB::commit();
return $testimonial;
} catch (\Throwable $th) {
report($th);
DB::rollback();
return null;
}
}
public function updateTestimonial($validated, $uuid)
{
DB::beginTransaction();
try {
$testimonial = $this->findTestimonialByUuid($uuid);
if (! $testimonial) {
return null;
}
$testimonial->name = $validated['name'];
$testimonial->designation = $validated['designation'];
$testimonial->ordering = $validated['ordering'];
$testimonial->statement = $validated['statement'];
$testimonial->link = $validated['link'];
$testimonial->status = $validated['status'];
$testimonial->save();
if (isset($validated['image']) && $validated['image']->isValid()) {
FileManagementService::uploadFile(
file: $validated['image'],
uploadedFolderName: 'testimonials',
filePath: $testimonial->image_path,
model: $testimonial
);
}
return $testimonial;
DB::commit();
} catch (\Throwable $th) {
report($th);
DB::rollBack();
return null;
}
}
//-- Delete Testimonial
public function deleteTestimonial(string $uuid)
{
DB::beginTransaction();
try {
$testimonial = $this->findTestimonialByUuid($uuid);
if (! $testimonial) {
return null;
}
// Delete the image file associated with the activity
if ($testimonial->image_path !== null) {
FileManagementService::deleteFile($testimonial->image_path);
}
$testimonial->delete();
DB::commit();
return $testimonial;
} catch (\Throwable $th) {
DB::rollBack();
report($th);
return null;
}
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Modules\Testimonial\app\Services;
use Illuminate\Support\Facades\Storage;
class FileManagementService
{
//-- store file
public static function storeFile($file, $uploadedFolderName, $model)
{
try {
$originalFileName = $file->getClientOriginalName();
$modifiedFileName = date('YmdHis') . "_" . uniqid() . "." . $originalFileName;
$file->storeAs($uploadedFolderName, $modifiedFileName, 'public_uploads'); // This line uses 'public_uploads' disk
$model->image = $modifiedFileName;
$model->image_path = $uploadedFolderName . '/' . $modifiedFileName;
$model->save();
} catch (\Throwable $th) {
report($th);
toastr()->error('Something went wrong.');
return redirect()->back();
}
}
//-- update file
public static function uploadFile($file, $uploadedFolderName ,$filePath, $model)
{
try {
if ($filePath && Storage::disk('public_uploads')->exists($filePath)) {
Storage::disk('public_uploads')->delete($filePath);
}
$originalFileName = $file->getClientOriginalName();
$modifiedFileName = date('YmdHis') . "_" . uniqid() . "." . $originalFileName;
$file->storeAs($uploadedFolderName, $modifiedFileName, 'public_uploads'); // This line uses 'public_uploads' disk
$model->image = $modifiedFileName;
$model->image_path = $uploadedFolderName . '/' . $modifiedFileName;
$model->save();
} catch (\Throwable $th) {
report($th);
toastr()->error('Something went wrong.');
return redirect()->back();
}
}
//-- delete file
public static function deleteFile($filePath)
{
try {
if ($filePath && Storage::disk('public_uploads')->exists($filePath)) {
Storage::disk('public_uploads')->delete($filePath);
} else {
toastr()->error('File Not wrong.');
}
} catch (\Throwable $th) {
report($th);
toastr()->error('Something went wrong while deleting the file.');
}
}
}

View File

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

View File

View File

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

View File

@@ -0,0 +1,36 @@
<?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('testimonials', function (Blueprint $table) {
$table->id();
$table->uuid();
$table->string('name')->nullable();
$table->string('designation')->nullable();
$table->integer('ordering');
$table->string('statement',1000);
$table->string('image')->nullable();
$table->string('image_path')->nullable();
$table->string('status')->default('active');
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('testimonials');
}
};

View File

@@ -0,0 +1,28 @@
<?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::table('testimonials', function (Blueprint $table) {
$table->string('link', 10000)->nullable()->after('image_path');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('testimonials', function (Blueprint $table) {
$table->dropColumn('link');
});
}
};

View File

@@ -0,0 +1,137 @@
<?php
namespace Modules\Testimonial\database\seeders;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
use Modules\Testimonial\app\Models\Testimonial;
class TestimonialDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$testimonials = [
//-- With youtube video link
[
'image' => '',
'name' => 'Paras Khadka',
'designation' => 'Former Nepali CricketTeam Captain',
'company' => '',
'ordering' => 1,
'statement' => "When I first thought about hair restoration, I thought, is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water? So, having gone through this procedure and seeing the results—its the same as my natural hair. It IS my hair, so it doesnt fall out. I would say that Arogin has the most advanced technology on the market right now.",
'link' => '<iframe width="100%" height="300px" style="border-radius: 12px;" src="https://www.youtube.com/embed/NbFJ8W8L-3s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
],
[
'image' => '',
'name' => 'Paras Khadka',
'designation' => 'Former Nepali CricketTeam Captain',
'company' => '',
'ordering' => 2,
'statement' => "When I first thought about hair restoration, I thought, is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water? So, having gone through this procedure and seeing the results—its the same as my natural hair. It IS my hair, so it doesnt fall out. I would say that Arogin has the most advanced technology on the market right now.",
'link' => '<iframe width="100%" height="300px" style="border-radius: 12px;" src="https://www.youtube.com/embed/NbFJ8W8L-3s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
],
[
'image' => '',
'name' => 'Paras Khadka',
'designation' => 'Former Nepali CricketTeam Captain',
'company' => '',
'ordering' => 3,
'statement' => "When I first thought about hair restoration, I thought, is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water? So, having gone through this procedure and seeing the results—its the same as my natural hair. It IS my hair, so it doesnt fall out. I would say that Arogin has the most advanced technology on the market right now.",
'link' => '<iframe width="100%" height="300px" style="border-radius: 12px;" src="https://www.youtube.com/embed/NbFJ8W8L-3s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
],
[
'image' => '',
'name' => 'Paras Khadka',
'designation' => 'Former Nepali CricketTeam Captain',
'company' => '',
'ordering' => 4,
'statement' => "When I first thought about hair restoration, I thought, is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water? So, having gone through this procedure and seeing the results—its the same as my natural hair. It IS my hair, so it doesnt fall out. I would say that Arogin has the most advanced technology on the market right now.",
'link' => '<iframe width="100%" height="300px" style="border-radius: 12px;" src="https://www.youtube.com/embed/NbFJ8W8L-3s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
],
//-- With Image Only
[
'image' => 't1.png',
'name' => 'Rahul Sharma',
'designation' => '',
'company' => '',
'ordering' => 1,
'statement' => "When I first thought about hair restoration, I thought, is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water? So, having gone through this procedure and seeing the results—its the same as my natural hair. It IS my hair, so it doesnt fall out. I would say that Arogin has the most advanced technology on the market right now.",
'link' => ''
],
[
'image' => 't1.png',
'name' => 'Rahul Sharma',
'designation' => '',
'company' => '',
'ordering' => 2,
'statement' => "When I first thought about hair restoration, I thought, is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water? So, having gone through this procedure and seeing the results—its the same as my natural hair. It IS my hair, so it doesnt fall out. I would say that Arogin has the most advanced technology on the market right now.",
'link' => ''
],
[
'image' => 't1.png',
'name' => 'Rahul Sharma',
'designation' => '',
'company' => '',
'ordering' => 3,
'statement' => "When I first thought about hair restoration, I thought, is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water? So, having gone through this procedure and seeing the results—its the same as my natural hair. It IS my hair, so it doesnt fall out. I would say that Arogin has the most advanced technology on the market right now.",
'link' => ''
],
[
'image' => 't1.png',
'name' => 'Rahul Sharma',
'designation' => '',
'company' => '',
'ordering' => 4,
'statement' => "When I first thought about hair restoration, I thought, is it going to fall out if I do something active—if I go on roller coasters, or if I am in the water? So, having gone through this procedure and seeing the results—its the same as my natural hair. It IS my hair, so it doesnt fall out. I would say that Arogin has the most advanced technology on the market right now.",
'link' => ''
],
];
foreach ($testimonials as $testimonial) {
$cmsTestimonial = Testimonial::create([
'uuid' => Str::uuid(),
'name' => $testimonial['name'],
'designation' => $testimonial['designation'],
'ordering' => $testimonial['ordering'],
'statement' => $testimonial['statement'],
'link' => $testimonial['link'],
]);
if (!empty($testimonial['image'])) {
// Add image to the created banner
$this->uploadImageForTestimonial($testimonial['image'], $cmsTestimonial);
}
}
}
private function uploadImageForTestimonial(string $imageFileName, $cmsbanner)
{
$seederDirPath = 'testimonials/';
// Generate a unique filename for the new image
$newFileName = Str::uuid() . '.jpg';
// Storage path for the new image
$storagePath = '/testimonials/' . $newFileName;
// Check if the image exists in the seeder_disk
if (Storage::disk('seeder_disk')->exists($seederDirPath . $imageFileName)) {
// Copy the image from seeder to public
$fileContents = Storage::disk('seeder_disk')->get($seederDirPath . $imageFileName);
Storage::disk('public_uploads')->put($storagePath, $fileContents);
$cmsbanner->image = $newFileName;
$cmsbanner->image_path = $storagePath;
$cmsbanner->save();
}
}
}

View File

View File

@@ -0,0 +1,11 @@
{
"name": "Testimonial",
"alias": "testimonial",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Testimonial\\app\\Providers\\TestimonialServiceProvider"
],
"files": []
}

View File

@@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.5",
"sass": "^1.69.5",
"postcss": "^8.3.7",
"vite": "^4.0.0"
}
}

View File

@@ -0,0 +1,46 @@
@extends('admin::layouts.master')
@section('title')
Create Testimonial
@endsection
@section('breadcrumb')
@php
$breadcrumbData = [
[
'title' => 'Testimonial',
'link' => 'null',
],
[
'title' => 'Dashboard',
'link' => route('dashboard'),
],
[
'title' => 'Testimonials',
'link' => null,
],
[
'title' => 'Add Testimonial',
'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 Testimonial</h5>
</div>
<div class="card-body">
<form
action="{{ route('cms.testimonials.store')}}"
method="POST" enctype="multipart/form-data">
@csrf
@include('testimonial::partial.form')
</form>
</div>
</div>
</div>@endsection

View File

@@ -0,0 +1,49 @@
@extends('admin::layouts.master')
@section('title')
Update Testimonial
@endsection
@section('breadcrumb')
@php
$breadcrumbData = [
[
'title' => 'Testimonial',
'link' => 'null',
],
[
'title' => 'Dashboard',
'link' => route('dashboard'),
],
[
'title' => 'Testimonials',
'link' => null,
],
[
'title' => 'Update Testimonial',
'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 Testimonial</h5>
</div>
<div class="card-body">
<form
action="{{ route('cms.testimonials.update', ['uuid' => $testimonial->uuid]) }}"
method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
@include('testimonial::partial.form')
</form>
</div>
</div>
</div>
</div>@endsection

View File

@@ -0,0 +1,137 @@
@extends('admin::layouts.master')
@section('title')
Testimonial
@endsection
@section('breadcrumb')
@php
$breadcrumbData = [
[
'title' => 'Testimonial',
'link' => 'null',
],
[
'title' => 'Dashboard',
'link' => route('dashboard'),
],
[
'title' => 'Testimonials',
'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 Testimonial</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.testimonials.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 table-hover table border-top">
<thead class="table-light">
<tr>
<th>S.N</th>
<th>Name With Image</th>
<th>Ordering</th>
<th>Created At</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody class="table-border-bottom-0">
@if(count($testimonials) > 0)
@foreach ($testimonials ?? [] as $testimonial)
<tr>
<td>
#{{ $loop->iteration }}
</td>
<td>
<div class="d-flex align-items-center me-3">
<img src="{{ asset($testimonial->fullImage ?? 'backend/uploads/images/no-Image.jpg') }}"
alt="Image" class="rounded me-3" height="40" width="60" style="object-fit: cover">
<div class="card-title mb-0 px-3">
<h6 class="mb-0">{{ $testimonial->name }}</h6>
<small class="text-muted">{{ Str::limit($testimonial->designation , 50) }}</small>
</div>
</div>
</td>
<td>
{{ $testimonial->ordering }}
</td>
<td>
{{ $testimonial->created_at->toFormattedDateString() }}
</td>
<td>
<span <span
class="badge bg-label-{{ $testimonial->status == 'active' ? 'success' : 'danger' }}">
{{ $testimonial->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.testimonials.edit', ['uuid' => $testimonial->uuid]) }}"><i
class="bx bx-edit-alt me-1"></i>
Edit</a>
<form method="POST"
action="{{ route('cms.testimonials.delete', ['uuid' => $testimonial->uuid]) }}"
id="deleteForm_{{ $testimonial->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="8">No record found.</td>
</tr>
@endif
</tbody>
</table>
</div>
<div class="px-3">
{{ $testimonials->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

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>Testimonial 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-testimonial', 'resources/assets/sass/app.scss') }} --}}
</head>
<body>
@yield('content')
{{-- Vite JS --}}
{{-- {{ module_vite('build-testimonial', 'resources/assets/js/app.js') }} --}}
</body>

View File

@@ -0,0 +1,107 @@
<div>
<div class="row">
<div class="card-body">
<div class="d-flex align-items-start align-items-sm-center gap-4">
<img src="{{ asset(!empty($testimonial->image_path) ? 'storage/uploads/' . $testimonial->image_path : 'backend/uploads/images/no-Image.jpg') }}"
alt="testimonial-image input-file" class="d-block rounded show-image" height="100" width="100" />
<div class="button-wrapper">
<label for="upload" class="btn btn-primary me-2 mb-4" tabindex="0">
<span class="d-none d-sm-block">Upload</span>
<i class="bx bx-upload d-block d-sm-none"></i>
<input type="file" id="upload" class="input-file" name="image" hidden
accept="image/png, image/jpeg" />
</label>
<button type="button" class="btn btn-label-secondary image-reset mb-4">
<i class="bx bx-reset d-block d-sm-none"></i>
<span class="d-none d-sm-block">Reset</span>
</button>
<p class="mb-0">Allowed JPG, GIF or PNG. Max size of 3Mb</p>
</div>
</div>
</div>
<hr class="my-0" />
</div>
<div class="mb-3">
<label class="form-label" for="basic-default-name">Name</label>
<input type="text" class="form-control" name="name" value="{{ old('name', $testimonial->name ?? '') }}"
placeholder="e.g. John Doe" required />
@error('name')
<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">Designation</label>
<input type="text" class="form-control" name="designation"
value="{{ old('designation', $testimonial->designation ?? '') }}"
placeholder="e.g. Chief Executive Officer" required />
@error('designation')
<div class="text-danger">{{ $message }}</div>
@enderror
</div>
<div class="mb-3 col-md-6">
<label class="form-label" for="basic-default-company">Ordering</label>
<input type="number" class="form-control" name="ordering"
value="{{ old('ordering', $testimonial->ordering ?? '') }}" placeholder="e.g. 15" required />
@error('ordering')
<div class="text-danger">{{ $message }}</div>
@enderror
</div>
</div>
<div class="mb-3">
<label class="form-label" for="basic-default-message">Statement</label>
<textarea name="" id="mainTextarea" class="d-none"> {{ !empty($testimonial) ? $testimonial->statement : '' }}</textarea>
<textarea name="statement" class="form-control full-editor" id="editorTextarea" rows='5'
placeholder="Our stay at Jhigu CMS was nothing short of amazing. The staff's hospitality and the luxurious amenities made our vacation unforgettable. We can't wait to return!">
</textarea>
@error('statement')
<div class="text-danger">{{ $message }}</div>
@enderror
</div>
<div class="mb-3 col-md-12">
<label for="exampleFormControlTextarea1" class="form-label">Link</label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" name="link"
placeholder="e.g:video link">{{ !empty($testimonial) ? $testimonial->link : '' }}</textarea>
@error('link')
<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"{{ ($testimonial->status ?? '') == 'active' ? 'selected' : '' }}>Active</option>
<option value="inactive"{{ ($testimonial->status ?? '') == 'inactive' ? 'selected' : '' }}>Inactive
</option>
</select>
@error('status')
<div class="text-danger">{{ $message }}</div>
@enderror
</div>
<div>
<button type="submit" class="btn btn-primary">
{{ empty($testimonial) ? 'Save Testimonial' : 'Update Testimonial' }}
</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

View File

View 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('testimonial', fn (Request $request) => $request->user())->name('testimonial');
});

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Testimonial\app\Http\Controllers\TestimonialController;
/*
|--------------------------------------------------------------------------
| 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' => 'testimonials.',
'controller' => 'TestimonialController',
],
function () {
Route::get('testimonials', 'index')->name('index');
Route::get('testimonials/create', 'create')->name('create');
Route::post('testimonials/store', 'store')->name('store');
Route::get('testimonials/{uuid}/edit', 'edit')->name('edit');
Route::put('testimonials/{uuid}/update', 'update')->name('update');
Route::delete('testimonials/{uuid}/delete', 'destroy')->name('delete');
}
);
}
);

View File

View File

@@ -0,0 +1,26 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
build: {
outDir: '../../public/build-testimonial',
emptyOutDir: true,
manifest: true,
},
plugins: [
laravel({
publicDirectory: '../../public',
buildDirectory: 'build-testimonial',
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',
//];