MAHUI
Welcome back! Log in to your account Super Admin.
@csrf
Email address
@error('email'){{ $message }}@enderror
Password
@error('password'){{ $message }}@enderror
Remember me
{{-- --}}
Login
Not a user? Sign up
An open API service indexing awesome lists of open source software.
Starter Project adalah paket basic instalasi instan yang sudah langsung login (Multi Auth with Breeze Login Auth for Super Admin, Admin and User) tanpa setup dari awal. Starter project ini juga memiliki pilihan (Branches) untuk digunakan sesuai dengan kebutuhan anda.
https://github.com/arihidayatm/lara11-startproject
instant-apps laravel-breeze laravel-framework laravel11-starter starter-project
Last synced: 3 days ago
JSON representation
Starter Project adalah paket basic instalasi instan yang sudah langsung login (Multi Auth with Breeze Login Auth for Super Admin, Admin and User) tanpa setup dari awal. Starter project ini juga memiliki pilihan (Branches) untuk digunakan sesuai dengan kebutuhan anda.
Tutorial Starting Project in Laravel 11 use Breeze
------------------------------------------------
## 1. Create Project- create Project
``composer create-project laravel/laravel lara11-startproject``
- Install Breeze
``composer require laravel/breeze --dev``
``php artisan breeze:install``
``blade``
``no``
``1``
``php artisan serve``
------------------------------------------------------------
## 2. Create Database, configuration and migrate
- Create Database
- Configuration
// .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=projectstarter
DB_USERNAME=root
DB_PASSWORD=********- Migrate
// migration/0001_01_01_000000_create_users_table.php
{
Schema::create('users', function (Blueprint $table){
$table->id();
$table->string('name')->nullable();
$table->string('username')->nullable();
$table->string('email')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->string('photo')->nullable();
$table->string('phone')->nullable();
$table->text('address')->nullable();
$table->enum('role',['superadmin','admin','user'])->default('user');
$table->enum('status',['active','inactive'])->default('active');
$table->rememberToken();
$table->timestamp();
});
}// Models/User.php
protected $guarded = [];
``php artisan migrate``
--------------------------------------------------------------
## 3. Seeders and Factories Demo User Data
- Seeders
``php artisan make:seeder UsersTableSeeder``
public function run(): void
{
DB::table('users')->insert([
//superadmin
[
'name' => 'Super Admin',
'username' => 'superadmin',
'email' => '[email protected]',
'password' => Hash::make ('qwerty123'),
'role' => 'superadmin',
'status' => 'active',
],
//admin
[
'name' => 'Admin',
'username' => 'admin',
'email' => '[email protected]',
'password' => Hash::make ('qwerty123'),
'role' => 'admin',
'status' => 'active',
],
//user
[
'name' => 'User',
'username' => 'user',
'email' => '[email protected]',
'password' => Hash::make ('qwerty123'),
'role' => 'user',
'status' => 'active',
]
]);
}- Factories
// factories/UserFactory.php
public function definition(): array
{
return[
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('qwerty123'),
'phone' => fake()->phoneNumber,
'address' => fake()->address(),
'photo' => fake()->imageUrl('60','60'),
'role' => fake()->randomElement(['superadmin','admin','user']),
'status' => fake()->randomElement(['active','inactive']),
'remember_token' => Str::random(10),
];
}// seeders/DatabaseSeeder.php
public function run(): void
{
$this->call(UsersTableSeeder::class);
User::factory(10)->create();
}``php artisan migrate``
``php artisan migrate:fresh --seed``
--------------------------------------------------------------
## 4. Super Admin, Admin and User Multi Login System
(Multi Auth with Breeze Login Auth for Super Admin, Admin and User)``php artisan make:controller SuperAdminController``
//Controller/SuperAdminController.php
public function SuperAdminDashboard(Request, $request)
{
return view ('sadmin.dashboard');
}//routes/web.php
require __DIR__.'/auth.php';
Route::get('sadmin/dashboard',[SuperAdminController::class,'SuperAdminDashboard'])->name('sadmin.dashboard');
create folder at sadmin/dashboard.blade.php
//views/sadmin/dashboard.blade.php
``php artisan make:controller AdminController``
//Controller/AdminController.php
public function AdminDashboard(Request, $request)
{
return view ('admin.dashboard');
}//routes/web.php
Route::get('admin/dashboard',[AdminController::class,'AdminDashboard'])->name('admin.dashboard');
create folder at admin/dashboard.blade.php
//views/admin/dashboard.blade.php
``php artisan make:controller UserController``
- Multi Login System
//Controllers/Auth/AuthenticatedSessionController.php
public function store(LoginRequest $request): RedirectResponse
{
$request->authenticate();
$request->session()->regenerate();if($request->user()->role == 'superadmin')
{
return redirect()->intended('sadmin/dashboard');
}elseif($request->user()->role == 'admin')
{
return redirect()->intended('admin/dashboard');
}elseif($request->user()->role == 'user')
{
return redirect()->intended(route('dashboard', absolute: false));
}
}- Role
//Middleware/Role.php
use App\Http\Middleware\Role;
public function handle(Request $request, Closure $next, $role): Response
{
if($request->user()->role !== $role){
return redirect('dashboard');
}
return $next($request);
}//bootstrap/app.php
use App\Http\Middleware\Role;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->alias([
'role' => Role::class
]);
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();//routes/web.php
require __DIR__.'/auth.php';
Route::middleware(['auth', 'role:superadmin'])->group(function(){
Route::get('sadmin/dashboard',[SuperAdminController::class,'SuperAdminDashboard'])->name('sadmin.dashboard');
});Route::middleware(['auth', 'role:admin'])->group(function(){
Route::get('admin/dashboard',[AdminController::class,'AdminDashboard'])->name('admin.dashboard');
});------------------------------------------------------------------
## 5. Login with Name, Email and Phone
//resources/views/auth/login.blade.php
{{-- Use login with Email/Name/Phone --}}
//Http/Requests/Auth/LoginRequest.php
use App\Models\User;
public function rules(): array
{
return [
'login' => ['required', 'string'],
'password' => ['required', 'string'],
];
}public function authenticate(): void
{
$this->ensureIsNotRateLimited();$user = User::where('email', $this->login)
->orWhere('name', $this->login)
->orWhere('phone', $this->login)
->first();if (!$user || !Hash::check($this->password, $user->password))
{
RateLimiter::hit($this->throttleKey());throw ValidationException::withMessages([
'email' => trans('auth.failed'),
]);
}Auth::login($user, $this->boolean('remember'));
RateLimiter::clear($this->throttleKey());
}If you want login use login with Email/Name/Phone.
Download or clone this Branc :
[Login-with-Email-Name-Phone](https://github.com/arihidayatm/lara11-startproject/tree/Login-with-Name-and-Phone)------------------------------------------------------------------
## 6. Admin Template SetupIf you want Admin Template Setup,
- NobleUI - HTML Bootstrap 5 Admin Dashboard Template
download or clone this Branch :
[Admin-Template-Setup](https://github.com/arihidayatm/lara11-startproject/tree/Admin-Template-Setup)------------------------------------------------------------------
## 6.1 Dashboard Page SegmentationIf you want Dashboard Page Segmentation in SuperAdmin and Admin,
create folder _body at resources/views/sadmin/_body
and create file blade.php at _body for segmentation page
--sidebar.blade.php
--navbar.blade.php
--footer.blade.phpand in dashboard.blade.php at sadmin folder or admin folder
insert this code:
@include('sadmin._body.sidebar')
@include('sadmin._body.navbar')
@yield('sadmin')
@include('sadmin._body.footer')
------------------------------------------------------------------
## 6.2 SuperAdmin Logout Option
//resources/views/sadmin/_body/navbar.blade.php
navbar.blade.php
//app/Http/Controllers/SuperAdminController.php
SuperAdminController.php
public function SuperAdminLogout(Request $request)
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/login');
}
//routes/web.php
web.php
Route::get('sadmin/logout',[SuperAdminController::class,'SuperAdminLogout'])->name('sadmin.logout');
------------------------------------------------------------------
## 6.3 Costumize Login Form Super Admin
Create file sadmin-login.blade.php at resources/views/sadmin
//resources/views/sadmin/sadmin-login.blade.php
sadmin/sadmin-login.blade.php
Starter Project - Super Admin Login
//app/Http/Controllers/SuperAdminController.php
SuperAdminController.php
public function SuperAdminLogin(Request $request)
{
return view ('sadmin.sadmin-login');
}
//routes/web.php
web.php
//Super Admin Login
Route::get('sadmin/login',[SuperAdminController::class,'SuperAdminLogin'])->name('sadmin.login');
------------------------------------------------------------------
## Contributing
The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs).
- Laravel and Breeze: [Laravel Starter Kits - Breeze and Blade](https://laravel.com/docs/11.x/starter-kits#breeze-and-blade)
- Spatie: [Spatie Laravel Permission Installation](https://spatie.be/docs/laravel-permission/v6/installation-laravel)
- Tailwind CSS: [Tailwind CSS Laravel Installation](https://tailwindcss.com/docs/guides/laravel)
- Tailwind Dashboard Template: [Tailwind Dashboard Template Source](https://www.tailwindawesome.com/resources/dashboard-template)
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Muhamad Ari Hidayat via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).