Laravel Jetstream B2B Project Setup
Laravel Jetstream B2B Project Setup
Then we go into the folder workshop and we control the Laravel version:
cd workshop
cat composer.json
STEP 2
We create a MySQL database with the name workshop.
STEP 3
Then we edit the environtmen file .env to set the database settings:
I am using vim here for editing the file, but you can also do it in your editor.
STEP 4
Then we run php artisan migrate and after that we have our 5 standard Laravel tables:
We now can run php artisan serve to see our page in the frontend under:
http://127.0.0.1:8000
https://laravel.com/docs/8.x/starter-kits
But there is also a dedicated web page only for Laravel Jetstream:
https://jetstream.laravel.com/2.x/installation.html
This error means that Laravel Jetstream needs a session table to work.
We can fix this easily by opening a new terminal tab or window and the we run:
php artisan migrate
The output tells us, that there is a new sessions table, but also something was added to our
users table:
We will talk about the sessions table and about the Two Factor Authentication later in this
course series!
See also here: https://jetstream.laravel.com/2.x/features/two-factor-authentication.html
git init
git add -A
git commit -m "Laravel and Jetstream installed"
We can then also open the project folder in the source tree application, go to the master
branch and there we see our commits on most recent changes in the project:
We now can register a new user with the register-link on the top right:
Then we open the project in our editor and search for the file dashboard.blade.php
(in PhpStorm you can use double shift for the search)
In this file you can see that a layout file was used and also that our actual content "hides"
behind <x-jet-welcome>
/resources/vendor/jetstream/components/welcome.blade.php
After we done the Deletions the Dashboard page should look like this:
git add -A
git commit -m "Publish Jetstream Components & Change dashboard page"
In this lecture we will change the standard Jetstream Logos, we will install a favicon and we
will also change the App Title that is for example visible in your Browser Tab:
Please note that the new Logos and the new favicon is included in the download
section of your course lecture!
PREPARATION
1. Please create a subfolder img inside your public folder.
2. Then place the 2 attached images inside this new folder.
After you did this you might want to have a look on this page:
https://jetstream.laravel.com/2.x/installation.html#livewire
Here you see the 3 files where the current logos are located:
5.1 Change the large logo on the dashboard page (after Login)
In application-logo.blade.php you delete the SVG that is there and simply replace it by the
new logo image file:
<img src="/img/RealEstate.png" alt="Application Logo">
2. To make sure that the new logo has the correct size, you use the classes w-16 h-16
that were already used in the SVG:
<a href="/">
<img class="w-16 h-16" src="/img/flash.png" alt="Flash Logo">
</a>
Now the new Logo is visible on the login and registration page and has the correct size:
5.3 Change the logo on the dashboard page on the top left
What we are doing here is not only to change the logo on the dashboard page, but actually
on ALL pages that use the main Layout for logged in users.
So in the file application-mark-blade.php we replace the SVG, again with same png:
<img class="w-auto h-9" src="/img/flash.png" alt="Flash Logo">
Please be aware that here we also used the 2 classes that the SVG had before
(w-auto and h-9)
Here is just a little difference to the other Logo in the last example. The classes were not
directly applied in the SVG, but they were passed to the Component in the SVG by the
including file (navigation-menu.blade.php)
Therefore - in the course lecture - we had to find out those classes with the Google Chrome
Inspector.
After we replaced the Logo we see it on all pages for logged in users:
There are 2 layout files that we have to consider. Both of these files are located in the folder
/resources/views/layouts:
In both files we place the favicon in the head section like so:
Please be aware that in Laravel we have this kind of "cascading system" for Definitions like
e.g. the App name.
That means that the configuration value for the app name checks if there is an app name
set in the .env file.
Only if APP_NAME is NOT set in the .env file then the default value (Laravel) is used!
Another example for this system you can find in the template file app.blade.php:
Here again - the value config('app.name') is used to determine the title for the document. But
in case this value is NOT set (in /config/app.php), then the default of "Laravel" is used.
Later in this course I will show you how to use the extended color palette!
The new field should be nullable(), so we do not get an error, when the field for some users
is empty.
Then we run php artisan migrate:fresh and we have our new field in the DB table:
As you can see, the DatabaseSeeder can call other seeders or directly a factory. Also the
other seeders can call factories.
Step 1: In the file DatabaseSeeder.php you just delete the comment in front of this line:
\App\Models\User::factory(10)->create();
The number in brackets is the number of Users that you want to seed.
Step 2: When we now run php artisan db:seed, then we have already 10 random users:
Step 2: In this new file we have to import the user model and the Str facade:
use App\Models\User;
use Illuminate\Support\Str;
And in the run() - function we create our Admin User like this:
User::create([
'name' => 'Martin Krebs Eberth',
'email' => 'martin@laravel-php.com',
'role' => 'admin',
'email_verified_at' => now(),
'created_at' => now(),
'updated_at' => now(),
'password' => bcrypt('test'),
'remember_token' => Str::random(10),
]);
Of course you should use your own name and E-Mail here! ;-)
Step 4: Include the new AdminSeeder into the DatabaseSeeder like this:
$this->call([
AdminSeeder::class,
]);
\App\Models\User::factory(10)->create();
Important here is to place this call before the call of User::factory, so our Admin is always
at the beginning of our users table, so when we run php artisan migrate:fresh --seed, then it
looks something like this:
And then you can use the functions of this facade with the "::"-Syntax
(like calling a static method):
'remember_token' => Str::random(10),
An overview of all the available facades you can either find in the end of the file
/config/app.php