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,
'goal' => $e->goal,
'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,
'goal' => $event->goal,
'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);

Voir le fichier

@ -71,9 +71,8 @@ public function show(Event $event)
*/
public function edit($id)
{
$course = Course::get();
$event = Event::findOrFail(encryptor('decrypt', $id));
return view('backend.event.edit', compact('course', 'event'));
$event = Event::findOrFail($id);
return view('backend.event.edit', compact('event'));
}
/**
@ -82,12 +81,19 @@ public function edit($id)
public function update(Request $request, $id)
{
try {
$event = Event::findOrFail(encryptor('decrypt', $id));
$event->title = $request->lessonTitle;
$event->course_id = $request->courseId;
$event->description = $request->lessonDescription;
$event->notes = $request->lessonNotes;
$event = Event::findOrFail($id);
$event->title = $request->title;
$event->description = $request->description;
$event->location = $request->location;
$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()) {
$this->notice::success('Data Saved');
return redirect()->route('event.index');
@ -96,7 +102,7 @@ public function update(Request $request, $id)
return redirect()->back()->withInput();
}
} catch (Exception $e) {
// dd($e);
dd($e);
$this->notice::error('Please try again');
return redirect()->back()->withInput();
}
@ -107,7 +113,7 @@ public function update(Request $request, $id)
*/
public function destroy($id)
{
$data = Event::findOrFail(encryptor('decrypt', $id));
$data = Event::findOrFail($id);
if ($data->delete()) {
$this->notice::error('Data Deleted!');
return redirect()->back();

Voir le fichier

@ -8,4 +8,5 @@
class Event extends Model
{
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="form-group">
<label class="form-label">Event Title</label>
<input type="text" class="form-control" name="title"
value="{{old('title')}}">
<input type="text" class="form-control" name="title" value="{{old('title')}}">
</div>
@if($errors->has('title'))
<span class="text-danger"> {{$errors->first('title')}}</span>
@endif
</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="form-group">
<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>
@if($errors->has('location'))
<span class="text-danger"> {{$errors->first('location')}}</span>
@ -79,15 +70,6 @@
<span class="text-danger"> {{$errors->first('topic')}}</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" 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="form-group">
<label class="form-label">Hosted By</label>
@ -97,16 +79,39 @@
<span class="text-danger"> {{$errors->first('hosted_by')}}</span>
@endif
</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="form-group">
<label class="form-label">Date</label>
<input type="date" class="form-control" name="date"
value="{{old('date')}}">
<input type="date" class="form-control" name="date" value="{{old('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">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-light">Cancel</button>

Voir le fichier

@ -1,5 +1,5 @@
@extends('backend.layouts.app')
@section('title', 'Edit Coupon')
@section('title', 'Edit Event')
@push('styles')
<!-- Pick date -->
@ -19,14 +19,14 @@
<div class="row page-titles mx-0">
<div class="col-sm-6 p-md-0">
<div class="welcome-text">
<h4>Edit Coupon</h4>
<h4>Edit Event</h4>
</div>
</div>
<div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
<ol class="breadcrumb">
<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="javascript:void(0);">Edit Coupon</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 Event</a></li>
</ol>
</div>
</div>
@ -35,54 +35,90 @@
<div class="col-xl-12 col-xxl-12 col-sm-12">
<div class="card">
<div class="card-header">
<h5 class="card-title">Coupon Info</h5>
<h5 class="card-title">Event Info</h5>
</div>
<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">
@csrf
@method('PATCH')
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Coupon Code</label>
<input type="text" class="form-control" name="code"
value="{{old('code', $coupon->code)}}">
<label class="form-label">Event Title</label>
<input type="text" class="form-control" name="title"
value="{{old('title', $event->title)}}">
</div>
@if($errors->has('code'))
<span class="text-danger"> {{ $errors->first('code') }}</span>
@if($errors->has('title'))
<span class="text-danger"> {{$errors->first('title')}}</span>
@endif
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Discount</label>
<input type="text" class="form-control" name="discount"
value="{{old('discount', $coupon->discount)}}">
<label class="form-label">Location Type</label>
<input type="text" class="form-control" name="location"
value="{{old('location', $event->location)}}">
</div>
@if($errors->has('discount'))
<span class="text-danger"> {{ $errors->first('discount') }}</span>
@if($errors->has('location'))
<span class="text-danger"> {{$errors->first('location')}}</span>
@endif
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Valid From</label>
<input type="text" class="form-control" name="valid_from"
value="{{old('valid_from', $coupon->valid_from)}}">
<label class="form-label">Topic</label>
<input type="text" class="form-control" name="topic"
value="{{old('topic', $event->topic)}}">
</div>
@if($errors->has('valid_from'))
<span class="text-danger"> {{ $errors->first('valid_from') }}</span>
@if($errors->has('topic'))
<span class="text-danger"> {{$errors->first('topic')}}</span>
@endif
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="form-group">
<label class="form-label">Valid Until</label>
<input type="text" class="form-control" name="valid_until"
value="{{old('valid_until', $coupon->valid_until)}}">
<label class="form-label">Hosted By</label>
<input type="text" class="form-control" name="hosted_by"
value="{{old('hosted_by', $event->hosted_by)}}">
</div>
@if($errors->has('valid_until'))
<span class="text-danger"> {{ $errors->first('valid_until') }}</span>
@if($errors->has('hosted_by'))
<span class="text-danger"> {{$errors->first('hosted_by')}}</span>
@endif
</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">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-light">Cancel</button>

Voir le fichier

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