Skip to content

Commit

Permalink
Develop contact us model
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilan032 committed May 23, 2024
1 parent 1d3ae0d commit c392cf0
Show file tree
Hide file tree
Showing 34 changed files with 143 additions and 92 deletions.
27 changes: 12 additions & 15 deletions app/Http/Controllers/UserMassageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,12 @@ class UserMassageController extends Controller
*/
public function index()
{
//
}

// for admin showBlogs
public function showMasage(){
$user_massages = userMassage::orderBy('created_at','DESC')->get();
return view('admin.massage', compact('user_massages')); // Pass data to the view

return view('user.contactUs');
}

//for user page contacUs
public function contactUsShow(){
return view('user.contactUs');
// return view('user.contactUs');

}

Expand All @@ -47,7 +40,7 @@ public function store(Request $request)
'user_name' => 'required|string',
'email' => 'required|email',
'subject' => 'required|string',
'description' => 'nullable|string',
'discription' => 'nullable|string',
];

$validator = Validator::make($request->all(), $rules);
Expand All @@ -64,11 +57,11 @@ public function store(Request $request)
$user_massages->user_name = $request->user_name;
$user_massages->email = $request->email;
$user_massages->subject = $request->subject;
$user_massages->description = $request->description;
$user_massages->discription = $request->discription;
$user_massages->save();

// Process the validated data, such as saving it to the database
return redirect()->route('contactUs')->with('success', 'Massage Send successfully');
return redirect()->route('contactUs')->with('success', 'Massage successfully Send');

}
}
Expand All @@ -78,7 +71,8 @@ public function store(Request $request)
*/
public function show(userMassage $userMassage)
{
//
$user_massages = userMassage::orderBy('created_at','DESC')->get();
return view('admin.masage', compact('user_massages')); // Pass data to the view
}

/**
Expand All @@ -100,8 +94,11 @@ public function update(Request $request, userMassage $userMassage)
/**
* Remove the specified resource from storage.
*/
public function destroy(userMassage $userMassage)
public function destroy($id)
{
//
$userMassage = userMassage::findOrFail($id);
$userMassage->delete();

return redirect()->route('admin.massage')->with('success', 'Massage Delete');
}
}
19 changes: 19 additions & 0 deletions public/css/user_css/contactUs.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,22 @@
ul{
list-style-type: none;
}

/* for aleart massage */
.message-overlay{
position: relative;
z-index: 1;

}

/* for admin css */
.massage-box{
background-color: rgb(255, 255, 255);
border-radius: 6px;
border-style: outset;
border-bottom-width: 2px;
width: 900px;
padding-bottom: 80px;
padding-top: 5px;
}

Binary file removed public/image/uploads/blog/1716070975.jpg
Binary file not shown.
Binary file removed public/image/uploads/blog/1716198609.jpeg
Binary file not shown.
File renamed without changes.
9 changes: 0 additions & 9 deletions public/image/uploads/travelPackage/1716169588.svg

This file was deleted.

9 changes: 0 additions & 9 deletions public/image/uploads/travelPackage/1716182903.svg

This file was deleted.

9 changes: 0 additions & 9 deletions public/image/uploads/travelPackage/1716182954.svg

This file was deleted.

Binary file removed public/image/uploads/travelPackage/1716183156.jpeg
Binary file not shown.
Binary file removed public/image/uploads/travelPackage/1716186599.jpeg
Binary file not shown.
Binary file removed public/image/uploads/travelPackage/1716202606.jpeg
Binary file not shown.
Binary file removed public/image/uploads/travelPackage/1716202607.jpeg
Binary file not shown.
9 changes: 0 additions & 9 deletions public/image/uploads/travelPackage/1716217881.svg

This file was deleted.

9 changes: 0 additions & 9 deletions public/image/uploads/travelPackage/1716217882.svg

This file was deleted.

Binary file removed public/image/uploads/travelPackage/1716348777.jpeg
Binary file not shown.
Binary file removed public/image/uploads/travelPackage/1716350239.jpeg
Binary file not shown.
Binary file removed public/image/uploads/travelPackage/1716435206.webp
Binary file not shown.
Binary file removed public/image/uploads/travelPackage/1716438513.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
88 changes: 82 additions & 6 deletions resources/views/admin/masage.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,89 @@

@section('admincontent')
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h2 class="fw-light">Masages</h2>
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-5 border-bottom">
<h2 class="fw-light">Messages</h2>
</div>
<div class="container">
<!-- Your dashboard content goes here -->

{{-- To display validation errors or success messages --}}
@if ($errors->any())
<div class="alert alert-danger">
<ul class="fw-medium">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
<li class="fw-light">try again</li>
</ul>
</div>
@endif

