diff --git a/app/Http/Controllers/Api/EventController.php b/app/Http/Controllers/Api/EventController.php index ab4b5c0..f5a517a 100644 --- a/app/Http/Controllers/Api/EventController.php +++ b/app/Http/Controllers/Api/EventController.php @@ -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); diff --git a/app/Http/Controllers/EventController.php b/app/Http/Controllers/EventController.php index 8d6bd29..dd737b7 100644 --- a/app/Http/Controllers/EventController.php +++ b/app/Http/Controllers/EventController.php @@ -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(); diff --git a/app/Models/Event.php b/app/Models/Event.php index cbd6b41..a75059d 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model; class Event extends Model -{ +{ use HasFactory; + } diff --git a/public/uploads/events/3791704478042.jpg b/public/uploads/events/3791704478042.jpg new file mode 100644 index 0000000..916fc32 Binary files /dev/null and b/public/uploads/events/3791704478042.jpg differ diff --git a/resources/views/backend/event/create.blade.php b/resources/views/backend/event/create.blade.php index ef7f8ab..61dc4dc 100644 --- a/resources/views/backend/event/create.blade.php +++ b/resources/views/backend/event/create.blade.php @@ -45,26 +45,17 @@
- +
@if($errors->has('title')) {{$errors->first('title')}} @endif
-
-
- - -
- @if($errors->has('description')) - {{$errors->first('description')}} - @endif -
- +
@if($errors->has('location')) {{$errors->first('location')}} @@ -79,15 +70,6 @@ {{$errors->first('topic')}} @endif
-
-
- - -
- @if($errors->has('goal')) - {{$errors->first('goal')}} - @endif -
@@ -97,16 +79,39 @@ {{$errors->first('hosted_by')}} @endif
+
+
+ + +
+ @if($errors->has('description')) + {{$errors->first('description')}} + @endif +
+
+
+ + +
+ @if($errors->has('goal')) + {{$errors->first('goal')}} + @endif +
- +
@if($errors->has('date')) {{$errors->first('date')}} @endif
+
+
+ + +
+
diff --git a/resources/views/backend/event/edit.blade.php b/resources/views/backend/event/edit.blade.php index cd83e91..e1d9dd3 100644 --- a/resources/views/backend/event/edit.blade.php +++ b/resources/views/backend/event/edit.blade.php @@ -1,5 +1,5 @@ @extends('backend.layouts.app') -@section('title', 'Edit Coupon') +@section('title', 'Edit Event') @push('styles') @@ -19,14 +19,14 @@
-

Edit Coupon

+

Edit Event

@@ -35,54 +35,90 @@
-
Coupon Info
+
Event Info
-
@csrf @method('PATCH')
- - + +
- @if($errors->has('code')) - {{ $errors->first('code') }} + @if($errors->has('title')) + {{$errors->first('title')}} @endif
- - + +
- @if($errors->has('discount')) - {{ $errors->first('discount') }} + @if($errors->has('location')) + {{$errors->first('location')}} @endif
- - + +
- @if($errors->has('valid_from')) - {{ $errors->first('valid_from') }} + @if($errors->has('topic')) + {{$errors->first('topic')}} @endif
- - + +
- @if($errors->has('valid_until')) - {{ $errors->first('valid_until') }} + @if($errors->has('hosted_by')) + {{$errors->first('hosted_by')}} @endif
+
+
+ + +
+ @if($errors->has('description')) + {{$errors->first('description')}} + @endif +
+
+
+ + + @if($errors->has('goal')) + {{$errors->first('goal')}} + @endif +
+
+
+
+ + +
+ @if($errors->has('date')) + {{$errors->first('date')}} + @endif +
+
+
+ + +
+
diff --git a/resources/views/backend/event/index.blade.php b/resources/views/backend/event/index.blade.php index 4a13cd3..3a9cf7f 100644 --- a/resources/views/backend/event/index.blade.php +++ b/resources/views/backend/event/index.blade.php @@ -1,5 +1,5 @@ @extends('backend.layouts.app') -@section('title', 'Coupon List') +@section('title', 'Event List') @push('styles') @@ -18,14 +18,14 @@
-

Coupon List

+

Event List

@@ -36,8 +36,8 @@
-

All Coupons List

- + Add new +

All Events List

+ + Add new
@@ -45,31 +45,31 @@ {{__('#')}} - {{__('Coupon Code')}} - {{__('Discount')}} - {{__('Valid From')}} - {{__('Valid Until')}} + {{__('Event Title')}} + {{__('Topic')}} + {{__('Location Type')}} + {{__('Date')}} {{__('Action')}} - @forelse ($coupon as $c) + @forelse ($event as $e) - {{$c->id}} - {{$c->code}} - {{$c->discount}} - {{$c->valid_from}} - {{$c->valid_until}} + + {{$e->title}} + {{$e->topic}} + {{$e->location}} + {{ \Carbon\Carbon::parse($e->date)->format('j F, Y, l') }} - - + @csrf @method('DELETE') @@ -77,7 +77,7 @@ class="la la-trash-o"> @empty - No Coupon Found + No Event Found @endforelse