added event backend crud files

Cette révision appartient à :
Ibrahim Khalil Shakil 2024-01-05 21:37:33 +06:00
Parent 0ba5f6c309
révision b9b2a439b8
28 fichiers modifiés avec 483 ajouts et 2 suppressions

Voir le fichier

@ -21,7 +21,7 @@ public function index()
'id' => $e->id,
'title' => $e->title,
'description' => $e->description,
'image' => asset('public/uploads/event/' . $e->image),
'image' => asset('public/uploads/events/' . $e->image),
'location' => $e->location,
'topic' => $e->topic,
'goal' => $e->goal,
@ -41,7 +41,7 @@ public function single($id)
'id' => $event->id,
'title' => $event->title,
'description' => $event->description,
'image' => asset('public/uploads/event/' . $event->image),
'image' => asset('public/uploads/events/' . $event->image),
'location' => $event->location,
'topic' => $event->topic,
'goal' => $event->goal,

Voir le fichier

@ -0,0 +1,116 @@
<?php
namespace App\Http\Controllers;
use App\Models\Event;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class EventController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$event = Event::get();
return view('backend.event.index', compact('event'));
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('backend.event.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
try {
$event = new Event;
$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');
} else {
$this->notice::error('Please try again');
return redirect()->back()->withInput();
}
} catch (Exception $e) {
dd($e);
$this->notice::error('Please try again');
return redirect()->back()->withInput();
}
}
/**
* Display the specified resource.
*/
public function show(Event $event)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$course = Course::get();
$event = Event::findOrFail(encryptor('decrypt', $id));
return view('backend.event.edit', compact('course', 'event'));
}
/**
* Update the specified resource in storage.
*/
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;
if ($event->save()) {
$this->notice::success('Data Saved');
return redirect()->route('event.index');
} else {
$this->notice::error('Please try again');
return redirect()->back()->withInput();
}
} catch (Exception $e) {
// dd($e);
$this->notice::error('Please try again');
return redirect()->back()->withInput();
}
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
$data = Event::findOrFail(encryptor('decrypt', $id));
if ($data->delete()) {
$this->notice::error('Data Deleted!');
return redirect()->back();
}
}
}

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 69 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 69 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 79 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 79 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 69 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 69 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 83 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 83 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 94 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 94 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 100 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 100 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 81 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 81 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 138 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 138 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 87 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 87 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 40 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 40 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 108 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 108 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 101 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 101 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 390 B

Après

Largeur:  |  Hauteur:  |  Taille: 390 B

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 83 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 83 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 71 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 71 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 234 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 234 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 2.0 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 2.0 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 56 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 56 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 52 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 52 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 41 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 41 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 44 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 44 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 55 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 55 KiB

Voir le fichier

Avant

Largeur:  |  Hauteur:  |  Taille: 37 KiB

Après

Largeur:  |  Hauteur:  |  Taille: 37 KiB

Voir le fichier

@ -0,0 +1,147 @@
@extends('backend.layouts.app')
@section('title', 'Add Event')
@push('styles')
<!-- Pick date -->
<link rel="stylesheet" href="{{asset('public/vendor/pickadate/themes/default.css')}}">
<link rel="stylesheet" href="{{asset('public/vendor/pickadate/themes/default.date.css')}}">
@endpush
@section('content')
<!--**********************************
Content body start
***********************************-->
<div class="content-body">
<!-- row -->
<div class="container-fluid">
<div class="row page-titles mx-0">
<div class="col-sm-6 p-md-0">
<div class="welcome-text">
<h4>Add 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('event.index')}}">Events</a></li>
<li class="breadcrumb-item active"><a href="{{route('event.create')}}">Add Event</a>
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-xl-12 col-xxl-12 col-sm-12">
<div class="card">
<div class="card-header">
<h5 class="card-title">Event Info</h5>
</div>
<div class="card-body">
<form action="{{route('event.store')}}" method="post" enctype="multipart/form-data">
@csrf
<div class="row">
<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')}}">
</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')}}">
</div>
@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">Topic</label>
<input type="text" class="form-control" name="topic" value="{{old('topic')}}">
</div>
@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">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>
<input type="text" class="form-control" name="hosted_by" value="{{old('hosted_by')}}">
</div>
@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">Valid From</label>
<input type="date" class="form-control" name="valid_from"
value="{{old('valid_from')}}">
</div>
@if($errors->has('valid_from'))
<span class="text-danger"> {{$errors->first('valid_from')}}</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="date" class="form-control" name="valid_until"
value="{{old('valid_until')}}">
</div>
@if($errors->has('valid_until'))
<span class="text-danger"> {{$errors->first('valid_until')}}</span>
@endif
</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>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!--**********************************
Content body end
***********************************-->
@endsection
@push('scripts')
<!-- pickdate -->
<script src="{{asset('public/vendor/pickadate/picker.js')}}"></script>
<script src="{{asset('public/vendor/pickadate/picker.time.js')}}"></script>
<script src="{{asset('public/vendor/pickadate/picker.date.js')}}"></script>
<!-- Pickdate -->
<script src="{{asset('public/js/plugins-init/pickadate-init.js')}}"></script>
@endpush

