u
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers\Backend\Courses;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\CourseCategory;
|
use App\Models\CourseCategory;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Requests\Backend\CourseCategory\AddNewRequest;
|
use App\Http\Requests\Backend\CourseCategory\AddNewRequest;
|
||||||
@ -16,7 +17,7 @@ class CourseCategoryController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$data = CourseCategory::paginate(10);
|
$data = CourseCategory::paginate(10);
|
||||||
return view('courseCategory.index', compact('data'));
|
return view('backend.courses.courseCategory.index', compact('data'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +25,7 @@ public function index()
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
return view('courseCategory.create');
|
return view('backend.courses.courseCategory.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +44,7 @@ public function store(AddNewRequest $request)
|
|||||||
$data->category_image = $imageName;
|
$data->category_image = $imageName;
|
||||||
}
|
}
|
||||||
if ($data->save())
|
if ($data->save())
|
||||||
return redirect()->route('courseCategory.index')->with('success', 'Data Saved');
|
return redirect()->route('backend.courses.courseCategory.index')->with('success', 'Data Saved');
|
||||||
else
|
else
|
||||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@ -66,7 +67,7 @@ public function show(CourseCategory $courseCategory)
|
|||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$data = CourseCategory::findOrFail($id);
|
$data = CourseCategory::findOrFail($id);
|
||||||
return view('courseCategory.edit', compact('data'));
|
return view('backend.courses.courseCategory.edit', compact('data'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +86,7 @@ public function update(Request $request, $id)
|
|||||||
$data->category_image = $imageName;
|
$data->category_image = $imageName;
|
||||||
}
|
}
|
||||||
if ($data->save())
|
if ($data->save())
|
||||||
return redirect()->route('courseCategory.index')->with('success', 'Data Saved');
|
return redirect()->route('backend.courses.courseCategory.index')->with('success', 'Data Saved');
|
||||||
else
|
else
|
||||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
65
app/Http/Controllers/PermissionController.php
Fichier normal
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Permission;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class PermissionController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Permission $permission)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Permission $permission)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Permission $permission)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Permission $permission)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
20
app/Http/Middleware/checkAuth.php
Fichier normal
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class checkAuth
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,8 +5,8 @@
|
|||||||
use Closure;
|
use Closure;
|
||||||
use App\Models\User; //custom
|
use App\Models\User; //custom
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Session; //custom
|
use Session; //custom
|
||||||
|
use App\Models\Permission; //custom
|
||||||
|
|
||||||
class checkRole
|
class checkRole
|
||||||
{
|
{
|
||||||
@ -15,7 +15,7 @@ class checkRole
|
|||||||
*
|
*
|
||||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
if (!Session::has('userId') || Session::has('userId') == null) {
|
if (!Session::has('userId') || Session::has('userId') == null) {
|
||||||
return redirect()->route('logOut');
|
return redirect()->route('logOut');
|
||||||
|
|||||||
15
app/Models/Permission.php
Fichier normal
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Permission extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
public function role(){
|
||||||
|
return $this->belongsToMany(Role::class,'role_permission');
|
||||||
|
}
|
||||||
|
}
|
||||||
30
database/migrations/2023_11_22_143059_create_permissions_table.php
Fichier normal
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('permissions', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedBigInteger('role_id')->index();
|
||||||
|
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
|
||||||
|
$table->string('name');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('permissions');
|
||||||
|
}
|
||||||
|
};
|
||||||
BIN
public/uploads/courseCategories/1461700662815.jpg
Fichier normal
|
Après Largeur: | Hauteur: | Taille: 175 KiB |
BIN
public/uploads/courseCategories/6941700662715.jpg
Fichier normal
|
Après Largeur: | Hauteur: | Taille: 135 KiB |
BIN
public/uploads/courseCategories/8271700662783.jpg
Fichier normal
|
Après Largeur: | Hauteur: | Taille: 146 KiB |
BIN
public/uploads/users/2021700663139.jpg
Fichier normal
|
Après Largeur: | Hauteur: | Taille: 22 KiB |
BIN
public/uploads/users/3341700662994.jpg
Fichier normal
|
Après Largeur: | Hauteur: | Taille: 18 KiB |
BIN
public/uploads/users/7111700662381.png
Fichier normal
|
Après Largeur: | Hauteur: | Taille: 255 KiB |
BIN
public/uploads/users/7901700663094.jpg
Fichier normal
|
Après Largeur: | Hauteur: | Taille: 20 KiB |
@ -4,7 +4,7 @@
|
|||||||
use App\Http\Controllers\Backend\AuthenticationController as auth;
|
use App\Http\Controllers\Backend\AuthenticationController as auth;
|
||||||
use App\Http\Controllers\Backend\UserController as user;
|
use App\Http\Controllers\Backend\UserController as user;
|
||||||
use App\Http\Controllers\Backend\DashboardController as dashboard;
|
use App\Http\Controllers\Backend\DashboardController as dashboard;
|
||||||
use App\Http\Controllers\CourseCategoryController as courseCategory;
|
use App\Http\Controllers\Backend\Courses\CourseCategoryController as courseCategory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||