@if (session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@endif

<table class="table">
<thead>
<tr class="table-dark">
<th scope="col">No</th>
<th scope="col" style="text-align: center; width: 100%;">Subject</th>
<th scope="col" style="text-align: right;">Action</th>
</tr>
</thead>
</table>

<div class="accordion accordion-flush" id="accordionFlushExample">
@if ($user_massages->isNotEmpty())
@foreach ($user_massages as $key => $massage)
<div class="accordion-item">
<h2 class="accordion-header" id="flush-heading{{ $key }}">
<button class="accordion-button collapsed d-flex justify-content-between align-items-center" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapse{{ $key }}" aria-expanded="false" aria-controls="flush-collapse{{ $key }}">
<div class="fs-6 fw-medium w-100 d-flex justify-content-between">
<span><b>{{ $massage->id }}.</b></span>
<span class="mx-auto">{{ $massage->subject }}</span>
</div>
</button>
</h2>
<div id="flush-collapse{{ $key }}" class="accordion-collapse collapse" aria-labelledby="flush-heading{{ $key }}" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">
<ul>
<li class="fw-medium">{{ $massage->user_name }}</li>
<li class="fw-light">{{ $massage->email }}</li>
<li class="fw-medium"><pre>{{ \Carbon\Carbon::parse($massage->created_at)->format('d M,Y | h:i A') }}</pre></li>
<li class="fw-medium">Massage : </li>
<div class="massage-box mt-1 p-4">
<li><q>{{ $massage->discription }}</q></li>
</div>
<li class="mt-4">
<a href="mailto:{{$massage->email}}" type="button" class="btn btn-success btn-sm">Send Email</a>
{{-- button for delete the blog post --}}
<a href="#" onclick="deleteUserMassage({{ $massage->id}});" class="btn btn-danger btn-sm">Delete</a>
<form id="massage-id-{{ $massage->id }}" action="{{route('admin.massage.delete', $massage->id)}}" method="post">
@csrf
@method('delete')
</form>
</li>
</ul>

</div>
<br>
</div>
</div> <br>
@endforeach
@endif
</div>
</div>
</main>


@endsection
{{-- script for delete blog post cofomation alert --}}
<script>
function deleteUserMassage(id){
if(confirm("Do you want to this massage ?")){
document.getElementById('massage-id-' + id).submit();
}
}
</script>

</main>
@endsection
44 changes: 24 additions & 20 deletions resources/views/user/contactUs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@
@section('content')


{{-- To display validation errors or success messages --}}
@if ($errors->any())
<div class="alert alert-danger">
<ul class="fw-medium">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
<li class="fw-light">try again</li>
</ul>
</div>
@endif

@if (session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@endif

{{-- map --}}
<div class="ms-2 map-position" style="margin-top: -25px;">
Expand All @@ -33,8 +16,29 @@
{{-- Email contact form --}}
<div class="d-flex justify-content-end pe-5" style="margin-right: 60px">
<div class="contac-form p-3">
<form action="#" method="post">
<form action="{{route('user.contactUs.store')}}" method="post">
@csrf

<div class="message-overlay">
{{-- To display validation errors or success messages --}}
@if ($errors->any())
<div class="alert alert-danger">
<ul class="fw-medium">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
<li class="fw-light">try again</li>
</ul>
</div>
@endif

@if (session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@endif
</div>

<div class="form-floating mb-3">
<input type="text" name="user_name" class="form-control" id="floatingInput" placeholder="Full Name">
<label for="floatingInput">Full Name</label>
Expand All @@ -48,7 +52,7 @@
<label for="floatingInput">Subject</label>
</div>
<div class="form-floating">
<textarea class="form-control" name="description" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 200px"></textarea>
<textarea class="form-control" name="discription" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 200px"></textarea>
<label for="floatingTextarea2">Your Massage</label>
</div>

Expand All @@ -62,7 +66,7 @@


{{-- details section --}}
<div class="mb-5" style="margin-top: 95px;">
<div style="margin-top: 95px; margin-bottom: 100px;">
{{-- <h2 class="mt-5">Contac Us</h2> --}}
<div class="d-flex justify-content-start gap-5">
<ul>
Expand Down
12 changes: 6 additions & 6 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
Route::get('/profile/Edit', [ProfileController::class, 'edit'])->name('profile.edit');
Route::get('/profile/Edit/password', [ProfileController::class, 'editPassword'])->name('profile.profileChangePassword');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('/profile/{}', [ProfileController::class, 'destroy'])->name('profile.destroy');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

require __DIR__.'/auth.php';
Expand Down Expand Up @@ -86,10 +86,10 @@
Route::delete('/package/page{TravelPackage}', [TravelPackageController::class, 'destroy'])->name('admin.deleteTravelPackage');


//for admin massage
Route::get('/admin/massage', [UserMassageController::class, 'showMasage'])->name('admin.massage');

//for user massage
// Route::view('/contactUs', 'user/contactUs')->name('contactUs');
Route::get('/contactUs', [UserMassageController::class, 'contactUsShow'])->name('contactUs');
Route::post('/contactUs', [UserMassageController::class, 'store'])->name('user.massage.store');
Route::get('/contactUs', [UserMassageController::class, 'index'])->name('contactUs');
Route::post('/contactUs', [UserMassageController::class, 'store'])->name('user.contactUs.store');
//for admin massage
Route::get('/admin/massage', [UserMassageController::class, 'show'])->name('admin.massage');
Route::delete('/admin/massage/{userMassage}', [UserMassageController::class, 'destroy'])->name('admin.massage.delete');

0 comments on commit c392cf0

Please sign in to comment.