[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

Laravel Admin setup method

Hello!

My name is Matsuki from the System Development Department.

In this article, we will talk about setting up Laravel Admin!

What is Laravel Admin?

Laravel Admin is an administrator tool developed using the Laravel framework.

You can easily create application management dashboards and control panels.

You can use Laravel Admin to manage various data and resources.

environment

Docker: 23.0.1

Laravel: 10.37.1

PHP: 8.2

MySQL: 8.0

Nginx: 1.23.3

Setup instructions

Login screen display

Run the command below to install Laravel Admin.

composer require encore/laravel-admin

Next, use the command below to add the installed Laravel Admin files to the Laravel project.

php artisan vendor:publish --provider="Encore\Admin\AdminServiceProvider"

Next, use the command below to create a standard table in Laravel Admin.

php artisan admin:install

If the above command is executed successfully, the following will be displayed and the creation of the standard table is complete.

root@d816ac03c504:/var/www/html# php artisan admin:install INFO Preparing database. Creating migration table ...... ................................................... ................................ 126ms DONE INFO Running migrations. 2014_10_12_000000_create_users_table .......... ................................................... ...................................... 133ms DONE 2014_10_12_100000_create_password_reset_tokens_table ...... ................................................... ...................... 190ms DONE 2016_01_04_173148_create_admin_tables ...... ................................................... ................................ 976ms DONE 2019_08_19_000000_create_failed_jobs_table .......... ................................................... ...... 101ms DONE 2019_12_14_000001_create_personal_access_tokens_table ................................ ................................................... .. 147ms DONE INFO Seeding database. Admin directory was created: /app/Admin HomeController file was created: /app/Admin/Controllers/HomeController.php AuthController file was created: /app/Admin/Controllers/AuthController.php ExampleController file was created: /app/Admin/Controllers/ExampleController.php Bootstrap file was created: /app/Admin/bootstrap.php Routes file was created: /app/Admin/routes.php

Once you have done this, try accessing the Laravel-Admin login screen.

If the access is successful, the following screen will be displayed.

Create administrator user

I have completed displaying the login screen, but I have not been able to create the important login user.

The next step is to create an administrator user to log in.

First, create a suitable seeder.

This time, we will create it with the name UserSeeder, so run the following command.

php artisan make:seeder UserSeeder

Next, in order to use the seeder under the vendor, the process described in the seeder created is

Open the /vendor/encore/laravel-admin/src/Auth/Database/AdminTablesSeeder.php file and copy the contents of public function run(){}.

Replace the copied content inside UserSeeder's public function run(){}

The replaced contents are as follows.

<?php namespace Database\Seeders; use Encore\Admin\Auth\Database\Administrator; use Encore\Admin\Auth\Database\Menu; use Encore\Admin\Auth\Database\Permission; use Encore\Admin\Auth\Database\Role; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\Hash; class UserSeeder extends Seeder { /** * Run the database seeds. */ public function run() { // create a user. Administrator::truncate(); Administrator::create([ 'username' => 'admin', 'password' => Hash::make('admin'), 'name' => 'Administrator', ]); // create a role. Role::truncate(); Role::create([ 'name' => 'Administrator', 'slug' => 'administrator', ]); // add role to user. Administrator::first()->roles()->save(Role::first()) ; //create a permission Permission::truncate(); Permission::insert([ [ 'name' => 'All permission', 'slug' => '*', 'http_method' => '', 'http_path' => '*', ], [ 'name' => 'Dashboard', 'slug' => 'dashboard', 'http_method' => 'GET', 'http_path' => '/', ], [ 'name ' => 'Login', 'slug' => 'auth.login', 'http_method' => '', 'http_path' => "/auth/login\r\n/auth/logout", ], [ ' name' => 'User setting', 'slug' => 'auth.setting', 'http_method' => 'GET,PUT', 'http_path' => '/auth/setting', ], [ 'name' = > 'Auth management', 'slug' => 'auth.management', 'http_method' => '', 'http_path' => "/auth/roles\r\n/auth/permissions\r\n/auth/ menu\r\n/auth/logs", ], ]); Role::first()->permissions()->save(Permission::first()); // add default menus. Menu::truncate( ); Menu::insert([ [ 'parent_id' => 0, 'order' => 1, 'title' => 'Dashboard', 'icon' => 'fa-bar-chart', 'uri' => '/', ], [ 'parent_id' => 0, 'order' => 2, 'title' => 'Admin', 'icon' => 'fa-tasks', 'uri' => '', ] , [ 'parent_id' => 2, 'order' => 3, 'title' => 'Users', 'icon' => 'fa-users', 'uri' => 'auth/users', ], [ 'parent_id' => 2, 'order' => 4, 'title' => 'Roles', 'icon' => 'fa-user', 'uri' => 'auth/roles', ], [ 'parent_id ' => 2, 'order' => 5, 'title' => 'Permission', 'icon' => 'fa-ban', 'uri' => 'auth/permissions', ], [ 'parent_id' = > 2, 'order' => 6, 'title' => 'Menu', 'icon' => 'fa-bars', 'uri' => 'auth/menu', ], [ 'parent_id' => 2 , 'order' => 7, 'title' => 'Operation log', 'icon' => 'fa-history', 'uri' => 'auth/logs', ], ]); // add role to menu. Menu::find(2)->roles()->save(Role::first()); } }

Next, write the UserSeeder you created in the DatabaseSeeder.

<?php namespace Database\Seeders; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder { /** * Seed the application's database. */ public function run(): void { $this-> call([ UserSeeder::class, ]); } }

Once you've done this, all you have to do is turn the seeder.

php artisan db:seed

Once the seeder is running, go to the login screen again and enter the Username and Password that you set in the seeder.

This time, both the Username and Password are registered as admin, so please change them when actually using them.

If you enter admin in both cases and log in, you will be redirected to a screen like the one below.

It is now possible to log in normally.

Laravel Admin setup is now complete.

summary

What did you think?

Laravel Admin is very easy to set up and allows you to quickly build an admin panel.

Also, if you create a table with Laravel Admin, you can operate the table with the GUI.

Please try using it.

lastly

We have opened the service site "SEKARAKU Lab" for the system development department to which I belong.
Beyond is a one-stop service for everything from server design and construction to operation, so if you have any trouble with server-side development, please feel free to contact us.

● SEKARAKU Lab: https://sekarakulab.beyondjapan.com

If you found this article helpful , please give it a like!
2
Loading...
2 votes, average: 1.00 / 12
1,590
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

Matsuki

I like poker and rugby.
MARVEL likes “Hulk”

My motto is concentration x time + luck