You will learn here how to create a project and connect it to the database.

Unknown

Im assuming here you have a basic setup which includes:

  • composer globally installed
  • mysql installed

Lets create new empty laravel project i will call my one redirect-panel

 composer create-project laravel/laravel redirect-panel

Enter folder and add ui package i know a bit of bootstrap so i'll use that

cd redirect-panel
composer require laravel/ui
php artisan ui bootstrap --auth

Now let's add debug bard to our dev environment.

composer require barryvdh/laravel-debugbar --dev

Now we need to setup .env file

cp .env.example .env
nano .env

Inside .env edit those lines

APP_NAME="Your app Name"

DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

QUEUE_CONNECTION=database

Generate key and enter mysql console

php artisan key:generate
sudo mysql

Now inside mysql we will create db called whatever you want i'll call my one redirectpanel

create database redirectpanel

Create user and password

 grant all on redirectpanel.* to redirectpanel@localhost identified by 'redirectpanel';

Now refresh privileges and exit

flush privileges;
\q

Now you can try to migrate your base and if all done corectly we should get no error.

php artisan migrate

All looks good now to make setup more final we will set ques table and we will add an admin user to our user's migration.

php artisan queue:table

Find an user migration usually in Database->migration -> _create_users_table.php an modify

//Remember to import Carbon and DB Class
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;

// Create default admin
DB::table('users')->insert([
	'name' => 'Administrator Admin',
	'email' => '[email protected]',
	'password' => Hash::make('admin'),
	'created_at' => Carbon::now(),
	'updated_at' => Carbon::now(),
]);

And run migration again that should create jobs table and admin user so you can login

php artisan migrate:fresh

Test run the server by

php artisan serve