u 23nov2023
Cette révision appartient à :
Parent
5611f6d3e0
révision
0c9bc7c0cd
@ -48,11 +48,14 @@ public function signInCheck(SignInRequest $request)
|
||||
try {
|
||||
$user = User::where('contact_en', $request->username)->orWhere('email', $request->username)->first();
|
||||
if ($user) {
|
||||
if (Hash::check($request->password, $user->password)) {
|
||||
$this->setSession($user);
|
||||
return redirect()->route('dashboard')->with('success', 'Successfully Logged In');
|
||||
if ($user->status == 1) {
|
||||
if (Hash::check($request->password, $user->password)) {
|
||||
$this->setSession($user);
|
||||
return redirect()->route('dashboard')->with('success', 'Successfully Logged In');
|
||||
} else
|
||||
return redirect()->route('login')->with('error', 'Username or Password is wrong!');
|
||||
} else
|
||||
return redirect()->route('login')->with('error', 'Username or Password is wrong!');
|
||||
return redirect()->route('login')->with('error', 'You are not an active user! Please contact to Authority');
|
||||
} else
|
||||
return redirect()->route('login')->with('error', 'Username or Password is wrong!');
|
||||
} catch (Exception $e) {
|
||||
@ -68,8 +71,8 @@ public function setSession($user)
|
||||
'userId' => encryptor('encrypt', $user->id),
|
||||
'userName' => encryptor('encrypt', $user->name_en),
|
||||
'emailAddress' => encryptor('encrypt', $user->email),
|
||||
'role_id'=> encryptor('encrypt',$user->role_id),
|
||||
'accessType'=> encryptor('encrypt',$user->full_access),
|
||||
'role_id' => encryptor('encrypt', $user->role_id),
|
||||
'accessType' => encryptor('encrypt', $user->full_access),
|
||||
'role' => encryptor('encrypt', $user->role->type),
|
||||
'roleIdentitiy' => encryptor('encrypt', $user->role->identity),
|
||||
'language' => encryptor('encrypt', $user->language),
|
||||
@ -84,8 +87,8 @@ public function signOut()
|
||||
return redirect('login')->with('danger', 'Succesfully Logged Out');
|
||||
}
|
||||
|
||||
public function show(User $data)
|
||||
public function show(User $data)
|
||||
{
|
||||
return view('backend.user.profile', compact('data'));
|
||||
return view('backend.user.profile', compact('data'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
91
app/Http/Controllers/Backend/PermissionController.php
Fichier normal
91
app/Http/Controllers/Backend/PermissionController.php
Fichier normal
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Backend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Permission;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Role;
|
||||
use App\Http\Requests\Backend\Permission\SaveRequest;
|
||||
use Exception;
|
||||
|
||||
class PermissionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index($id)
|
||||
{
|
||||
$role = Role::findOrFail(encryptor('decrypt', $id));
|
||||
$permission = Permission::where('role_id', encryptor('decrypt', $id))->get();
|
||||
return view('backend.permission.index', compact('role', 'permission'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function save(SaveRequest $request, $role)
|
||||
{
|
||||
try {
|
||||
// delete permission before saved
|
||||
Permission::where('role_id', encryptor('decrypt', $role))->delete();
|
||||
foreach ($request->permission as $permission) {
|
||||
$data = new Permission;
|
||||
$data->role_id = encryptor('decrypt', $role);
|
||||
$data->name = $permission;
|
||||
$data->save();
|
||||
}
|
||||
$this->notice::success('Permission saved');
|
||||
return redirect()->route('role.index');
|
||||
} catch (Exception $e) {
|
||||
$this->notice::error('Please try again');
|
||||
dd($e);
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
98
app/Http/Controllers/Backend/RoleController.php
Fichier normal
98
app/Http/Controllers/Backend/RoleController.php
Fichier normal
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Backend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Role;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\Backend\Role\AddNewRequest;
|
||||
use App\Http\Requests\Backend\Role\UpdateRequest;
|
||||
|
||||
class RoleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data=Role::paginate(10);
|
||||
return view('backend.role.index',compact('data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('backend.role.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(AddNewRequest $request)
|
||||
{
|
||||
try{
|
||||
$data=new Role();
|
||||
$data->name=$request->Name;
|
||||
$data->identity=$request->Identity;
|
||||
if($data->save()){
|
||||
$this->notice::success('Successfully saved');
|
||||
return redirect()->route('role.index');
|
||||
}
|
||||
}catch(Exception $e){
|
||||
dd($e);
|
||||
$this->notice::error('Please try again');
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$role=Role::findOrFail(encryptor('decrypt',$id));
|
||||
return view('backend.role.edit',compact('role'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(UpdateRequest $request, $id)
|
||||
{
|
||||
try{
|
||||
$data=Role::findOrFail(encryptor('decrypt',$id));
|
||||
$data->name=$request->Name;
|
||||
$data->identity=$request->Identity;
|
||||
if($data->save()){
|
||||
$this->notice::success('Successfully updated');
|
||||
return redirect()->route('role.index');
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->notice::error('Please try again');
|
||||
//dd($e);
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$data= Role::findOrFail(encryptor('decrypt',$id));
|
||||
if($data->delete()){
|
||||
$this->notice::warning('Deleted Permanently!');
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,8 +5,17 @@
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Toastr;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
public $notice;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->notice = new Toastr();
|
||||
}
|
||||
|
||||
use AuthorizesRequests, ValidatesRequests;
|
||||
}
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
<?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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@ -55,6 +55,7 @@ class Kernel extends HttpKernel
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'checkrole' => \App\Http\Middleware\checkRole::class,
|
||||
'checkauth' => \App\Http\Middleware\checkAuth::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
|
||||
@ -3,8 +3,10 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use App\Models\User; //custom
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Session; //custom
|
||||
use App\Models\Permission; //custom
|
||||
|
||||
class checkAuth
|
||||
{
|
||||
@ -13,8 +15,17 @@ class checkAuth
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
return $next($request);
|
||||
if (!Session::has('userId') || Session::has('userId') == null) {
|
||||
return redirect()->route('logOut');
|
||||
} else {
|
||||
$user = User::where('status', 1)->where('id', currentUserId())->first();
|
||||
if (!$user)
|
||||
return redirect()->route('logOut');
|
||||
else
|
||||
return $next($request);
|
||||
}
|
||||
return redirect()->route('logOut');
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,13 +20,23 @@ public function handle(Request $request, Closure $next)
|
||||
if (!Session::has('userId') || Session::has('userId') == null) {
|
||||
return redirect()->route('logOut');
|
||||
} else {
|
||||
$user = User::find(currentUserId());
|
||||
$user = User::where('status', 1)->where('id', currentUserId())->first();
|
||||
if (!$user) {
|
||||
return redirect()->route('logOut');
|
||||
} else if ($user->full_access == "1") {
|
||||
return $next($request);
|
||||
} else {
|
||||
return $next($request);
|
||||
$auto_accept = array("POST", "PUT");
|
||||
if (in_array($request->route()->methods[0], $auto_accept)) {
|
||||
return $next($request);
|
||||
} else {
|
||||
if (Permission::where('role_id', $user->role_id)->where('name', $request->route()->getName())->exists())
|
||||
return $next($request);
|
||||
else {
|
||||
\Toastr::warning("You don't have permission to access this page");
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return redirect()->route('logOut');
|
||||
|
||||
28
app/Http/Requests/Backend/Permission/SaveRequest.php
Fichier normal
28
app/Http/Requests/Backend/Permission/SaveRequest.php
Fichier normal
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Permission;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'permission'=>'required'
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Backend/Role/AddNewRequest.php
Fichier normal
30
app/Http/Requests/Backend/Role/AddNewRequest.php
Fichier normal
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Role;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AddNewRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'Identity'=>'required|max:30|alpha:ascii|unique:roles,identity',
|
||||
'Name'=>'required|max:30|unique:roles,name'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
32
app/Http/Requests/Backend/Role/UpdateRequest.php
Fichier normal
32
app/Http/Requests/Backend/Role/UpdateRequest.php
Fichier normal
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Role;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(Request $r): array
|
||||
{
|
||||
$id=encryptor('decrypt',$r->uptoken);
|
||||
return [
|
||||
'Identity'=>'required|max:30|alpha:ascii|unique:roles,identity,'.$id,
|
||||
'Name'=>'required|max:30|unique:roles,name,'.$id
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"brian2694/laravel-toastr": "^5.58",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"laravel/framework": "^10.10",
|
||||
"laravel/sanctum": "^3.3",
|
||||
|
||||
64
composer.lock
générée
64
composer.lock
générée
@ -4,8 +4,70 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "283e34281449c1c77bfa692414cd4a55",
|
||||
"content-hash": "da2e44149d81ccf73d7aaef91083caa6",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brian2694/laravel-toastr",
|
||||
"version": "5.58",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/brian2694/laravel-toastr.git",
|
||||
"reference": "6c7d1c6a959b7042757865d3df0c2f57b912f2c1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/brian2694/laravel-toastr/zipball/6c7d1c6a959b7042757865d3df0c2f57b912f2c1",
|
||||
"reference": "6c7d1c6a959b7042757865d3df0c2f57b912f2c1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/session": ">=5.2.7",
|
||||
"illuminate/support": ">=5.2.7",
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Brian2694\\Toastr\\ToastrServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Toastr": "Brian2694\\Toastr\\Facades\\Toastr"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/helper.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Brian2694\\Toastr\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "brian2694",
|
||||
"email": "briansanchez2694@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "toastr.js for Laravel",
|
||||
"homepage": "https://github.com/brian2694/laravel-toastr",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"notification",
|
||||
"php",
|
||||
"toastr"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/brian2694/laravel-toastr/issues",
|
||||
"source": "https://github.com/brian2694/laravel-toastr/tree/5.58"
|
||||
},
|
||||
"time": "2023-10-31T20:35:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "brick/math",
|
||||
"version": "0.11.0",
|
||||
|
||||
@ -15,29 +15,29 @@ public function up(): void
|
||||
{
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('type', 20)->unique();
|
||||
$table->string('name', 20)->unique();
|
||||
$table->string('identity', 30)->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
DB::table('roles')->insert([
|
||||
[
|
||||
'type'=> 'Super Admin',
|
||||
'name'=> 'Super Admin',
|
||||
'identity'=> 'superadmin',
|
||||
'created_at'=> Carbon::now()
|
||||
],
|
||||
[
|
||||
'type'=> 'Admin',
|
||||
'name'=> 'Admin',
|
||||
'identity'=> 'admin',
|
||||
'created_at'=> Carbon::now()
|
||||
],
|
||||
[
|
||||
'type'=> 'Instructor',
|
||||
'name'=> 'Instructor',
|
||||
'identity'=> 'instructor',
|
||||
'created_at'=> Carbon::now()
|
||||
],
|
||||
[
|
||||
'type'=> 'Student',
|
||||
'name'=> 'Student',
|
||||
'identity'=> 'student',
|
||||
'created_at'=> Carbon::now()
|
||||
]
|
||||
|
||||
@ -261,12 +261,12 @@ class="feather feather-log-out">
|
||||
</li>
|
||||
<li><a class="has-arrow" href="javascript:void()" aria-expanded="false">
|
||||
<i class="la la-book"></i>
|
||||
<span class="nav-text">Contents</span>
|
||||
<span class="nav-text">Roles</span>
|
||||
</a>
|
||||
<ul aria-expanded="false">
|
||||
<li><a href="all-library.html">All Content</a></li>
|
||||
<li><a href="add-library.html">Add Content</a></li>
|
||||
<li><a href="edit-library.html">Edit Content</a></li>
|
||||
<li><a href="{{route('role.index')}}">All Role</a></li>
|
||||
<li><a href="{{route('role.create')}}">Add Role</a></li>
|
||||
<li><a href="{{route('role.index')}}">Edit Role</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="has-arrow" href="javascript:void()" aria-expanded="false">
|
||||
|
||||
206
resources/views/backend/permission/index.blade.php
Fichier normal
206
resources/views/backend/permission/index.blade.php
Fichier normal
@ -0,0 +1,206 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', trans('Permission List'))
|
||||
|
||||
@push('styles')
|
||||
<!-- Datatable -->
|
||||
<link href="{{asset('public/vendor/datatables/css/jquery.dataTables.min.css')}}" rel="stylesheet">
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
|
||||
<style>
|
||||
.list-group-collapse li>ul li:first-child {
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
.list-group-collapse li>ul {
|
||||
margin-left: 16px;
|
||||
margin-right: 16px;
|
||||
margin-bottom: 11px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<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>Permission 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('role.index')}}">Permissions</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('role.index')}}">All Permission</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<ul class="nav nav-pills mb-3">
|
||||
<li class="nav-item"><a href="#list-view" data-toggle="tab"
|
||||
class="nav-link btn-primary mr-1 show active">List View</a></li>
|
||||
<li class="nav-item"><a href="#grid-view" data-toggle="tab" class="nav-link btn-primary">Grid
|
||||
View</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<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 Role List </h4>
|
||||
<a href="{{route('role.create')}}" class="btn btn-primary">+ Add new</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4>{{$role->type}}</h4>
|
||||
@php
|
||||
$routes=array();
|
||||
$auto_accept=array('GET',"DELETE");
|
||||
$permissions=array();
|
||||
foreach($permission as $perm){
|
||||
$permissions[$perm->name]=$perm->name;
|
||||
}
|
||||
@endphp
|
||||
@foreach(Illuminate\Support\Facades\Route::getRoutes() as $v)
|
||||
@if($v->getPrefix()=="/admin")
|
||||
@php
|
||||
$rl=explode('.',$v->getName());
|
||||
if(isset($rl[1]))
|
||||
$routes[$rl[0]][]=array("method"=>$v->methods[0],"function"=>$rl[1]);
|
||||
@endphp
|
||||
@endif
|
||||
@endforeach
|
||||
<form action="{{route('permission.save',encryptor('encrypt',$role->id))}}" method="post"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="row">
|
||||
@forelse($routes as $k=>$r)
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<input type="checkbox" onchange="checkAll(this)"> {{__($k)}}
|
||||
@if($r)
|
||||
<ul class="list-group">
|
||||
@foreach($r as $name)
|
||||
@if(in_array($name['method'],$auto_accept))
|
||||
<li class="list-group-item">
|
||||
@if(in_array($k.'.'.$name['function'],$permissions))
|
||||
<input type="checkbox" checked name="permission[]"
|
||||
value="{{$k.'.'.$name['function']}}">
|
||||
{{__($name['function'])}}
|
||||
@else
|
||||
<input type="checkbox" name="permission[]"
|
||||
value="{{$k.'.'.$name['function']}}">
|
||||
{{__($name['function'])}}
|
||||
@endif
|
||||
</li>
|
||||
@endif
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</div>
|
||||
@empty
|
||||
|
||||
@endforelse
|
||||
<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">Cencel</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- <div id="grid-view" class="tab-pane fade col-lg-12">
|
||||
<div class="row">
|
||||
@forelse ($data as $d)
|
||||
<div class="col-lg-4 col-md-6 col-sm-6 col-12">
|
||||
<div class="card card-profile">
|
||||
<div class="card-header justify-content-end pb-0">
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-link" type="button" data-toggle="dropdown">
|
||||
<span class="dropdown-dots fs--1"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-right border py-0">
|
||||
<div class="py-2">
|
||||
<a class="dropdown-item"
|
||||
href="{{route('user.edit', encryptor('encrypt',$d->id))}}">Edit</a>
|
||||
<a class="dropdown-item text-danger"
|
||||
href="javascript:void(0);">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-2">
|
||||
<div class="text-center">
|
||||
<div class="profile-photo">
|
||||
<img src="{{asset('public/uploads/users/'.$d->image)}}" width="100"
|
||||
height="100" class="rounded-circle" alt="">
|
||||
</div>
|
||||
<h3 class="mt-4 mb-1">{{$d->name_en}}</h3>
|
||||
<p class="text-muted">{{$d->role?->type}}</p>
|
||||
<ul class="list-group mb-3 list-group-flush">
|
||||
<li class="list-group-item px-0 d-flex justify-content-between">
|
||||
<span>#Sl.</span><strong>{{$d->id}}</strong>
|
||||
</li>
|
||||
<li class="list-group-item px-0 d-flex justify-content-between">
|
||||
<span class="mb-0">Phone No.
|
||||
:</span><strong>{{$d->contact_en}}</strong>
|
||||
</li>
|
||||
<li class="list-group-item px-0 d-flex justify-content-between">
|
||||
<span class="mb-0">Email:</span><strong>{{$d->email}}</strong>
|
||||
</li>
|
||||
<li class="list-group-item px-0 d-flex justify-content-between">
|
||||
<span class="mb-0">Created At.
|
||||
:</span><strong>{{$d->created_at}}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="btn btn-outline-primary btn-rounded mt-3 px-4"
|
||||
href="about-student.html">Read More</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<div class="col-lg-4 col-md-6 col-sm-6 col-12">
|
||||
<div class="card card-profile">
|
||||
<div class="card-body pt-2">
|
||||
<div class="text-center">
|
||||
<p class="mt-3 px-4">User Not Found</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
</div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@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>
|
||||
|
||||
<script>
|
||||
function checkAll(e){
|
||||
if($(e).prop('checked')==true)
|
||||
$(e).next('.list-group').find('input').attr('checked','checked');
|
||||
else
|
||||
$(e).next('.list-group').find('input').removeAttr('checked','checked');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
85
resources/views/backend/role/create.blade.php
Fichier normal
85
resources/views/backend/role/create.blade.php
Fichier normal
@ -0,0 +1,85 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', 'Add Role')
|
||||
|
||||
@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')
|
||||
|
||||
<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 Role</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('role.index')}}">Roles</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('role.create')}}">Add Role</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">Basic Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{route('role.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">Identity (only Alpha Character)</label>
|
||||
<input type="text" class="form-control" name="Identity"
|
||||
value="{{old('Identity')}}">
|
||||
</div>
|
||||
@if($errors->has('Identity'))
|
||||
<span class="text-danger"> {{ $errors->first('Identity') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Name</label>
|
||||
<input type="text" class="form-control" name="Name"
|
||||
value="{{old('Name')}}">
|
||||
</div>
|
||||
@if($errors->has('Name'))
|
||||
<span class="text-danger"> {{ $errors->first('Name') }}</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">Cencel</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@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
|
||||
86
resources/views/backend/role/edit.blade.php
Fichier normal
86
resources/views/backend/role/edit.blade.php
Fichier normal
@ -0,0 +1,86 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', 'Update Role')
|
||||
|
||||
@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')
|
||||
|
||||
<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 Role</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('role.index')}}">Roles</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('role.create')}}">Add Role</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">Basic Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{route('role.update',encryptor('encrypt',$role->id))}}" method="post" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
<input type="hidden" name="uptoken" value="{{encryptor('encrypt',$role->id)}}">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Identity (only Alpha Character)</label>
|
||||
<input type="text" class="form-control" name="Identity"
|
||||
value="{{old('Identity',$role->identity)}}">
|
||||
</div>
|
||||
@if($errors->has('Identity'))
|
||||
<span class="text-danger"> {{ $errors->first('Identity') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Name</label>
|
||||
<input type="text" class="form-control" name="Name" value="{{old('Name',$role->name)}}">
|
||||
</div>
|
||||
@if($errors->has('Name'))
|
||||
<span class="text-danger"> {{ $errors->first('Name') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
<button type="submit" class="btn btn-light">Cencel</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@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
|
||||
168
resources/views/backend/role/index.blade.php
Fichier normal
168
resources/views/backend/role/index.blade.php
Fichier normal
@ -0,0 +1,168 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', trans('Role List'))
|
||||
|
||||
@push('styles')
|
||||
<!-- Datatable -->
|
||||
<link href="{{asset('public/vendor/datatables/css/jquery.dataTables.min.css')}}" rel="stylesheet">
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
|
||||
<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>Role 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('role.index')}}">Roles</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('role.index')}}">All Role</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<ul class="nav nav-pills mb-3">
|
||||
<li class="nav-item"><a href="#list-view" data-toggle="tab"
|
||||
class="nav-link btn-primary mr-1 show active">List View</a></li>
|
||||
<li class="nav-item"><a href="#grid-view" data-toggle="tab" class="nav-link btn-primary">Grid
|
||||
View</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<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 Role List </h4>
|
||||
<a href="{{route('role.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>{{__('Name')}}</th>
|
||||
<th>{{__('Identity')}}</th>
|
||||
<th>{{__('Action')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($data as $d)
|
||||
<tr>
|
||||
<td>{{++$loop->index}}</td>
|
||||
<td><strong>{{$d->name}}</strong></td>
|
||||
<td>{{$d->identity}}</td>
|
||||
<td>
|
||||
<a href="{{route('role.edit', encryptor('encrypt',$d->id))}}"
|
||||
class="btn btn-sm btn-primary"><i class="la la-pencil"></i></a>
|
||||
<a href="{{route('permission.list', encryptor('encrypt',$d->id))}}"
|
||||
class="btn btn-sm btn-primary"><i class="la la-unlock"></i></a>
|
||||
<a href="javascript:void(0);" class="btn btn-sm btn-danger"
|
||||
onclick="$('#form{{$d->id}}').submit()"><i
|
||||
class="la la-trash-o"></i></a>
|
||||
<form id="form{{$d->id}}"
|
||||
action="{{route('role.destroy', encryptor('encrypt',$d->id))}}"
|
||||
method="post">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<th colspan="7" class="text-center">No User Found</th>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="grid-view" class="tab-pane fade col-lg-12">
|
||||
<div class="row">
|
||||
@forelse ($data as $d)
|
||||
<div class="col-lg-4 col-md-6 col-sm-6 col-12">
|
||||
<div class="card card-profile">
|
||||
<div class="card-header justify-content-end pb-0">
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-link" type="button" data-toggle="dropdown">
|
||||
<span class="dropdown-dots fs--1"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-right border py-0">
|
||||
<div class="py-2">
|
||||
<a class="dropdown-item"
|
||||
href="{{route('user.edit', encryptor('encrypt',$d->id))}}">Edit</a>
|
||||
<a class="dropdown-item text-danger"
|
||||
href="javascript:void(0);">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-2">
|
||||
<div class="text-center">
|
||||
<div class="profile-photo">
|
||||
<img src="{{asset('public/uploads/users/'.$d->image)}}" width="100"
|
||||
height="100" class="rounded-circle" alt="">
|
||||
</div>
|
||||
<h3 class="mt-4 mb-1">{{$d->name_en}}</h3>
|
||||
<p class="text-muted">{{$d->role?->type}}</p>
|
||||
<ul class="list-group mb-3 list-group-flush">
|
||||
<li class="list-group-item px-0 d-flex justify-content-between">
|
||||
<span>#Sl.</span><strong>{{$d->id}}</strong>
|
||||
</li>
|
||||
<li class="list-group-item px-0 d-flex justify-content-between">
|
||||
<span class="mb-0">Phone No.
|
||||
:</span><strong>{{$d->contact_en}}</strong>
|
||||
</li>
|
||||
<li class="list-group-item px-0 d-flex justify-content-between">
|
||||
<span class="mb-0">Email:</span><strong>{{$d->email}}</strong>
|
||||
</li>
|
||||
<li class="list-group-item px-0 d-flex justify-content-between">
|
||||
<span class="mb-0">Created At.
|
||||
:</span><strong>{{$d->created_at}}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="btn btn-outline-primary btn-rounded mt-3 px-4"
|
||||
href="about-student.html">Read More</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<div class="col-lg-4 col-md-6 col-sm-6 col-12">
|
||||
<div class="card card-profile">
|
||||
<div class="card-body pt-2">
|
||||
<div class="text-center">
|
||||
<p class="mt-3 px-4">User Not Found</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@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
|
||||
@ -66,7 +66,7 @@ class="nav-link btn-primary mr-1 show active">List View</a></li>
|
||||
<td><strong>{{$d->name_en}}</strong></td>
|
||||
<td>{{$d->email}}</td>
|
||||
<td>{{$d->contact_en}}</td>
|
||||
<td>{{$d->role?->type}}</td>
|
||||
<td>{{$d->role?->name}}</td>
|
||||
<td>@if($d->status==1){{__('Active')}} @else{{__('Inactive')}} @endif
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
use App\Http\Controllers\Backend\UserController as user;
|
||||
use App\Http\Controllers\Backend\DashboardController as dashboard;
|
||||
use App\Http\Controllers\Backend\Courses\CourseCategoryController as courseCategory;
|
||||
use App\Http\Controllers\Backend\RoleController as role;
|
||||
use App\Http\Controllers\Backend\PermissionController as permission;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -25,11 +27,17 @@
|
||||
|
||||
Route::resource('/courseCategory', courseCategory::class);
|
||||
|
||||
|
||||
Route::middleware(['checkrole'])->group(function () {
|
||||
Route::middleware(['checkauth'])->prefix('admin')->group(function () {
|
||||
Route::get('/dashboard', [dashboard::class, 'index'])->name('dashboard');
|
||||
});
|
||||
|
||||
Route::middleware(['checkrole'])->prefix('admin')->group(function () {
|
||||
Route::resource('/user', user::class);
|
||||
Route::get('/userProfile', [auth::class, 'show'])->name('userProfile');
|
||||
Route::resource('user',user::class);
|
||||
Route::resource('role',role::class);
|
||||
Route::get('permission/{role}',[permission::class,'index'])->name('permission.list');
|
||||
Route::post('permission/{role}',[permission::class,'save'])->name('permission.save');
|
||||
});
|
||||
|
||||
|
||||
@ -43,3 +51,4 @@
|
||||
// Route::get('/dashboard', function () {
|
||||
// return view('welcome');
|
||||
// })->name('dashboard');
|
||||
|
||||
Chargement…
Référencer dans un nouveau ticket
Block a user