Voir le fichier

@ -0,0 +1,113 @@
@extends('backend.layouts.app')
@section('title', 'Edit Coupon')
@push('styles')
<!-- Pick date -->
<link rel="stylesheet" href="{{asset('public/vendor/pickadate/themes/default.css')}}">
<link rel="stylesheet" href="{{asset('public/vendor/pickadate/themes/default.date.css')}}">
@endpush
@section('content')
<!--**********************************
Content body start
***********************************-->
<div class="content-body">
<!-- row -->
<div class="container-fluid">
<div class="row page-titles mx-0">
<div class="col-sm-6 p-md-0">
<div class="welcome-text">
<h4>Edit Coupon</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>
</ol>
</div>
</div>
<div class="row">
<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>
</div>
<div class="card-body">
<form action="{{ route('coupon.update', $coupon->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)}}">
</div>
@if($errors->has('code'))
<span class="text-danger"> {{ $errors->first('code') }}</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)}}">
</div>
@if($errors->has('discount'))
<span class="text-danger"> {{ $errors->first('discount') }}</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)}}">
</div>
@if($errors->has('valid_from'))
<span class="text-danger"> {{ $errors->first('valid_from') }}</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)}}">
</div>
@if($errors->has('valid_until'))
<span class="text-danger"> {{ $errors->first('valid_until') }}</span>
@endif
</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>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!--**********************************
Content body end
***********************************-->
@endsection
@push('scripts')
<!-- pickdate -->
<script src="{{asset('public/vendor/pickadate/picker.js')}}"></script>
<script src="{{asset('public/vendor/pickadate/picker.time.js')}}"></script>
<script src="{{asset('public/vendor/pickadate/picker.date.js')}}"></script>
<!-- Pickdate -->
<script src="{{asset('public/js/plugins-init/pickadate-init.js')}}"></script>
@endpush

Voir le fichier

@ -0,0 +1,105 @@
@extends('backend.layouts.app')
@section('title', 'Coupon List')
@push('styles')
<!-- Datatable -->
<link href="{{asset('public/vendor/datatables/css/jquery.dataTables.min.css')}}" rel="stylesheet">
@endpush
@section('content')
<!--**********************************
Content body start
***********************************-->
<div class="content-body">
<!-- row -->
<div class="container-fluid">
<div class="row page-titles mx-0">
<div class="col-sm-6 p-md-0">
<div class="welcome-text">
<h4>Coupon 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>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="row tab-content">
<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>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="example3" class="display" style="min-width: 845px">
<thead>
<tr>
<th>{{__('#')}}</th>
<th>{{__('Coupon Code')}}</th>
<th>{{__('Discount')}}</th>
<th>{{__('Valid From')}}</th>
<th>{{__('Valid Until')}}</th>
<th>{{__('Action')}}</th>
</tr>
</thead>
<tbody>
@forelse ($coupon as $c)
<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>
<a href="{{route('coupon.edit', $c->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
class="la la-trash-o"></i></a>
<form id="form{{$c->id}}"
action="{{route('coupon.destroy', $c->id)}}"
method="post">
@csrf
@method('DELETE')
</form>
</td>
</tr>
@empty
<tr>
<th colspan="7" class="text-center">No Coupon Found</th>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--**********************************
Content body end
***********************************-->
@endsection
@push('scripts')
<!-- Datatable -->
<script src="{{asset('public/vendor/datatables/js/jquery.dataTables.min.js')}}"></script>
<script src="{{asset('public/js/plugins-init/datatables.init.js')}}"></script>
@endpush