request Model is added
This commit is contained in:
@@ -1,41 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use App\Models\Admin;
|
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use App\Models\Admin;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AdminAuthController extends Controller
|
class AdminAuthController extends Controller
|
||||||
{
|
{
|
||||||
// 🟢 Show login form
|
/**
|
||||||
|
* Show the admin login page
|
||||||
|
*/
|
||||||
public function showLoginForm()
|
public function showLoginForm()
|
||||||
{
|
{
|
||||||
return view('admin.login');
|
return view('admin.login');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🟢 Handle login request
|
/**
|
||||||
|
* Handle admin login
|
||||||
|
*/
|
||||||
public function login(Request $request)
|
public function login(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'email' => 'required|email',
|
'email' => 'required|email',
|
||||||
'password' => 'required|min:6',
|
'password' => 'required|string|min:6',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$credentials = $request->only('email', 'password');
|
// Try to log in using the 'admin' guard
|
||||||
|
if (Auth::guard('admin')->attempt($request->only('email', 'password'))) {
|
||||||
if (Auth::guard('admin')->attempt($credentials)) {
|
return redirect()->route('admin.dashboard')->with('success', 'Welcome back, Admin!');
|
||||||
return redirect()->route('admin.dashboard')->with('success', 'Login successful!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return back()->withErrors(['email' => 'Invalid credentials.'])->withInput();
|
return back()->withErrors(['email' => 'Invalid email or password.']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🟢 Logout
|
/**
|
||||||
|
* Logout admin
|
||||||
|
*/
|
||||||
public function logout(Request $request)
|
public function logout(Request $request)
|
||||||
{
|
{
|
||||||
Auth::guard('admin')->logout();
|
Auth::guard('admin')->logout();
|
||||||
|
|
||||||
|
// Destroy the session completely
|
||||||
$request->session()->invalidate();
|
$request->session()->invalidate();
|
||||||
$request->session()->regenerateToken();
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
68
app/Http/Controllers/Admin/UserRequestController.php
Normal file
68
app/Http/Controllers/Admin/UserRequestController.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\RequestModel as CustomerRequest;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class UserRequestController extends Controller
|
||||||
|
{
|
||||||
|
// Show all requests
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$requests = CustomerRequest::orderBy('id', 'desc')->get();
|
||||||
|
return view('admin.requests', compact('requests'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Approve user request
|
||||||
|
public function approve($id)
|
||||||
|
{
|
||||||
|
$requestData = CustomerRequest::findOrFail($id);
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
// Generate unique Customer ID
|
||||||
|
$latestUser = User::orderBy('id', 'desc')->first();
|
||||||
|
$nextId = $latestUser ? $latestUser->id + 1 : 1;
|
||||||
|
$customerId = 'CID-' . date('Y') . '-' . str_pad($nextId, 6, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
|
// Create user record
|
||||||
|
$user = new User();
|
||||||
|
$user->customer_id = $customerId;
|
||||||
|
$user->customer_name = $requestData->customer_name;
|
||||||
|
$user->company_name = $requestData->company_name;
|
||||||
|
$user->designation = $requestData->designation;
|
||||||
|
$user->email = $requestData->email;
|
||||||
|
$user->mobile_no = $requestData->mobile_no;
|
||||||
|
$user->address = $requestData->address;
|
||||||
|
$user->pincode = $requestData->pincode;
|
||||||
|
$user->date = now()->format('Y-m-d');
|
||||||
|
$user->password = Hash::make('123456'); // default password (you can change logic)
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
// Update request status
|
||||||
|
$requestData->status = 'approved';
|
||||||
|
$requestData->save();
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return redirect()->back()->with('success', 'Request approved and user created successfully.');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollback();
|
||||||
|
return redirect()->back()->with('error', 'Something went wrong: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject request
|
||||||
|
public function reject($id)
|
||||||
|
{
|
||||||
|
$requestData = CustomerRequest::findOrFail($id);
|
||||||
|
$requestData->status = 'rejected';
|
||||||
|
$requestData->save();
|
||||||
|
|
||||||
|
return redirect()->back()->with('info', 'Request rejected successfully.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Support\Facades\Hash;
|
|
||||||
use PHPOpenSourceSaver\JWTAuth\Facades\JWTAuth;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class AuthController extends Controller
|
|
||||||
{
|
|
||||||
// ✅ Register
|
|
||||||
public function register(Request $request)
|
|
||||||
{
|
|
||||||
$request->validate([
|
|
||||||
'name' => 'required|string|max:255',
|
|
||||||
'email' => 'required|string|email|unique:users',
|
|
||||||
'password' => 'required|string|min:6',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$user = User::create([
|
|
||||||
'name' => $request->name,
|
|
||||||
'email' => $request->email,
|
|
||||||
'password' => Hash::make($request->password),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$token = JWTAuth::fromUser($user);
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'status' => true,
|
|
||||||
'message' => 'User registered successfully',
|
|
||||||
'user' => $user,
|
|
||||||
'token' => $token
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ✅ Login
|
|
||||||
public function login(Request $request)
|
|
||||||
{
|
|
||||||
$credentials = $request->only('email', 'password');
|
|
||||||
|
|
||||||
if (!$token = Auth::guard('api')->attempt($credentials)) {
|
|
||||||
return response()->json(['error' => 'Invalid credentials'], 401);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'status' => true,
|
|
||||||
'message' => 'Login successful',
|
|
||||||
'token' => $token,
|
|
||||||
'user' => Auth::guard('api')->user()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ✅ Logout
|
|
||||||
public function logout()
|
|
||||||
{
|
|
||||||
Auth::guard('api')->logout();
|
|
||||||
return response()->json(['message' => 'Successfully logged out']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ✅ Refresh token
|
|
||||||
public function refresh()
|
|
||||||
{
|
|
||||||
return response()->json([
|
|
||||||
'token' => Auth::guard('api')->refresh()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
56
app/Http/Controllers/RequestController.php
Normal file
56
app/Http/Controllers/RequestController.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\RequestModel;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class RequestController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle new user signup request (registration request)
|
||||||
|
*/
|
||||||
|
public function usersignup(Request $request)
|
||||||
|
{
|
||||||
|
// ✅ Validate user input
|
||||||
|
$request->validate([
|
||||||
|
'customer_name' => 'required|string|max:255',
|
||||||
|
'company_name' => 'required|string|max:255',
|
||||||
|
'designation' => 'nullable|string|max:255',
|
||||||
|
'email' => 'required|email|unique:requests,email',
|
||||||
|
'mobile_no' => 'required|string|max:15',
|
||||||
|
'priority' => 'nullable|string|max:50',
|
||||||
|
'address' => 'nullable|string',
|
||||||
|
'pincode' => 'nullable|string|max:10',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// ✅ Generate formatted request ID (e.g., REQ-2025-000001)
|
||||||
|
$lastRequest = RequestModel::latest('id')->first();
|
||||||
|
$nextId = $lastRequest ? $lastRequest->id + 1 : 1;
|
||||||
|
$year = date('Y');
|
||||||
|
$formattedRequestId = sprintf('REQ-%s-%06d', $year, $nextId);
|
||||||
|
|
||||||
|
// ✅ Create new request entry
|
||||||
|
$newRequest = RequestModel::create([
|
||||||
|
'request_id' => $formattedRequestId,
|
||||||
|
'customer_name' => $request->customer_name,
|
||||||
|
'company_name' => $request->company_name,
|
||||||
|
'designation' => $request->designation,
|
||||||
|
'email' => $request->email,
|
||||||
|
'mobile_no' => $request->mobile_no,
|
||||||
|
'priority' => $request->priority,
|
||||||
|
'address' => $request->address,
|
||||||
|
'pincode' => $request->pincode,
|
||||||
|
'date' => Carbon::now()->toDateString(), // Auto current date
|
||||||
|
'status' => 'pending', // Default status
|
||||||
|
]);
|
||||||
|
|
||||||
|
// ✅ Response
|
||||||
|
return response()->json([
|
||||||
|
'status' => true,
|
||||||
|
'message' => 'Signup request submitted successfully. Please wait for admin approval.',
|
||||||
|
'data' => $newRequest
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
82
app/Http/Controllers/UserAuthController.php
Normal file
82
app/Http/Controllers/UserAuthController.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use PHPOpenSourceSaver\JWTAuth\Facades\JWTAuth;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class UserAuthController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* User Login
|
||||||
|
*/
|
||||||
|
public function login(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'login_id' => 'required|string', // can be email, mobile, or customer_id
|
||||||
|
'password' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Find user by email OR mobile_no OR customer_id
|
||||||
|
$user = User::where('email', $request->login_id)
|
||||||
|
->orWhere('mobile_no', $request->login_id)
|
||||||
|
->orWhere('customer_id', $request->login_id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'User not found with given credentials.',
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check hashed password
|
||||||
|
if (!Hash::check($request->password, $user->password)) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Incorrect password.',
|
||||||
|
], 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate JWT token
|
||||||
|
$token = JWTAuth::fromUser($user);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Login successful.',
|
||||||
|
'token' => $token,
|
||||||
|
'user' => [
|
||||||
|
'id' => $user->id,
|
||||||
|
'customer_id' => $user->customer_id,
|
||||||
|
'customer_name' => $user->customer_name,
|
||||||
|
'company_name' => $user->company_name,
|
||||||
|
'email' => $user->email,
|
||||||
|
'mobile_no' => $user->mobile_no,
|
||||||
|
'address' => $user->address,
|
||||||
|
'pincode' => $user->pincode,
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Logout
|
||||||
|
*/
|
||||||
|
public function logout(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
JWTAuth::invalidate(JWTAuth::getToken());
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Logout successful.',
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Failed to logout. Token may be invalid or expired.',
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Models/MarkList.php
Normal file
29
app/Models/MarkList.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class MarkList extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'mark_lists';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'mark_no', // e.g., MARK-2025-000001
|
||||||
|
'origin',
|
||||||
|
'destination',
|
||||||
|
'customer_name',
|
||||||
|
'mobile_no',
|
||||||
|
'customer_id',
|
||||||
|
'date',
|
||||||
|
'status',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relationship: each mark list belongs to a customer (user)
|
||||||
|
*/
|
||||||
|
public function customer()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'customer_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Models/RequestModel.php
Normal file
24
app/Models/RequestModel.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class RequestModel extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'requests';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'request_id', // ✅ custom formatted ID like REQ-2025-000001
|
||||||
|
'customer_name',
|
||||||
|
'company_name',
|
||||||
|
'designation',
|
||||||
|
'email',
|
||||||
|
'mobile_no',
|
||||||
|
'priority',
|
||||||
|
'address',
|
||||||
|
'pincode',
|
||||||
|
'date',
|
||||||
|
'status',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -11,17 +11,33 @@ class User extends Authenticatable implements JWTSubject
|
|||||||
{
|
{
|
||||||
use HasFactory, Notifiable;
|
use HasFactory, Notifiable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'customer_id', // CID-2025-000001 format
|
||||||
|
'customer_name',
|
||||||
|
'company_name',
|
||||||
|
'designation',
|
||||||
'email',
|
'email',
|
||||||
|
'mobile_no',
|
||||||
|
'address',
|
||||||
|
'pincode',
|
||||||
|
'date',
|
||||||
'password',
|
'password',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for arrays.
|
||||||
|
*/
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'password',
|
'password',
|
||||||
'remember_token',
|
'remember_token',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast.
|
||||||
|
*/
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -30,12 +46,17 @@ class User extends Authenticatable implements JWTSubject
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🔑 Required for JWT
|
/**
|
||||||
|
* JWT Identifier.
|
||||||
|
*/
|
||||||
public function getJWTIdentifier()
|
public function getJWTIdentifier()
|
||||||
{
|
{
|
||||||
return $this->getKey();
|
return $this->getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JWT Custom Claims.
|
||||||
|
*/
|
||||||
public function getJWTCustomClaims()
|
public function getJWTCustomClaims()
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@@ -11,22 +11,38 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
// USERS TABLE
|
||||||
Schema::create('users', function (Blueprint $table) {
|
Schema::create('users', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id(); // Auto-increment primary key
|
||||||
$table->string('name');
|
|
||||||
|
// Custom customer ID like CID-2025-000001
|
||||||
|
$table->string('customer_id')->unique();
|
||||||
|
|
||||||
|
// Customer details
|
||||||
|
$table->string('customer_name');
|
||||||
|
$table->string('company_name');
|
||||||
|
$table->string('designation')->nullable();
|
||||||
$table->string('email')->unique();
|
$table->string('email')->unique();
|
||||||
|
$table->string('mobile_no');
|
||||||
|
$table->string('address')->nullable();
|
||||||
|
$table->string('pincode')->nullable();
|
||||||
|
$table->date('date')->nullable();
|
||||||
|
|
||||||
|
// Authentication fields
|
||||||
$table->timestamp('email_verified_at')->nullable();
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
$table->string('password');
|
$table->string('password')->nullable();
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// PASSWORD RESETS TABLE
|
||||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||||
$table->string('email')->primary();
|
$table->string('email')->primary();
|
||||||
$table->string('token');
|
$table->string('token');
|
||||||
$table->timestamp('created_at')->nullable();
|
$table->timestamp('created_at')->nullable();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// SESSIONS TABLE
|
||||||
Schema::create('sessions', function (Blueprint $table) {
|
Schema::create('sessions', function (Blueprint $table) {
|
||||||
$table->string('id')->primary();
|
$table->string('id')->primary();
|
||||||
$table->foreignId('user_id')->nullable()->index();
|
$table->foreignId('user_id')->nullable()->index();
|
||||||
@@ -42,8 +58,8 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('users');
|
|
||||||
Schema::dropIfExists('password_reset_tokens');
|
|
||||||
Schema::dropIfExists('sessions');
|
Schema::dropIfExists('sessions');
|
||||||
|
Schema::dropIfExists('password_reset_tokens');
|
||||||
|
Schema::dropIfExists('users');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?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()
|
||||||
|
{
|
||||||
|
Schema::create('mark_lists', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
// Order as requested:
|
||||||
|
$table->string('mark_no');
|
||||||
|
$table->string('origin');
|
||||||
|
$table->string('destination');
|
||||||
|
$table->string('customer_name');
|
||||||
|
$table->string('mobile_no');
|
||||||
|
$table->unsignedBigInteger('customer_id');
|
||||||
|
$table->date('date')->nullable();
|
||||||
|
$table->enum('status', ['active', 'inactive'])->default('active');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
// Foreign key constraint
|
||||||
|
$table->foreign('customer_id')
|
||||||
|
->references('id')
|
||||||
|
->on('users')
|
||||||
|
->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('mark_lists');
|
||||||
|
}
|
||||||
|
};
|
||||||
BIN
public/img/kent-logo.png
Normal file
BIN
public/img/kent-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
@@ -5,13 +5,19 @@
|
|||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-light">
|
<body class="bg-light">
|
||||||
|
|
||||||
<div class="container mt-5">
|
<div class="container mt-5">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card shadow">
|
<div class="card shadow">
|
||||||
<div class="card-header text-center bg-primary text-white">
|
<div class="card-header text-center bg-primary text-white">
|
||||||
<h4>Admin Login</h4>
|
{{-- Kent Logo --}}
|
||||||
|
<img src="{{ asset('img/kent-logo.png') }}"
|
||||||
|
alt="KENT Logo"
|
||||||
|
style="max-width: 140px; margin-bottom: 8px;">
|
||||||
|
<h4 class="mt-2">Admin Login</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
@@ -38,5 +44,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -4,45 +4,73 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-body">
|
<div class="card-header bg-primary text-white">
|
||||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
<h5 class="mb-0">Pending User Requests</h5>
|
||||||
<input type="text" class="form-control w-50" placeholder="Search Request by name, email, company or ID">
|
|
||||||
<div>
|
|
||||||
<span class="badge bg-primary">3 Pending</span>
|
|
||||||
<span class="badge bg-success">1 Approved</span>
|
|
||||||
<span class="badge bg-danger">1 Rejected</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
@if(session('success'))
|
||||||
|
<div class="alert alert-success">{{ session('success') }}</div>
|
||||||
|
@elseif(session('error'))
|
||||||
|
<div class="alert alert-danger">{{ session('error') }}</div>
|
||||||
|
@elseif(session('info'))
|
||||||
|
<div class="alert alert-info">{{ session('info') }}</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<table class="table table-bordered align-middle">
|
<table class="table table-bordered table-striped">
|
||||||
<thead class="table-light">
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Request ID</th>
|
<th>#</th>
|
||||||
<th>Requester</th>
|
<th>Request ID</th>
|
||||||
<th>Company</th>
|
<th>Name</th>
|
||||||
<th>Type</th>
|
<th>Company</th>
|
||||||
<th>Priority</th>
|
<th>Email</th>
|
||||||
<th>Date</th>
|
<th>Mobile</th>
|
||||||
<th>Status</th>
|
<th>Address</th>
|
||||||
<th>Actions</th>
|
<th>Priority</th>
|
||||||
</tr>
|
<th>Date</th>
|
||||||
</thead>
|
<th>Status</th>
|
||||||
<tbody>
|
<th>Actions</th>
|
||||||
<tr>
|
</tr>
|
||||||
<td>REQ-2024-001</td>
|
</thead>
|
||||||
<td>Amit Patel<br><small>amit.patel@example.com</small></td>
|
<tbody>
|
||||||
<td>Tech Solutions Pvt. Ltd.</td>
|
@forelse($requests as $req)
|
||||||
<td><span class="badge bg-info text-dark">New Account</span></td>
|
<tr>
|
||||||
<td><span class="badge bg-danger">High</span></td>
|
<td>{{ $req->id }}</td>
|
||||||
<td>2024-09-01</td>
|
<td>{{ $req->request_id }}</td>
|
||||||
<td><span class="badge bg-warning text-dark">Pending</span></td>
|
<td>{{ $req->customer_name }}</td>
|
||||||
<td>
|
<td>{{ $req->company_name }}</td>
|
||||||
<i class="bi bi-eye text-primary"></i>
|
<td>{{ $req->email }}</td>
|
||||||
<i class="bi bi-x-circle text-danger ms-2"></i>
|
<td>{{ $req->mobile_no }}</td>
|
||||||
</td>
|
<td>{{ $req->address }}</td>
|
||||||
</tr>
|
<td>{{ $req->priority }}</td>
|
||||||
</tbody>
|
<td>{{ $req->date }}</td>
|
||||||
</table>
|
<td>
|
||||||
</div>
|
@if($req->status == 'approved')
|
||||||
|
<span class="badge bg-success">Approved</span>
|
||||||
|
@elseif($req->status == 'rejected')
|
||||||
|
<span class="badge bg-danger">Rejected</span>
|
||||||
|
@else
|
||||||
|
<span class="badge bg-warning text-dark">Pending</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@if($req->status == 'pending' || $req->status == null)
|
||||||
|
<a href="{{ route('admin.requests.approve', $req->id) }}"
|
||||||
|
class="btn btn-success btn-sm">Approve</a>
|
||||||
|
<a href="{{ route('admin.requests.reject', $req->id) }}"
|
||||||
|
class="btn btn-danger btn-sm">Reject</a>
|
||||||
|
@else
|
||||||
|
<em>N/A</em>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="8" class="text-center">No requests found</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use App\Http\Controllers\AuthController;
|
use App\Http\Controllers\RequestController;
|
||||||
|
use App\Http\Controllers\UserAuthController;
|
||||||
|
|
||||||
Route::post('/register', [AuthController::class, 'register']);
|
//user send request
|
||||||
Route::post('/login', [AuthController::class, 'login']);
|
Route::post('/signup-request', [RequestController::class, 'usersignup']);
|
||||||
|
|
||||||
Route::middleware('auth:api')->group(function () {
|
//login / logout
|
||||||
Route::post('/logout', [AuthController::class, 'logout']);
|
Route::post('/user/login', [UserAuthController::class, 'login']);
|
||||||
Route::post('/refresh', [AuthController::class, 'refresh']);
|
Route::post('/user/logout', [UserAuthController::class, 'logout'])->middleware('auth:api');
|
||||||
});
|
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use App\Http\Controllers\AdminAuthController;
|
use App\Http\Controllers\Admin\AdminAuthController;
|
||||||
|
use App\Http\Controllers\Admin\UserRequestController;
|
||||||
|
|
||||||
// Default welcome page
|
// -------------------------
|
||||||
|
// Default Front Page
|
||||||
|
// -------------------------
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
return view('welcome');
|
return view('welcome');
|
||||||
});
|
});
|
||||||
@@ -12,15 +15,16 @@ Route::get('/', function () {
|
|||||||
// Admin Authentication Routes
|
// Admin Authentication Routes
|
||||||
// -------------------------
|
// -------------------------
|
||||||
Route::prefix('admin')->group(function () {
|
Route::prefix('admin')->group(function () {
|
||||||
Route::get('/login', [AdminAuthController::class, 'showLoginForm'])->name('admin.login');
|
Route::get('login', [AdminAuthController::class, 'showLoginForm'])->name('admin.login');
|
||||||
Route::post('/login', [AdminAuthController::class, 'login'])->name('admin.login.submit');
|
Route::post('login', [AdminAuthController::class, 'login'])->name('admin.login.submit');
|
||||||
Route::post('/logout', [AdminAuthController::class, 'logout'])->name('admin.logout');
|
Route::post('logout', [AdminAuthController::class, 'logout'])->name('admin.logout');
|
||||||
});
|
});
|
||||||
|
|
||||||
// -------------------------
|
// -------------------------
|
||||||
// Protected Admin Panel Routes
|
// Protected Admin Routes
|
||||||
// -------------------------
|
// -------------------------
|
||||||
Route::prefix('admin')->middleware('auth:admin')->group(function () {
|
Route::prefix('admin')->middleware('auth:admin')->group(function () {
|
||||||
|
// Dashboard Pages
|
||||||
Route::get('/dashboard', fn() => view('admin.dashboard'))->name('admin.dashboard');
|
Route::get('/dashboard', fn() => view('admin.dashboard'))->name('admin.dashboard');
|
||||||
Route::get('/shipments', fn() => view('admin.shipments'))->name('admin.shipments');
|
Route::get('/shipments', fn() => view('admin.shipments'))->name('admin.shipments');
|
||||||
Route::get('/invoice', fn() => view('admin.invoice'))->name('admin.invoice');
|
Route::get('/invoice', fn() => view('admin.invoice'))->name('admin.invoice');
|
||||||
@@ -28,7 +32,11 @@ Route::prefix('admin')->middleware('auth:admin')->group(function () {
|
|||||||
Route::get('/reports', fn() => view('admin.reports'))->name('admin.reports');
|
Route::get('/reports', fn() => view('admin.reports'))->name('admin.reports');
|
||||||
Route::get('/chat-support', fn() => view('admin.chat_support'))->name('admin.chat_support');
|
Route::get('/chat-support', fn() => view('admin.chat_support'))->name('admin.chat_support');
|
||||||
Route::get('/orders', fn() => view('admin.orders'))->name('admin.orders');
|
Route::get('/orders', fn() => view('admin.orders'))->name('admin.orders');
|
||||||
Route::get('/requests', fn() => view('admin.requests'))->name('admin.requests');
|
|
||||||
Route::get('/staff', fn() => view('admin.staff'))->name('admin.staff');
|
Route::get('/staff', fn() => view('admin.staff'))->name('admin.staff');
|
||||||
Route::get('/account', fn() => view('admin.account'))->name('admin.account');
|
Route::get('/account', fn() => view('admin.account'))->name('admin.account');
|
||||||
|
|
||||||
|
// ✅ User Requests Controller Routes
|
||||||
|
Route::get('/requests', [UserRequestController::class, 'index'])->name('admin.requests');
|
||||||
|
Route::get('/requests/approve/{id}', [UserRequestController::class, 'approve'])->name('admin.requests.approve');
|
||||||
|
Route::get('/requests/reject/{id}', [UserRequestController::class, 'reject'])->name('admin.requests.reject');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user