diff --git a/app/Http/Controllers/Admin/AdminMarkListController.php b/app/Http/Controllers/Admin/AdminMarkListController.php new file mode 100644 index 0000000..0747741 --- /dev/null +++ b/app/Http/Controllers/Admin/AdminMarkListController.php @@ -0,0 +1,34 @@ +get(); + + return view('admin.mark_list', compact('markList')); + } + + /** + * Toggle status between Active and Inactive + */ + public function toggleStatus($id) + { + $mark = MarkList::findOrFail($id); + + // Toggle logic + $mark->status = $mark->status === 'active' ? 'inactive' : 'active'; + $mark->save(); + + return redirect()->back()->with('success', 'Status updated successfully!'); + } +} diff --git a/app/Http/Controllers/MarkListController.php b/app/Http/Controllers/MarkListController.php new file mode 100644 index 0000000..9f0b733 --- /dev/null +++ b/app/Http/Controllers/MarkListController.php @@ -0,0 +1,95 @@ +validate([ + 'mark_no' => 'required|string|max:255|unique:mark_list,mark_no', + 'origin' => 'required|string|max:255', + 'destination' => 'required|string|max:255', + ]); + } catch (\Illuminate\Validation\ValidationException $e) { + // Check if the mark_no uniqueness failed + if (isset($e->validator->failed()['mark_no']['Unique'])) { + return response()->json([ + 'success' => false, + 'message' => 'Mark No already taken by another customer.' + ], 400); + } + + // Default validation error + return response()->json([ + 'success' => false, + 'message' => $e->getMessage() + ], 400); + } + + // Authenticate user via JWT + $user = JWTAuth::parseToken()->authenticate(); + + if (!$user) { + return response()->json([ + 'success' => false, + 'message' => 'Unauthorized' + ], 401); + } + + // Create mark record + $mark = MarkList::create([ + 'mark_no' => $request->mark_no, + 'origin' => $request->origin, + 'destination' => $request->destination, + 'customer_id' => $user->customer_id, + 'customer_name' => $user->customer_name, + 'company_name' => $user->company_name, + 'mobile_no' => $user->mobile_no, + 'date' => Carbon::now()->toDateString(), + 'status' => 'active', + ]); + + return response()->json([ + 'success' => true, + 'message' => 'Mark No added successfully.', + 'data' => $mark + ], 200); + } + + + /** + * Show all marks for the logged-in user + */ + public function showmarklist() + { + $user = JWTAuth::parseToken()->authenticate(); + + if (!$user) { + return response()->json([ + 'success' => false, + 'message' => 'Unauthorized' + ], 401); + } + + $marks = MarkList::where('customer_id', $user->customer_id) + ->orderBy('id', 'desc') + ->get(); + + return response()->json([ + 'success' => true, + 'data' => $marks + ]); + } +} diff --git a/app/Models/MarkList.php b/app/Models/MarkList.php index 18f3546..edd3e22 100644 --- a/app/Models/MarkList.php +++ b/app/Models/MarkList.php @@ -2,28 +2,24 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class MarkList extends Model { - protected $table = 'mark_lists'; + use HasFactory; + + protected $table = 'mark_list'; protected $fillable = [ - 'mark_no', // e.g., MARK-2025-000001 + 'mark_no', 'origin', 'destination', - 'customer_name', - 'mobile_no', 'customer_id', + 'customer_name', + 'company_name', + 'mobile_no', 'date', - 'status', + 'status' ]; - - /** - * Relationship: each mark list belongs to a customer (user) - */ - public function customer() - { - return $this->belongsTo(User::class, 'customer_id'); - } } diff --git a/database/migrations/2025_11_06_131937_create_mark_lists_table.php b/database/migrations/2025_11_06_131937_create_mark_lists_table.php deleted file mode 100644 index dda2f24..0000000 --- a/database/migrations/2025_11_06_131937_create_mark_lists_table.php +++ /dev/null @@ -1,45 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2025_11_07_105011_create_mark_list_table.php b/database/migrations/2025_11_07_105011_create_mark_list_table.php new file mode 100644 index 0000000..70c2a05 --- /dev/null +++ b/database/migrations/2025_11_07_105011_create_mark_list_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('mark_no')->unique(); + $table->string('origin'); + $table->string('destination'); + $table->string('customer_id'); + $table->string('customer_name'); + $table->string('company_name')->nullable(); + $table->string('mobile_no'); + $table->date('date')->nullable(); + $table->enum('status', ['active', 'inactive'])->default('active'); + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('mark_list'); + } +}; diff --git a/resources/views/admin/layouts/app.blade.php b/resources/views/admin/layouts/app.blade.php index 63df38f..d0c437c 100644 --- a/resources/views/admin/layouts/app.blade.php +++ b/resources/views/admin/layouts/app.blade.php @@ -85,6 +85,7 @@ Requests Staff Account + mark_list
@csrf diff --git a/resources/views/admin/login.blade.php b/resources/views/admin/login.blade.php index 452cc7e..77a0d87 100644 --- a/resources/views/admin/login.blade.php +++ b/resources/views/admin/login.blade.php @@ -2,48 +2,146 @@ Admin Login - + + +
+ + KENT Logo -
-
-
-
-
- {{-- Kent Logo --}} - KENT Logo -

Admin Login

+ +
+ KENT International Pvt. Ltd. +
+ +
+
+

Admin Login

+
+
+ @if ($errors->any()) +
+ {{ $errors->first() }} +
+ @endif + + + @csrf +
+ +
-
- @if ($errors->any()) -
- {{ $errors->first() }} -
- @endif - - - @csrf -
- - -
- -
- - -
- - - +
+ +
+ + + + +
+ + + + Secure & Encrypted
- diff --git a/resources/views/admin/mark_list.blade.php b/resources/views/admin/mark_list.blade.php new file mode 100644 index 0000000..bed6cf2 --- /dev/null +++ b/resources/views/admin/mark_list.blade.php @@ -0,0 +1,60 @@ +@extends('admin.layouts.app') + +@section('page-title', 'Mark List') + +@section('content') +
+
+

Mark List Management

+ + @if(session('success')) +
{{ session('success') }}
+ @endif + + + + + + + + + + + + + + + + + @forelse($markList as $index => $mark) + + + + + + + + + + + + @empty + + + + @endforelse + +
#Mark NoOriginDestinationCustomer NameMobileDateStatusAction
{{ $mark->id }}{{ $mark->mark_no }}{{ $mark->origin }}{{ $mark->destination }}{{ $mark->customer_name }}{{ $mark->mobile_no }}{{ \Carbon\Carbon::parse($mark->date)->format('d-m-Y') }} + @if($mark->status == 'active') + Active + @else + Inactive + @endif + + + {{ $mark->status == 'active' ? 'Deactivate' : 'Activate' }} + +
No mark numbers found.
+
+
+@endsection diff --git a/routes/api.php b/routes/api.php index fc52089..cb77329 100644 --- a/routes/api.php +++ b/routes/api.php @@ -3,10 +3,18 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\RequestController; use App\Http\Controllers\UserAuthController; +use App\Http\Controllers\MarkListController; //user send request Route::post('/signup-request', [RequestController::class, 'usersignup']); //login / logout Route::post('/user/login', [UserAuthController::class, 'login']); -Route::post('/user/logout', [UserAuthController::class, 'logout'])->middleware('auth:api'); \ No newline at end of file +Route::post('/user/logout', [UserAuthController::class, 'logout'])->middleware('auth:api'); + + + +Route::middleware(['auth:api'])->group(function () { + Route::get('/show-mark-list', [MarkListController::class, 'showmarklist']); // Fetch all marks by user + Route::post('/add-mark-no', [MarkListController::class, 'addmarkno']); // Create new mark +}); diff --git a/routes/web.php b/routes/web.php index 38881e1..5e7ad98 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,6 +3,7 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\Admin\AdminAuthController; use App\Http\Controllers\Admin\UserRequestController; +use App\Http\Controllers\Admin\AdminMarkListController; // ------------------------- // Default Front Page @@ -34,9 +35,14 @@ Route::prefix('admin')->middleware('auth:admin')->group(function () { Route::get('/orders', fn() => view('admin.orders'))->name('admin.orders'); Route::get('/staff', fn() => view('admin.staff'))->name('admin.staff'); 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'); + + //mark list show + Route::get('/mark-list', [AdminMarkListController::class, 'index'])->name('admin.marklist.index'); + Route::get('/mark-list/status/{id}', [AdminMarkListController::class, 'toggleStatus'])->name('admin.marklist.toggle'); });