Commit 8fce89f1 authored by Rajdeep Dutta's avatar Rajdeep Dutta

new upload1

parent e67aa64b
......@@ -18,13 +18,14 @@ public function dashboard() {
}
public function showLoginForm() {
return view('login');
return view('login'); // or 'auth.login' depending on your folder
}
public function loginProcess(Request $request) {
$request->validate([
'email' => 'required|email',
'password' => 'required',
'role' => 'required',
]);
$credentials = $request->only('email', 'password');
......
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
class UserManagementController extends Controller
{
public function roleAccess()
{
return view('layouts.roles'); // View will be resources/views/user-management/roles.blade.php
}
public function assignRole(Request $request)
{
$request->validate([
'email' => 'required|email',
'password' => 'required|string',
'role' => 'required|in:player,coach,manager',
]);
// Find user by email
$user = User::where('email', $request->email)->first();
if (!$user) {
return back()->with('error', 'User not found.');
}
if (!Hash::check($request->password, $user->password)) {
return back()->with('error', 'Incorrect password.');
}
// Assign the role
$user->role = $request->role;
$user->save();
return back()->with('success', 'Role "' . $request->role . '" assigned to ' . $user->email);
}
}
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class RoleMiddleware
{
/**
* 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);
}
}
......@@ -21,6 +21,7 @@ class User extends Authenticatable
'name',
'email',
'password',
'role',
];
/**
......
......@@ -12,10 +12,10 @@
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('role')->default('fan');
});
$table->string('role')->nullable();
});
}
/**
* Reverse the migrations.
*/
......
......@@ -14,6 +14,21 @@
<!-- AdminLTE CSS -->
<link rel="stylesheet" href="{{ asset('dashboard_assets/css/adminlte.min.css') }}">
</head>
<style>
body.login-page {
background-image: url('{{ asset('dashboard_assets/image/bg-login.jpg') }}');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.login-box {
background-color: rgba(255, 255, 255, 0.95);
border-radius: 10px;
padding: 20px;
box-shadow: 0 0 20px rgba(0,0,0,0.2);
}
</style>
<body class="hold-transition register-page">
<div class="register-box">
......
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AdminLTE v4 | Dashboard</title>
<title>Sports MIS</title>
<!--begin::Primary Meta Tags-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="title" content="AdminLTE v4 | Dashboard" />
......
......@@ -27,178 +27,5 @@
<button type="submit" class="btn btn-outline-danger btn-large">Logout</button>
</form>
</li>
<!--end::Navbar Search-->
<!--begin::Messages Dropdown Menu-->
{{-- <li class="nav-item dropdown">
<a class="nav-link" data-bs-toggle="dropdown" href="#">
<i class="bi bi-chat-text"></i>
<span class="navbar-badge badge text-bg-danger">3</span>
</a> --}}
{{-- <div class="dropdown-menu dropdown-menu-lg dropdown-menu-end">
<a href="#" class="dropdown-item">
<!--begin::Message-->
<div class="d-flex">
<div class="flex-shrink-0">
<img
src="../../dist/assets/img/user1-128x128.jpg"
alt="User Avatar"
class="img-size-50 rounded-circle me-3"
/>
</div>
<div class="flex-grow-1">
<h3 class="dropdown-item-title">
Brad Diesel
<span class="float-end fs-7 text-danger"
><i class="bi bi-star-fill"></i
></span>
</h3>
<p class="fs-7">Call me whenever you can...</p>
<p class="fs-7 text-secondary">
<i class="bi bi-clock-fill me-1"></i> 4 Hours Ago
</p>
</div>
</div>
<!--end::Message-->
</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">
<!--begin::Message-->
<div class="d-flex">
<div class="flex-shrink-0">
<img
src="../../dist/assets/img/user8-128x128.jpg"
alt="User Avatar"
class="img-size-50 rounded-circle me-3"
/>
</div>
<div class="flex-grow-1">
<h3 class="dropdown-item-title">
John Pierce
<span class="float-end fs-7 text-secondary">
<i class="bi bi-star-fill"></i>
</span>
</h3>
<p class="fs-7">I got your message bro</p>
<p class="fs-7 text-secondary">
<i class="bi bi-clock-fill me-1"></i> 4 Hours Ago
</p>
</div>
</div>
<!--end::Message-->
</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">
<!--begin::Message-->
<div class="d-flex">
<div class="flex-shrink-0">
<img
src="../../dist/assets/img/user3-128x128.jpg"
alt="User Avatar"
class="img-size-50 rounded-circle me-3"
/>
</div>
<div class="flex-grow-1">
<h3 class="dropdown-item-title">
Nora Silvester
<span class="float-end fs-7 text-warning">
<i class="bi bi-star-fill"></i>
</span>
</h3>
<p class="fs-7">The subject goes here</p>
<p class="fs-7 text-secondary">
<i class="bi bi-clock-fill me-1"></i> 4 Hours Ago
</p>
</div>
</div>
<!--end::Message-->
</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item dropdown-footer">See All Messages</a>
</div> --}}
{{-- </li> --}}
<!--end::Messages Dropdown Menu-->
<!--begin::Notifications Dropdown Menu-->
{{-- <li class="nav-item dropdown">
<a class="nav-link" data-bs-toggle="dropdown" href="#">
<i class="bi bi-bell-fill"></i>
<span class="navbar-badge badge text-bg-warning">15</span>
</a>
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end">
<span class="dropdown-item dropdown-header">15 Notifications</span>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">
<i class="bi bi-envelope me-2"></i> 4 new messages
<span class="float-end text-secondary fs-7">3 mins</span>
</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">
<i class="bi bi-people-fill me-2"></i> 8 friend requests
<span class="float-end text-secondary fs-7">12 hours</span>
</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">
<i class="bi bi-file-earmark-fill me-2"></i> 3 new reports
<span class="float-end text-secondary fs-7">2 days</span>
</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item dropdown-footer"> See All Notifications </a>
</div>
</li> --}}
<!--end::Notifications Dropdown Menu-->
<!--begin::Fullscreen Toggle-->
{{-- <li class="nav-item">
<a class="nav-link" href="#" data-lte-toggle="fullscreen">
<i data-lte-icon="maximize" class="bi bi-arrows-fullscreen"></i>
<i data-lte-icon="minimize" class="bi bi-fullscreen-exit" style="display: none"></i>
</a>
</li> --}}
<!--end::Fullscreen Toggle-->
<!--begin::User Menu Dropdown-->
{{-- <li class="nav-item dropdown user-menu">
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown">
<img
src="../../dist/assets/img/user2-160x160.jpg"
class="user-image rounded-circle shadow"
alt="User Image"
/>
<span class="d-none d-md-inline">Alexander Pierce</span>
</a>
<ul class="dropdown-menu dropdown-menu-lg dropdown-menu-end">
<!--begin::User Image-->
<li class="user-header text-bg-primary">
<img
src="../../dist/assets/img/user2-160x160.jpg"
class="rounded-circle shadow"
alt="User Image"
/>
<p>
Alexander Pierce - Web Developer
<small>Member since Nov. 2023</small>
</p>
</li>
<!--end::User Image-->
<!--begin::Menu Body-->
<li class="user-body">
<!--begin::Row-->
<div class="row">
<div class="col-4 text-center"><a href="#">Followers</a></div>
<div class="col-4 text-center"><a href="#">Sales</a></div>
<div class="col-4 text-center"><a href="#">Friends</a></div>
</div>
<!--end::Row-->
</li>
<!--end::Menu Body-->
<!--begin::Menu Footer-->
<li class="user-footer">
<a href="#" class="btn btn-default btn-flat">Profile</a>
<a href="#" class="btn btn-default btn-flat float-end">Sign out</a>
</li>
<!--end::Menu Footer-->
</ul>
</li> --}}
<!--end::User Menu Dropdown-->
</ul>
<!--end::End Navbar Links-->
</div>
<!--end::Container-->
</nav>
\ No newline at end of file
@extends('layouts.master')
@section('content')
<div class="container mt-4">
<h1 class="mb-4">Role-based Access</h1>
{{-- Flash message --}}
@if(session('success'))
<div class="alert alert-success">{{ session('success') }}</div>
@endif
{{-- Role Assignment Form --}}
<div class="card mb-4">
<div class="card-header"><b>Assign Role to User</b></div>
<div class="card-body">
<form action="{{ route('user.assignRole') }}" method="POST">
@csrf
<div class="mb-3">
<label for="email" class="form-label">User Email</label>
<input type="email" name="email" class="form-control" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">User Password</label>
<input type="password" name="password" class="form-control" required>
</div>
<div class="mb-3">
<label for="role" class="form-label">Select Role</label>
<select name="role" class="form-select" required>
<option value="">-- Select Role --</option>
<option value="player">Player</option>
<option value="coach">Coach</option>
<option value="manager">Manager</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Assign Role</button>
</form>
</div>
</div>
{{-- Existing Roles Table --}}
<h4>Existing Role Assignments</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>User</th>
<th>Assigned Role</th>
</tr>
</thead>
<tbody>
{{-- Example static content; replace with dynamic roles --}}
<tr>
<td>john@example.com</td>
<td>Coach</td>
</tr>
<tr>
<td>alice@example.com</td>
<td>Admin</td>
</tr>
</tbody>
</table>
</div>
@endsection
This diff is collapsed.
......@@ -10,18 +10,33 @@
<link rel="stylesheet" href="{{ asset('dashboard_assets/css/fontawesome-free/css/all.min.css') }}">
<link rel="stylesheet" href="{{ asset('dashboard_assets/css/adminlte.min.css') }}">
</head>
<style>
body.login-page {
background-image: url('{{ asset('dashboard_assets/image/bg-login.jpg') }}');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.login-box {
background-color: rgba(255, 255, 255, 0.95);
border-radius: 10px;
padding: 20px;
box-shadow: 0 0 20px rgba(0,0,0,0.2);
}
</style>
<body class="hold-transition login-page">
<div class="login-box">
<div class="card card-outline card-primary">
<div class="card-header text-center">
<a href="#" class="h1"><b>Sports</b>Manager</a>
<a href="#" class="h1"><b>Sports</b> Manager</a>
</div>
<div class="card-body">
<p class="login-box-msg">Sign in to start your session</p>
<!-- FORM, but no action for now -->
<form action="{{ route('login.submit') }}" method="POST">
<form action="{{ route('login') }}" method="POST">
@csrf
<!-- Add name="email" -->
......
......@@ -2,6 +2,7 @@
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\UserManagementController;
// Index route
Route::get('/', [HomeController::class, 'index'])->name('index');
......@@ -18,9 +19,18 @@
// Dashboard route (protected)
// Route::get('/dashboard', [HomeController::class, 'dashboard'])->name('dashboard')->middleware('auth');
Route::get('/dashboard', [HomeController::class, 'dashboard'])->middleware('auth')->name('dashboard');
Route::get('dashboard', [HomeController::class, 'dashboard'])->middleware('auth')->name('dashboard');
// Logout route (optional)
Route::post('/logout', [HomeController::class, 'logout'])->name('logout');
//Users
Route::get('/user-management/roles', [UserManagementController::class, 'roleAccess'])->name('user.roles');
//Role
Route::post('/user-management/assign-role', [UserManagementController::class, 'assignRole'])->name('user.assignRole');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment