completed event crud

Cette révision appartient à :
Ibrahim Khalil Shakil 2024-01-06 00:09:03 +06:00
Parent dcb147f347
révision 51934f73c1
7 fichiers modifiés avec 133 ajouts et 85 suppressions

Voir le fichier

@ -26,7 +26,7 @@ public function index()
'topic' => $e->topic, 'topic' => $e->topic,
'goal' => $e->goal, 'goal' => $e->goal,
'hosted_by' => $e->hosted_by, 'hosted_by' => $e->hosted_by,
'date' => date("F j, l, Y", strtotime($e->date)), 'date' => date("j F, Y, l", strtotime($e->date)),
); );
} }
} }
@ -46,7 +46,7 @@ public function single($id)
'topic' => $event->topic, 'topic' => $event->topic,
'goal' => $event->goal, 'goal' => $event->goal,
'hosted_by' => $event->hosted_by, 'hosted_by' => $event->hosted_by,
'date' => date("F j, l, Y", strtotime($event->date)), 'date' => date("j F, Y, l", strtotime($event->date)),
); );
} }
return response($data, 200); return response($data, 200);

Voir le fichier

@ -71,9 +71,8 @@ public function show(Event $event)
*/ */
public function edit($id) public function edit($id)
{ {
$course = Course::get(); $event = Event::findOrFail($id);
$event = Event::findOrFail(encryptor('decrypt', $id)); return view('backend.event.edit', compact('event'));
return view('backend.event.edit', compact('course', 'event'));
} }
/** /**
@ -82,12 +81,19 @@ public function edit($id)
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
try { try {
$event = Event::findOrFail(encryptor('decrypt', $id)); $event = Event::findOrFail($id);
$event->title = $request->lessonTitle; $event->title = $request->title;
$event->course_id = $request->courseId; $event->description = $request->description;
$event->description = $request->lessonDescription; $event->location = $request->location;
$event->notes = $request->lessonNotes; $event->topic = $request->topic;
$event->goal = $request->goal;
$event->hosted_by = $request->hosted_by;
$event->date = $request->date;
if ($request->hasFile('image')) {
$imageName = rand(999, 111) . time() . '.' . $request->image->extension();
$request->image->move(public_path('uploads/events'), $imageName);
$event->image = $imageName;
}
if ($event->save()) { if ($event->save()) {
$this->notice::success('Data Saved'); $this->notice::success('Data Saved');
return redirect()->route('event.index'); return redirect()->route('event.index');
@ -96,7 +102,7 @@ public function update(Request $request, $id)
return redirect()->back()->withInput(); return redirect()->back()->withInput();
} }
} catch (Exception $e) { } catch (Exception $e) {
// dd($e); dd($e);
$this->notice::error('Please try again'); $this->notice::error('Please try again');
return redirect()->back()->withInput(); return redirect()->back()->withInput();
} }
@ -107,7 +113,7 @@ public function update(Request $request, $id)
*/ */
public function destroy($id) public function destroy($id)
{ {
$data = Event::findOrFail(encryptor('decrypt', $id)); $data = Event::findOrFail($id);
if ($data->delete()) { if ($data->delete()) {
$this->notice::error('Data Deleted!'); $this->notice::error('Data Deleted!');
return redirect()->back(); return redirect()->back();

Voir le fichier

@ -8,4 +8,5 @@
class Event extends Model class Event extends Model
{ {
use HasFactory; use HasFactory;
} }

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 92 KiB

Voir le fichier

@ -45,26 +45,17 @@
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group"> <div class="form-group">
<label class="form-label">Event Title</label> <label class="form-label">Event Title</label>
<input type="text" class="form-control" name="title" <input type="text" class="form-control" name="title" value="{{old('title')}}">
value="{{old('title')}}">
</div> </div>
@if($errors->has('title')) @if($errors->has('title'))
<span class="text-danger"> {{$errors->first('title')}}</span> <span class="text-danger"> {{$errors->first('title')}}</span>
@endif @endif
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Description</label>
<textarea name="description" id="" cols="30" rows="10" class="form-control">{{old('description')}}</textarea>
</div>
@if($errors->has('description'))
<span class="text-danger"> {{$errors->first('description')}}</span>
@endif
</div>
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group"> <div class="form-group">
<label class="form-label">Location Type</label> <label class="form-label">Location Type</label>
<input type="text" class="form-control" name="location" value="{{old('location')}}"> <input type="text" class="form-control" name="location"
value="{{old('location')}}">
</div> </div>
@if($errors->has('location')) @if($errors->has('location'))
<span class="text-danger"> {{$errors->first('location')}}</span> <span class="text-danger"> {{$errors->first('location')}}</span>
@ -79,15 +70,6 @@
<span class="text-danger"> {{$errors->first('topic')}}</span> <span class="text-danger"> {{$errors->first('topic')}}</span>
@endif @endif
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Event Goal</label>
<textarea name="goal" id="" cols="30" rows="10" class="form-control">{{old('goal')}}</textarea>
</div>
@if($errors->has('goal'))
<span class="text-danger"> {{$errors->first('goal')}}</span>
@endif
</div>
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group"> <div class="form-group">
<label class="form-label">Hosted By</label> <label class="form-label">Hosted By</label>
@ -97,16 +79,39 @@
<span class="text-danger"> {{$errors->first('hosted_by')}}</span> <span class="text-danger"> {{$errors->first('hosted_by')}}</span>
@endif @endif
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Description</label>
<textarea name="description" class="form-control">{{old('description')}}</textarea>
</div>
@if($errors->has('description'))
<span class="text-danger"> {{$errors->first('description')}}</span>
@endif
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Event Goal</label>
<textarea name="goal" class="form-control">{{old('goal')}}</textarea>
</div>
@if($errors->has('goal'))
<span class="text-danger"> {{$errors->first('goal')}}</span>
@endif
</div>
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group"> <div class="form-group">
<label class="form-label">Date</label> <label class="form-label">Date</label>
<input type="date" class="form-control" name="date" <input type="date" class="form-control" name="date" value="{{old('date')}}">
value="{{old('date')}}">
</div> </div>
@if($errors->has('date')) @if($errors->has('date'))
<span class="text-danger"> {{$errors->first('date')}}</span> <span class="text-danger"> {{$errors->first('date')}}</span>
@endif @endif
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Image</label>
<input type="file" class="form-control" name="image">
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-lg-12 col-md-12 col-sm-12">
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-light">Cancel</button> <button type="submit" class="btn btn-light">Cancel</button>

Voir le fichier

@ -1,5 +1,5 @@
@extends('backend.layouts.app') @extends('backend.layouts.app')
@section('title', 'Edit Coupon') @section('title', 'Edit Event')
@push('styles') @push('styles')
<!-- Pick date --> <!-- Pick date -->
@ -19,14 +19,14 @@
<div class="row page-titles mx-0"> <div class="row page-titles mx-0">
<div class="col-sm-6 p-md-0"> <div class="col-sm-6 p-md-0">
<div class="welcome-text"> <div class="welcome-text">
<h4>Edit Coupon</h4> <h4>Edit Event</h4>
</div> </div>
</div> </div>
<div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex"> <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{route('dashboard')}}">Home</a></li> <li class="breadcrumb-item"><a href="{{route('dashboard')}}">Home</a></li>
<li class="breadcrumb-item active"><a href="{{route('coupon.index')}}">Coupons</a></li> <li class="breadcrumb-item active"><a href="{{route('event.index')}}">Events</a></li>
<li class="breadcrumb-item active"><a href="javascript:void(0);">Edit Coupon</a></li> <li class="breadcrumb-item active"><a href="javascript:void(0);">Edit Event</a></li>
</ol> </ol>
</div> </div>
</div> </div>
@ -35,54 +35,90 @@
<div class="col-xl-12 col-xxl-12 col-sm-12"> <div class="col-xl-12 col-xxl-12 col-sm-12">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h5 class="card-title">Coupon Info</h5> <h5 class="card-title">Event Info</h5>
</div> </div>
<div class="card-body"> <div class="card-body">
<form action="{{ route('coupon.update', $coupon->id) }}" method="post" <form action="{{ route('event.update', $event->id) }}" method="post"
enctype="multipart/form-data"> enctype="multipart/form-data">
@csrf @csrf
@method('PATCH') @method('PATCH')
<div class="row"> <div class="row">
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group"> <div class="form-group">
<label class="form-label">Coupon Code</label> <label class="form-label">Event Title</label>
<input type="text" class="form-control" name="code" <input type="text" class="form-control" name="title"
value="{{old('code', $coupon->code)}}"> value="{{old('title', $event->title)}}">
</div> </div>
@if($errors->has('code')) @if($errors->has('title'))
<span class="text-danger"> {{ $errors->first('code') }}</span> <span class="text-danger"> {{$errors->first('title')}}</span>
@endif @endif
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group"> <div class="form-group">
<label class="form-label">Discount</label> <label class="form-label">Location Type</label>
<input type="text" class="form-control" name="discount" <input type="text" class="form-control" name="location"
value="{{old('discount', $coupon->discount)}}"> value="{{old('location', $event->location)}}">
</div> </div>
@if($errors->has('discount')) @if($errors->has('location'))
<span class="text-danger"> {{ $errors->first('discount') }}</span> <span class="text-danger"> {{$errors->first('location')}}</span>
@endif @endif
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group"> <div class="form-group">
<label class="form-label">Valid From</label> <label class="form-label">Topic</label>
<input type="text" class="form-control" name="valid_from" <input type="text" class="form-control" name="topic"
value="{{old('valid_from', $coupon->valid_from)}}"> value="{{old('topic', $event->topic)}}">
</div> </div>
@if($errors->has('valid_from')) @if($errors->has('topic'))
<span class="text-danger"> {{ $errors->first('valid_from') }}</span> <span class="text-danger"> {{$errors->first('topic')}}</span>
@endif @endif
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group"> <div class="form-group">
<label class="form-label">Valid Until</label> <label class="form-label">Hosted By</label>
<input type="text" class="form-control" name="valid_until" <input type="text" class="form-control" name="hosted_by"
value="{{old('valid_until', $coupon->valid_until)}}"> value="{{old('hosted_by', $event->hosted_by)}}">
</div> </div>
@if($errors->has('valid_until')) @if($errors->has('hosted_by'))
<span class="text-danger"> {{ $errors->first('valid_until') }}</span> <span class="text-danger"> {{$errors->first('hosted_by')}}</span>
@endif @endif
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Description</label>
<textarea name="description"
class="form-control">{{old('description', $event->description)}}</textarea>
</div>
@if($errors->has('description'))
<span class="text-danger"> {{$errors->first('description')}}</span>
@endif
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Event Goal</label>
<textarea name="goal"
class="form-control">{{old('goal', $event->goal)}}</textarea>
@if($errors->has('goal'))
<span class="text-danger"> {{$errors->first('goal')}}</span>
@endif
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Date</label>
<input type="date" class="form-control" name="date"
value="{{old('date', $event->date)}}">
</div>
@if($errors->has('date'))
<span class="text-danger"> {{$errors->first('date')}}</span>
@endif
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Image</label>
<input type="file" class="form-control" name="image">
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-lg-12 col-md-12 col-sm-12">
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-light">Cancel</button> <button type="submit" class="btn btn-light">Cancel</button>

Voir le fichier

@ -1,5 +1,5 @@
@extends('backend.layouts.app') @extends('backend.layouts.app')
@section('title', 'Coupon List') @section('title', 'Event List')
@push('styles') @push('styles')
<!-- Datatable --> <!-- Datatable -->
@ -18,14 +18,14 @@
<div class="row page-titles mx-0"> <div class="row page-titles mx-0">
<div class="col-sm-6 p-md-0"> <div class="col-sm-6 p-md-0">
<div class="welcome-text"> <div class="welcome-text">
<h4>Coupon List</h4> <h4>Event List</h4>
</div> </div>
</div> </div>
<div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex"> <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{route('dashboard')}}">Home</a></li> <li class="breadcrumb-item"><a href="{{route('dashboard')}}">Home</a></li>
<li class="breadcrumb-item active"><a href="{{route('coupon.index')}}">Coupons</a></li> <li class="breadcrumb-item active"><a href="{{route('event.index')}}">Events</a></li>
<li class="breadcrumb-item active"><a href="{{route('coupon.index')}}">All Coupon</a></li> <li class="breadcrumb-item active"><a href="{{route('event.index')}}">All Event</a></li>
</ol> </ol>
</div> </div>
</div> </div>
@ -36,8 +36,8 @@
<div id="list-view" class="tab-pane fade active show col-lg-12"> <div id="list-view" class="tab-pane fade active show col-lg-12">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h4 class="card-title">All Coupons List </h4> <h4 class="card-title">All Events List </h4>
<a href="{{route('coupon.create')}}" class="btn btn-primary">+ Add new</a> <a href="{{route('event.create')}}" class="btn btn-primary">+ Add new</a>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="table-responsive"> <div class="table-responsive">
@ -45,31 +45,31 @@
<thead> <thead>
<tr> <tr>
<th>{{__('#')}}</th> <th>{{__('#')}}</th>
<th>{{__('Coupon Code')}}</th> <th>{{__('Event Title')}}</th>
<th>{{__('Discount')}}</th> <th>{{__('Topic')}}</th>
<th>{{__('Valid From')}}</th> <th>{{__('Location Type')}}</th>
<th>{{__('Valid Until')}}</th> <th>{{__('Date')}}</th>
<th>{{__('Action')}}</th> <th>{{__('Action')}}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@forelse ($coupon as $c) @forelse ($event as $e)
<tr> <tr>
<td>{{$c->id}}</td> <td><img src="{{asset('public/uploads/events/'.$e->image)}}"
<td><strong>{{$c->code}}</strong></td> class="w-100" height="50"></td>
<td><strong>{{$c->discount}}</strong></td> <td><strong>{{$e->title}}</strong></td>
<td>{{$c->valid_from}}</td> <td><strong>{{$e->topic}}</strong></td>
<td>{{$c->valid_until}}</td> <td>{{$e->location}}</td>
<td>{{ \Carbon\Carbon::parse($e->date)->format('j F, Y, l') }}</td>
<td> <td>
<a href="{{route('coupon.edit', $c->id)}}" <a href="{{route('event.edit', $e->id)}}"
class="btn btn-sm btn-primary" title="Edit"><i class="btn btn-sm btn-primary" title="Edit"><i
class="la la-pencil"></i></a> class="la la-pencil"></i></a>
<a href="javascript:void(0);" class="btn btn-sm btn-danger" <a href="javascript:void(0);" class="btn btn-sm btn-danger"
title="Delete" onclick="$('#form{{$c->id}}').submit()"><i title="Delete" onclick="$('#form{{$e->id}}').submit()"><i
class="la la-trash-o"></i></a> class="la la-trash-o"></i></a>
<form id="form{{$c->id}}" <form id="form{{$e->id}}"
action="{{route('coupon.destroy', $c->id)}}" action="{{route('event.destroy', $e->id)}}" method="post">
method="post">
@csrf @csrf
@method('DELETE') @method('DELETE')
</form> </form>
@ -77,7 +77,7 @@ class="la la-trash-o"></i></a>
</tr> </tr>
@empty @empty
<tr> <tr>
<th colspan="7" class="text-center">No Coupon Found</th> <th colspan="6" class="text-center">No Event Found</th>
</tr> </tr>
@endforelse @endforelse
</tbody> </tbody>