Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions app/Http/Controllers/Admin/AuthController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;

class AuthController extends Controller
{
public function index()
{
return view('admin.auth.index');
}
public function login(Request $request)
{
$request->validate([
'user_name' => 'required',
'password' => 'required',
]);

$credentials = $request->only('user_name', 'password');

if (Auth::guard('admin')->attempt($credentials, $request->filled('remember'))) {
$admin = Auth::guard('admin')->user();
return redirect()->intended(route('admin.dashboard'))
->with('success', $admin->user_name . ' Login Successfully');
}

return back()->withErrors([
'user_name' => 'Invalid credentials',
])->onlyInput('user_name');
}

public function logout(Request $request)
{
Auth::guard('admin')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect()->route('admin.login');
}
}
10 changes: 1 addition & 9 deletions app/Http/Controllers/Admin/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@

class HomeController extends Controller
{
public function login()
{
return view('admin.login');
}
public function register()
{
return view('admin.register');
}
public function dashboard()
public function dashboard()
{
return view('admin.dashboard');
}
Expand Down
11 changes: 11 additions & 0 deletions app/Http/Controllers/Vendor/AuthController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Http\Controllers\Vendor;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class AuthController extends Controller
{
//
}
21 changes: 21 additions & 0 deletions app/Models/Admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class Admin extends Authenticatable
{
use Notifiable;
protected $guard = 'admin';
protected $fillable = [
'user_name',
'email',
'password',
];
protected $hidden = [
'password',
'remember_token',
];
}
42 changes: 42 additions & 0 deletions app/Models/Vendor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Session;

class Vendor extends Model
{
//
protected $fillable = [
'shop_name',
'owner_name',
'email',
'password',
'shop_contact',
'owner_contact',
'shop_logo',
'is_active',
'created_by',
'updated_by',
'deleted_by',
];
// protected static function boot()
// {
// parent::boot();
// static::creating(function ($model) {
// $model->created_by = Session::get('user')->id;
// });
// static::updating(function ($model) {
// $model->updated_by = Session::get('user')->id;
// });
// static::deleting(function ($model) {
// $model->deleted_by = Session::get('user')->id;
// $model->save();
// });
// }

protected $hidden = [
'password',
];
}
22 changes: 18 additions & 4 deletions config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],

'vendor' => [
'driver' => 'session',
'provider' => 'vendors',
],
],

/*
Expand All @@ -65,10 +74,15 @@
'model' => env('AUTH_MODEL', App\Models\User::class),
],

// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],

'vendors' => [
'driver' => 'eloquent',
'model' => App\Models\Vendor::class,
],
],

/*
Expand Down
9 changes: 9 additions & 0 deletions config/miscConstant.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
'canManage' => 'Can manage ',
'COOKIE_LIFE' => 2 * 24 * 60 * 60,
'JS_VERSION' => '1.0',
'DEACTIVATE_STATUS' => 0,
'ACTIVATE_STATUS' => 1,
];
31 changes: 31 additions & 0 deletions database/migrations/2025_08_25_120833_create_admins_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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('admins', function (Blueprint $table) {
$table->id();
$table->string('user_name')->unique();
$table->string('email')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('admins');
}
};
41 changes: 41 additions & 0 deletions database/migrations/2025_08_25_120900_create_vendors_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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('vendors', function (Blueprint $table) {
$table->id();
$table->string('shop_name')->unique();
$table->string('owner_name');
$table->string('email')->unique();
$table->string('password');
$table->string('shop_contact')->nullable();
$table->string('owner_contact')->nullable();
$table->string('address')->nullable();
$table->string('shop_logo')->nullable();
$table->boolean('is_active')->default(true);
$table->rememberToken();
$table->timestamps();
$table->integer('created_by')->default(0);
$table->integer('updated_by')->default(0);
$table->integer('deleted_by')->default(0);
$table->softDeletes();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('vendors');
}
};
17 changes: 11 additions & 6 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Database\Seeders;

use App\Models\User;
use App\Models\Admin;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
Expand All @@ -13,11 +14,15 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();

User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
$this->call([
VendorSeeder::class,
]);

// Admin::factory()->create([
// 'user_name' => 'zodibit',
// 'email' => 'queryprovider247@gmail.com',
// 'password' => Hash::make('admin786'),
// ]);
// User::factory(10)->create();
}
}
44 changes: 44 additions & 0 deletions database/seeders/VendorSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Vendor;
use Illuminate\Support\Facades\Hash;

class VendorSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Vendor::create([
'shop_name' => 'Pizzas',
'owner_name' => 'Ali Khan',
'email' => 'pizzaking@example.com',
'password' => Hash::make('vendor786'),
'shop_contact' => '03001234567',
'owner_contact' => '03111234567',
'shop_logo' => null,
'is_active' => true,
'created_by' => 1,
'updated_by' => 1,
'deleted_by' => 0,
]);

Vendor::create([
'shop_name' => 'BurgerHouse',
'owner_name' => 'Sara Ahmed',
'email' => 'burgerhouse@example.com',
'password' => Hash::make('vendor786'),
'shop_contact' => '03007654321',
'owner_contact' => '03211234567',
'shop_logo' => null,
'is_active' => true,
'created_by' => 1,
'updated_by' => 1,
'deleted_by' => 1,
]);
}
}
Loading
Loading