firstcommit
This commit is contained in:
0
Modules/TeamMember/app/Http/Controllers/.gitkeep
Normal file
0
Modules/TeamMember/app/Http/Controllers/.gitkeep
Normal file
137
Modules/TeamMember/app/Http/Controllers/TeamMemberController.php
Normal file
137
Modules/TeamMember/app/Http/Controllers/TeamMemberController.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\app\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Modules\TeamMember\app\Models\TeamMember;
|
||||
use Modules\TeamMember\app\Models\SocialShare;
|
||||
use Modules\TeamMember\app\Services\FileManagementService;
|
||||
use Modules\TeamMember\app\Repositories\TeamMemberRepository;
|
||||
use Modules\TeamMember\app\Http\Requests\CreateTeamMemberRequest;
|
||||
use Modules\TeamMember\app\Http\Requests\CreateSocialShareRequest;
|
||||
|
||||
class TeamMemberController extends Controller
|
||||
{
|
||||
|
||||
protected $teamMemberRepository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->teamMemberRepository = new TeamMemberRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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') : [];
|
||||
$team_members = $this->teamMemberRepository->allTeamMember($perPage, $filter);
|
||||
return view('teammember::index', compact('team_members'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('teammember::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
public function store(CreateTeamMemberRequest $request): RedirectResponse
|
||||
{
|
||||
|
||||
try {
|
||||
$validated = $request->validated();
|
||||
|
||||
$this->teamMemberRepository->storeTeamMember($validated);
|
||||
|
||||
toastr()->success('Team Member created successfully.');
|
||||
|
||||
return redirect()->route('cms.team-members.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('teammember::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($uuid)
|
||||
{
|
||||
$team_member = $this->teamMemberRepository->findTeamMemberByUuid($uuid);
|
||||
if (!$team_member) {
|
||||
toastr()->error('Team Member not found.');
|
||||
return back();
|
||||
} return view('teammember::edit',compact('team_member'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(CreateTeamMemberRequest $request, $uuid): RedirectResponse
|
||||
{
|
||||
$validated = $request->validated();
|
||||
try {
|
||||
$team_member = $this->teamMemberRepository->updateTeamMember($validated, $uuid);
|
||||
|
||||
if (!$team_member) {
|
||||
toastr()->error('Team Member not found !');
|
||||
return back();
|
||||
}
|
||||
|
||||
toastr()->success('Team Member updated successfully.');
|
||||
|
||||
return redirect()->route('cms.team-members.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
try {
|
||||
$team_member = $this->teamMemberRepository->deleteTeamMember($uuid);
|
||||
|
||||
if (!$team_member) {
|
||||
toastr()->error('Team Member not found.');
|
||||
return back();
|
||||
}
|
||||
|
||||
toastr()->success('Team Member deleted successfully.');
|
||||
|
||||
return redirect()->route('cms.team-members.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
return back();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
0
Modules/TeamMember/app/Http/Middleware/.gitkeep
Normal file
0
Modules/TeamMember/app/Http/Middleware/.gitkeep
Normal file
0
Modules/TeamMember/app/Http/Requests/.gitkeep
Normal file
0
Modules/TeamMember/app/Http/Requests/.gitkeep
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\app\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateSocialShareRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|string|max:255',
|
||||
// 'link' => 'required|string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\app\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateTeamMemberRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255|regex:/^[a-zA-Z. ]+$/',
|
||||
'group_id' => 'required|integer|min:1',
|
||||
'designation' => 'required|string|max:255',
|
||||
'detail' => 'sometimes|nullable|string',
|
||||
// 'group-a' => 'array',
|
||||
'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.',
|
||||
'name.regex' => 'The name field only accepts letters, spaces, and dots.',
|
||||
|
||||
'group_id.required' => 'The group ID field is required.',
|
||||
'group_id.integer' => 'The group ID must be an integer.',
|
||||
'group_id.min' => 'The group ID must be at least 1.',
|
||||
|
||||
'designation.required' => 'The designation field is required.',
|
||||
'designation.string' => 'The designation field must be a string.',
|
||||
'designation.max' => 'The designation may not be greater than 255 characters.',
|
||||
|
||||
'detail.string' => 'The detail field must be a string.',
|
||||
|
||||
'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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\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.');
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/TeamMember/app/Models/.gitkeep
Normal file
0
Modules/TeamMember/app/Models/.gitkeep
Normal file
31
Modules/TeamMember/app/Models/SocialShare.php
Normal file
31
Modules/TeamMember/app/Models/SocialShare.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\app\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\TeamMember\Database\factories\SocialShareFactory;
|
||||
|
||||
class SocialShare extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
// 'uuid',
|
||||
// 'team_member_id',
|
||||
// 'name',
|
||||
// 'link',
|
||||
];
|
||||
|
||||
// public function teamMember(){
|
||||
// return $this->belongsTo(TeamMember::class, 'team_member_id');
|
||||
// }
|
||||
|
||||
protected static function newFactory(): SocialShareFactory
|
||||
{
|
||||
//return SocialShareFactory::new();
|
||||
}
|
||||
}
|
42
Modules/TeamMember/app/Models/TeamMember.php
Normal file
42
Modules/TeamMember/app/Models/TeamMember.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\app\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\TeamMember\Database\factories\TeamMemberFactory;
|
||||
|
||||
class TeamMember extends Model
|
||||
{
|
||||
const FILE_PATH = 'uploads/teamMembers/';
|
||||
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'name',
|
||||
'group_id',
|
||||
'designation',
|
||||
'detail',
|
||||
'image',
|
||||
'image_path',
|
||||
];
|
||||
|
||||
// public function socialShares()
|
||||
// {
|
||||
// return $this->hasMany(SocialShare::class, 'team_member_id');
|
||||
// }
|
||||
|
||||
protected static function newFactory(): TeamMemberFactory
|
||||
{
|
||||
//return TeamMemberFactory::new();
|
||||
}
|
||||
|
||||
public function getFullImageAttribute()
|
||||
{
|
||||
return $this->image ? asset('storage/' . Self::FILE_PATH . $this->image) : null;
|
||||
}
|
||||
}
|
0
Modules/TeamMember/app/Providers/.gitkeep
Normal file
0
Modules/TeamMember/app/Providers/.gitkeep
Normal file
59
Modules/TeamMember/app/Providers/RouteServiceProvider.php
Normal file
59
Modules/TeamMember/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\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\TeamMember\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('TeamMember', '/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('TeamMember', '/routes/api.php'));
|
||||
}
|
||||
}
|
114
Modules/TeamMember/app/Providers/TeamMemberServiceProvider.php
Normal file
114
Modules/TeamMember/app/Providers/TeamMemberServiceProvider.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\app\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class TeamMemberServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'TeamMember';
|
||||
|
||||
protected string $moduleNameLower = 'teammember';
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
144
Modules/TeamMember/app/Repositories/TeamMemberRepository.php
Normal file
144
Modules/TeamMember/app/Repositories/TeamMemberRepository.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\app\Repositories;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\TeamMember\app\Models\TeamMember;
|
||||
use Modules\TeamMember\app\Models\SocialShare;
|
||||
use Modules\Banner\app\Services\FileManagementService;
|
||||
|
||||
class TeamMemberRepository
|
||||
{
|
||||
|
||||
//-- Retrieve all Services
|
||||
public function allTeamMember($perPage = null, $filter = [], $sort = ['by' => 'id', 'sort' => 'DESC'])
|
||||
{
|
||||
return TeamMember::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 findTeamMemberByUuid($uuid)
|
||||
{
|
||||
return TeamMember::where('uuid', $uuid)->first();
|
||||
}
|
||||
|
||||
public function storeTeamMember(array $validated)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$teamMember = new TeamMember();
|
||||
$teamMember->uuid = Str::uuid();
|
||||
$teamMember->name = $validated['name'];
|
||||
if ($validated['group_id'] < 4 & $validated['group_id'] > 0) {
|
||||
$teamMember->group_id = $validated['group_id'];
|
||||
}
|
||||
$teamMember->designation = $validated['designation'];
|
||||
$teamMember->detail = $validated['detail'];
|
||||
$teamMember->save();
|
||||
|
||||
|
||||
// social media team member
|
||||
// if (isset($validated['group-a']) && is_array($validated['group-a'])) {
|
||||
// foreach ($validated['group-a'] as $socialShareData) {
|
||||
// $socialShare = new SocialShare([
|
||||
// 'uuid' => Str::uuid(),
|
||||
// 'name' => $socialShareData['name'],
|
||||
// 'link' => $socialShareData['link'],
|
||||
// ]);
|
||||
// $teamMember->socialShares()->save($socialShare);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (isset($validated['image']) && $validated['image']->isValid()) {
|
||||
FileManagementService::uploadFile(
|
||||
file: $validated['image'],
|
||||
uploadedFolderName: 'teamMembers',
|
||||
filePath: $teamMember->image_path,
|
||||
model: $teamMember
|
||||
);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $teamMember;
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
DB::rollback();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateTeamMember($validated, $uuid)
|
||||
{
|
||||
try {
|
||||
$teamMember = $this->findTeamMemberByUuid($uuid);
|
||||
if (!$teamMember) {
|
||||
|
||||
return null;
|
||||
}
|
||||
$teamMember->name = $validated['name'];
|
||||
if ($validated['group_id'] < 4 & $validated['group_id'] > 0) {
|
||||
$teamMember->group_id = $validated['group_id'];
|
||||
}
|
||||
$teamMember->designation = $validated['designation'];
|
||||
$teamMember->detail = $validated['detail'];
|
||||
$teamMember->save();
|
||||
|
||||
if (isset($validated['image']) && $validated['image']->isValid()) {
|
||||
FileManagementService::uploadFile(
|
||||
file: $validated['image'],
|
||||
uploadedFolderName: 'teamMembers',
|
||||
filePath: $teamMember->image_path,
|
||||
model: $teamMember
|
||||
);
|
||||
}
|
||||
|
||||
return $teamMember;
|
||||
DB::commit();
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
DB::rollBack();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//-- Delete Testimonial
|
||||
public function deleteTeamMember(string $uuid)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$teamMember = $this->findTeamMemberByUuid($uuid);
|
||||
if (!$teamMember) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Delete the image file associated with the activity
|
||||
if ($teamMember->image_path !== null) {
|
||||
FileManagementService::deleteFile($teamMember->image_path);
|
||||
}
|
||||
|
||||
$teamMember->delete();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $teamMember;
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
66
Modules/TeamMember/app/Services/FileManagementService.php
Normal file
66
Modules/TeamMember/app/Services/FileManagementService.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\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.');
|
||||
}
|
||||
}
|
||||
}
|
31
Modules/TeamMember/composer.json
Normal file
31
Modules/TeamMember/composer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "nwidart/teammember",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\TeamMember\\": "",
|
||||
"Modules\\TeamMember\\App\\": "app/",
|
||||
"Modules\\TeamMember\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\TeamMember\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\TeamMember\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/TeamMember/config/.gitkeep
Normal file
0
Modules/TeamMember/config/.gitkeep
Normal file
5
Modules/TeamMember/config/config.php
Normal file
5
Modules/TeamMember/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'TeamMember',
|
||||
];
|
0
Modules/TeamMember/database/factories/.gitkeep
Normal file
0
Modules/TeamMember/database/factories/.gitkeep
Normal file
0
Modules/TeamMember/database/migrations/.gitkeep
Normal file
0
Modules/TeamMember/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Schema::create('social_shares', function (Blueprint $table) {
|
||||
// $table->id();
|
||||
// $table->uuid();
|
||||
// $table->unsignedBigInteger('team_member_id');
|
||||
// $table->string('name');
|
||||
// $table->string('link');
|
||||
// $table->softDeletes();
|
||||
// $table->timestamps();
|
||||
|
||||
// $table->foreign('team_member_id')->references('id')->on('team_members');
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('social_shares');
|
||||
}
|
||||
};
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('team_members', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid();
|
||||
$table->string('name');
|
||||
$table->string('designation');
|
||||
$table->text('detail')->nullable();
|
||||
$table->string('image')->nullable();
|
||||
$table->string('image_path')->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('team_members');
|
||||
}
|
||||
};
|
@@ -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('team_members', function (Blueprint $table) {
|
||||
$table->unsignedSmallInteger('group_id')->after('name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('team_members', function (Blueprint $table) {
|
||||
$table->dropColumn('group_id');
|
||||
});
|
||||
}
|
||||
};
|
0
Modules/TeamMember/database/seeders/.gitkeep
Normal file
0
Modules/TeamMember/database/seeders/.gitkeep
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\TeamMember\database\seeders;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\TeamMember\app\Models\TeamMember;
|
||||
use Modules\TeamMember\app\Models\SocialShare;
|
||||
|
||||
class TeamMemberDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$teamMembers = [
|
||||
[
|
||||
'name' => 'Dr. Biken Shrestha',
|
||||
'group_id' => '1',
|
||||
'designation' => '(NMC-6766)',
|
||||
'detail' => 'Consultant Orthodontics and Dentofacial Orthopedics
|
||||
BDS, MDS, PhD',
|
||||
'image' => 't1.jpg'
|
||||
],
|
||||
[
|
||||
'name' => 'Dr. Sanjay Ranjit',
|
||||
'group_id' => '1',
|
||||
'designation' => '(NMC-13464)',
|
||||
'detail' => 'Consultant Dentistry and Endodontics
|
||||
MDS, AIIMS New Delhi',
|
||||
'image' => 't2.jpg'
|
||||
],
|
||||
[
|
||||
'name' => 'Dr. Padma Malla',
|
||||
'group_id' => '2',
|
||||
'designation' => '(NMC-7163)',
|
||||
'detail' => 'Senior Consultant Dermatologist and Venerologist, LASER /Aesthetic Specialist
|
||||
MBBS, MD',
|
||||
'image' => 't3.jpg'
|
||||
],
|
||||
[
|
||||
'name' => 'Dr. Deepak Gautam',
|
||||
'group_id' => '3',
|
||||
'designation' => '(NMC-8969)',
|
||||
'detail' => 'Consultant Joint Replacement and Orthopedics
|
||||
MBBS, MS Ortho, AIIMS , New Delhi',
|
||||
'image' => 't4.jpg'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($teamMembers as $teamMemberData) {
|
||||
$teamMember = TeamMember::create([
|
||||
'uuid' => Str::uuid(),
|
||||
'name' => $teamMemberData['name'],
|
||||
'group_id' => $teamMemberData['group_id'],
|
||||
'designation' => $teamMemberData['designation'],
|
||||
'detail' => $teamMemberData['detail']
|
||||
]);
|
||||
|
||||
// Add image to the created banner
|
||||
$this->uploadImageForBanner($teamMemberData['image'], $teamMember);
|
||||
}
|
||||
}
|
||||
|
||||
private function uploadImageForBanner(string $imageFileName, $cmsbanner)
|
||||
{
|
||||
$seederDirPath = 'teamMembers/';
|
||||
|
||||
// Generate a unique filename for the new image
|
||||
$newFileName = Str::uuid() . '.jpg';
|
||||
|
||||
// Storage path for the new image
|
||||
$storagePath = '/teamMembers/' . $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();
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/TeamMember/lang/.gitkeep
Normal file
0
Modules/TeamMember/lang/.gitkeep
Normal file
11
Modules/TeamMember/module.json
Normal file
11
Modules/TeamMember/module.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "TeamMember",
|
||||
"alias": "teammember",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\TeamMember\\app\\Providers\\TeamMemberServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/TeamMember/package.json
Normal file
15
Modules/TeamMember/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/TeamMember/resources/assets/.gitkeep
Normal file
0
Modules/TeamMember/resources/assets/.gitkeep
Normal file
0
Modules/TeamMember/resources/assets/js/app.js
Normal file
0
Modules/TeamMember/resources/assets/js/app.js
Normal file
0
Modules/TeamMember/resources/assets/sass/app.scss
Normal file
0
Modules/TeamMember/resources/assets/sass/app.scss
Normal file
0
Modules/TeamMember/resources/views/.gitkeep
Normal file
0
Modules/TeamMember/resources/views/.gitkeep
Normal file
45
Modules/TeamMember/resources/views/create.blade.php
Normal file
45
Modules/TeamMember/resources/views/create.blade.php
Normal file
@@ -0,0 +1,45 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Create Team Member
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'Team Member',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'Team Members',
|
||||
'link' => null,
|
||||
],
|
||||
[
|
||||
'title' => 'Add Team Member',
|
||||
'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 Team Member</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('cms.team-members.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('teammember::partial.form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
49
Modules/TeamMember/resources/views/edit.blade.php
Normal file
49
Modules/TeamMember/resources/views/edit.blade.php
Normal file
@@ -0,0 +1,49 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Update Team Member
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'Team Member',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'Team Members',
|
||||
'link' => null,
|
||||
],
|
||||
[
|
||||
'title' => 'Update Team Member',
|
||||
'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 Team Member</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('cms.team-members.update', ['uuid' => $team_member->uuid]) }}" method="POST"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
@include('teammember::partial.form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
133
Modules/TeamMember/resources/views/index.blade.php
Normal file
133
Modules/TeamMember/resources/views/index.blade.php
Normal file
@@ -0,0 +1,133 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Team Member
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'Team Member',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'Team Members',
|
||||
'link' => null,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<!-- Team Members List Table -->
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h4 class="card-header">List of Team Member</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.team-members.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>Name With Image</th>
|
||||
<th>Group</th>
|
||||
<th>Created At</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="table-border-bottom-0">
|
||||
@if (count($team_members) > 0)
|
||||
@foreach ($team_members ?? [] as $team_member)
|
||||
<tr>
|
||||
<td>
|
||||
#{{ $loop->iteration }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center me-3">
|
||||
<img src="{{ asset($team_member->image_path ? 'storage/uploads/' . $team_member->image_path : 'backend/uploads/images/no-Image.jpg') }}"
|
||||
alt="Image" class="rounded-circle" height="50" width="50"
|
||||
style="object-fit: cover">
|
||||
<div class="card-title mb-0 px-3">
|
||||
<h6 class="mb-0">{{ $team_member->name }}</h6>
|
||||
<small
|
||||
class="text-muted">{{ Str::limit($team_member->designation, 50) }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{{ $team_member->group_id }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $team_member->created_at->toFormattedDateString() }}
|
||||
</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.team-members.edit', ['uuid' => $team_member->uuid]) }}"><i
|
||||
class="bx bx-edit-alt me-1"></i>
|
||||
Edit</a>
|
||||
|
||||
<form method="POST"
|
||||
action="{{ route('cms.team-members.delete', ['uuid' => $team_member->uuid]) }}"
|
||||
id="deleteForm_{{ $team_member->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">
|
||||
{{ $team_members->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/TeamMember/resources/views/layouts/master.blade.php
Normal file
29
Modules/TeamMember/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>TeamMember 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-teammember', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-teammember', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
185
Modules/TeamMember/resources/views/partial/form.blade.php
Normal file
185
Modules/TeamMember/resources/views/partial/form.blade.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<div>
|
||||
<div class="row mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-start align-items-sm-center gap-4">
|
||||
<img src="{{ asset(!empty($team_member->image_path) ? 'storage/uploads/' . $team_member->image_path : 'backend/uploads/images/no-Image.jpg') }}"
|
||||
alt="team_member-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="row">
|
||||
<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', $team_member->name ?? '') }}" placeholder="e.g. Jhon Doe" required />
|
||||
@error('name')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="basic-default-name">Group</label>
|
||||
<select class="form-select select2" id="basic-default-compan select2Basic"
|
||||
aria-label="Default select example" name="group_id" required>
|
||||
<option value="1"{{ ($team_member->group_id ?? '') == '1' ? 'selected' : '' }}>Doctor</option>
|
||||
<option value="2"{{ ($team_member->group_id ?? '') == '2' ? 'selected' : '' }}>Pokhara Branch
|
||||
</option>
|
||||
<option value="3"{{ ($team_member->group_id ?? '') == '3' ? 'selected' : '' }}>Visiting Consultant
|
||||
</option>
|
||||
</select>
|
||||
@error('group_id')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="basic-default-company">Designation</label>
|
||||
<input type="text" class="form-control" name="designation"
|
||||
value="{{ old('designation', $team_member->designation ?? '') }}"
|
||||
placeholder="e.g. Chief Technology Officer" required />
|
||||
@error('designation')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="basic-default-message">Detail</label>
|
||||
<textarea name="" id="mainTextarea" class="d-none">{{ !empty($team_member) ? $team_member->detail : '' }}</textarea>
|
||||
<textarea name="detail" class="form-control full-editor" id="editorTextarea" rows='5'
|
||||
placeholder="Hi, I'm Jhon Doe, a passionate CTO at Jhigu CMS. With a focus on key technological infrastructure and framework, I thrive in dynamic environments, fostering collaboration and creative problem-solving. Experienced in designing system architecture for software as well as hardware level. I'm eager to contribute and make a positive impact for beterment of company and world."></textarea>
|
||||
@error('detail')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- Social media in Team Member --}}
|
||||
{{-- <div class="col-12">
|
||||
<div class="card mb-3">
|
||||
<h5 class="card-header">Social Media</h5>
|
||||
<div class="card-body">
|
||||
<div class="repeater">
|
||||
<div data-repeater-list="group-a">
|
||||
@if (isset($team_member->socialShares))
|
||||
@foreach ($team_member->socialShares ?? [] as $socialShare)
|
||||
@include('teammember::partial.social_form')
|
||||
@endforeach
|
||||
@else
|
||||
@include('teammember::partial.social_form')
|
||||
@endif
|
||||
|
||||
</div>
|
||||
<div class="mb-0">
|
||||
<button class="btn btn-primary" data-repeater-create>
|
||||
<i class="bx bx-plus me-1"></i>
|
||||
<span class="align-middle">Add</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
{{-- <div class="col-12">
|
||||
<div class="card mb-3">
|
||||
<h5 class="card-header">Social Media</h5>
|
||||
<div class="card-body">
|
||||
<div class="repeater">
|
||||
<div data-repeater-list="group-a">
|
||||
<div data-repeater-item>
|
||||
@if (isset($team_member->socialShares))
|
||||
|
||||
@foreach ($team_member->socialShares as $socialShare)
|
||||
<div class="row">
|
||||
<div class="mb-3 col-lg-6 col-xl-3 col-4 mb-0">
|
||||
<label class="form-label" for="form-repeater-1-1">Name</label>
|
||||
<input type="text" id="form-repeater-1-1" class="form-control"
|
||||
name="name" value="{{ old('name', $socialShare->name ?? '') }}"
|
||||
placeholder="facebook" />
|
||||
</div>
|
||||
<div class="mb-3 col-lg-6 col-xl-3 col-4 mb-0">
|
||||
<label class="form-label" for="form-repeater-1-2">Link</label>
|
||||
<input type="text" id="form-repeater-1-2" class="form-control"
|
||||
name="link" value="{{ old('name', $socialShare->link ?? '') }}"
|
||||
placeholder="https://facebook.com/jhon-doe" />
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-lg-12 col-xl-2 col-4 d-flex align-items-center mb-0">
|
||||
<button class="btn btn-label-danger mt-4" data-repeater-delete>
|
||||
<i class="bx bx-x me-1"></i>
|
||||
<span class="align-middle">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
@endforeach
|
||||
@else
|
||||
<div class="row">
|
||||
<div class="mb-3 col-lg-6 col-xl-3 col-4 mb-0">
|
||||
<label class="form-label" for="form-repeater-1-1">Name</label>
|
||||
<input type="text" id="form-repeater-1-1" class="form-control" name="name"
|
||||
value="{{ old('name', $socialShare->name ?? '') }}"
|
||||
placeholder="facebook" />
|
||||
</div>
|
||||
<div class="mb-3 col-lg-6 col-xl-3 col-4 mb-0">
|
||||
<label class="form-label" for="form-repeater-1-2">Link</label>
|
||||
<input type="text" id="form-repeater-1-2" class="form-control" name="link"
|
||||
value="{{ old('name', $socialShare->link ?? '') }}"
|
||||
placeholder="https://facebook.com/jhon-doe" />
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-lg-12 col-xl-2 col-4 d-flex align-items-center mb-0">
|
||||
<button class="btn btn-label-danger mt-4" data-repeater-delete>
|
||||
<i class="bx bx-x me-1"></i>
|
||||
<span class="align-middle">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-0">
|
||||
<button class="btn btn-primary" data-repeater-create>
|
||||
<i class="bx bx-plus me-1"></i>
|
||||
<span class="align-middle">Add</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
@if (empty($team_member))
|
||||
Save Team Member
|
||||
@else
|
||||
Update Team Member
|
||||
@endif
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@push('required-styles')
|
||||
@include('admin::vendor.full_editor.style')
|
||||
@endpush
|
||||
@push('required-scripts')
|
||||
@include('admin::vendor.textareaContentDisplay.script')
|
||||
@include('admin::vendor.full_editor.script')
|
||||
@include('admin::vendor.repeater.script')
|
||||
@endpush
|
@@ -0,0 +1,20 @@
|
||||
<div data-repeater-item>
|
||||
<div class="row">
|
||||
<div class="mb-3 col-lg-6 col-xl-3 col-4 mb-0">
|
||||
<label class="form-label" for="form-repeater-1-1">Name</label>
|
||||
<input type="text" id="form-repeater-1-1" class="form-control" name="group-a[0][name]" value="{{ old('name', $socialShare->name ?? '') }}" placeholder="facebook" />
|
||||
</div>
|
||||
<div class="mb-3 col-lg-6 col-xl-3 col-4 mb-0">
|
||||
<label class="form-label" for="form-repeater-1-2">Link</label>
|
||||
<input type="text" id="form-repeater-1-2" class="form-control" name="group-a[0][link]" value="{{ old('name', $socialShare->link ?? '') }}" placeholder="https://facebook.com/jhon-doe" />
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-lg-12 col-xl-2 col-4 d-flex align-items-center mb-0">
|
||||
<button class="btn btn-label-danger mt-4" data-repeater-delete>
|
||||
<i class="bx bx-x me-1"></i>
|
||||
<span class="align-middle">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
</div>
|
0
Modules/TeamMember/routes/.gitkeep
Normal file
0
Modules/TeamMember/routes/.gitkeep
Normal file
19
Modules/TeamMember/routes/api.php
Normal file
19
Modules/TeamMember/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('teammember', fn (Request $request) => $request->user())->name('teammember');
|
||||
});
|
40
Modules/TeamMember/routes/web.php
Normal file
40
Modules/TeamMember/routes/web.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\TeamMember\app\Http\Controllers\TeamMemberController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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' => 'team-members.',
|
||||
'controller' => 'TeamMemberController',
|
||||
],
|
||||
function () {
|
||||
Route::get('team-members', 'index')->name('index');
|
||||
Route::get('team-members/create', 'create')->name('create');
|
||||
Route::post('team-members/store', 'store')->name('store');
|
||||
Route::get('team-members/{uuid}/edit', 'edit')->name('edit');
|
||||
Route::put('team-members/{uuid}/update', 'update')->name('update');
|
||||
Route::delete('team-members/{uuid}/delete', 'destroy')->name('delete');
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
0
Modules/TeamMember/tests/Feature/.gitkeep
Normal file
0
Modules/TeamMember/tests/Feature/.gitkeep
Normal file
0
Modules/TeamMember/tests/Unit/.gitkeep
Normal file
0
Modules/TeamMember/tests/Unit/.gitkeep
Normal file
26
Modules/TeamMember/vite.config.js
Normal file
26
Modules/TeamMember/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-teammember',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-teammember',
|
||||
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