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,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();
}
}
}

View 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;
}
}

View File

@@ -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;
}
}

View 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.');
}
}
}