Courses

Creating CRM with Filament 3: Step-By-Step

Install Laravel and Filament

In this lesson, we will look at Laravel and Filament installation. You can skip this lesson if you already know how to install Laravel and Filament.

Laravel Installation

The simplest way to install Laravel is to follow the official documentation. We will use the Laravel installer to create a new project.

laravel new Filament-CRM-Course

This will generate a fresh Laravel installation in a Filament-CRM-Course directory. You can change the name of the project to whatever you want.

Don't forget to set your database credentials in the .env file.


Filament Installation

Next on our list is Filament. We will use Composer to install Filament.

composer require filament/filament

This will install the Filament package in your Laravel project. Next, we need to install Filament Panels:

php artisan filament:install --panels

Once that is done, we can visit our project in the browser like so:

http://filament-crm-course.test/admin/login (don't forget to change the domain to match your project's domain)


Logging Into Filament

To log in, we need to create a user. But before we do that, Filament asks us to add FilamentUser to our User Model:

app/Models/User.php

use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Illuminate\Foundation\Auth\User as Authenticatable;
 
// ...
 
class User extends Authenticatable implements FilamentUser
{
// ...
 
public function canAccessPanel(Panel $panel): bool
{
return true; // @todo Change this to check for access level
}
}

This is required for Filament to manage your User permissions and who can access the admin panel. We have set it to true, allowing everyone to access the admin panel. We will change this later in this Course.

Next, we can define a simple admin user in our DatabaseSeeder.php file:

database/seeders/DatabaseSeeder.php

public function run(): void
{
User::factory()->create([
'name' => 'Test Admin',
'email' => 'admin@admin.com',
]);
}

Then run the migrations and seeders:

php artisan migrate --seed

And we should be able to log in with our admin user: (Email: admin@admin.com, Password: password)

That's it! We have Laravel and Filament configured and ready to go. In the next lesson, we will create our first Filament Resource - Customer.

avatar

The php artisan filament:install --panels is giveing a error:


 ERROR  Command "filament:install" is not defined. Did you mean one of these?

   filament:check-translations
   filament:upgrade
   forms:install
   migrate:install
   notifications:install
   sail:install
   tables:install

Sujestions ? Do I need to do all of them?

tryed to run php artisan filament:check-translations and got the following Error:

    
  Not enough arguments (missing: "locales").  
  
avatar

You have most likely installed V2 of filament and not V3. This guide required V3 version

avatar

Installed Livewire v3.0.8 then composer require filament/filament -W ./composer.json has been updated Running composer update filament/filament --with-all-dependencies Loading composer repositories with package information Updating dependencies Got Error:


Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - filament/filament v3.0.0 requires filament/support v3.0.0 -> satisfiable by filament/support[v3.0.0].
    - filament/filament v3.0.1 requires filament/support v3.0.1 -> satisfiable by filament/support[v3.0.1].
    - filament/filament v3.0.2 requires filament/support v3.0.2 -> satisfiable by filament/support[v3.0.2].
    - filament/filament v3.0.3 requires filament/support v3.0.3 -> satisfiable by filament/support[v3.0.3].
    - filament/filament v3.0.4 requires filament/support v3.0.4 -> satisfiable by filament/support[v3.0.4].
    - filament/filament v3.0.5 requires filament/support v3.0.5 -> satisfiable by filament/support[v3.0.5].
    - filament/filament v3.0.6 requires filament/support v3.0.6 -> satisfiable by filament/support[v3.0.6].
    - filament/filament v3.0.7 requires filament/support v3.0.7 -> satisfiable by filament/support[v3.0.7].
    - filament/filament v3.0.8 requires filament/support v3.0.8 -> satisfiable by filament/support[v3.0.8].
    - filament/filament v3.0.9 requires filament/support v3.0.9 -> satisfiable by filament/support[v3.0.9].
    

Looks Like a versioning error to me

avatar

You do not have to install livewire as a separate package, it will come pre-bundled with FIlament. So only require Filament itself

avatar

Just do: composer require filament/filament

avatar

That gites me the 2.0.17 version

avatar

Which php version are you running? It should already give the v3

avatar

Had to change the php ini to alow the inil to work, I am using PHP 8.2.4 It has now installed and ready to go.

avatar

Hi, This guide required Filament V3 version https://filamentphp.com/docs/3.x/panels/upgrade-guide

composer require filament/filament:"^3.0-stable" -W --ignore-platform-req=ext-intl
avatar

Yes, this requires a V3, but your installation script has some problems. It should use:

composer require filament/filament

Adding -W is not a problem, but usually not required.

Adding --ignore-platform-req=ext-intl is a problem as you can later break your application without even realising it.

avatar

the back to top button in the bottom left is extremely annoying, it interfers with viewing pleasure. If you increase text-size it becomes even bigger.

avatar

Hi, are you talking about mobile view? If you could, please send us an email (mention that it's for Modestas in it) with a screenshot and we will take a look!

avatar

Is there any way you can do a few classes with the testing for this course?

avatar

In this course we did not plan to talk about testing. This is out of scope and not really a focus for these lessons.

avatar

x-filament::page> @foreach ($departments as $department) x-filament::section

{{ ('Department') }}: {{ $department->name }}
@foreach ($teams as $team) @if ($team->department_id == $department->id) <x-filament::infolist :title="$team->name"> </x-filament::infolist> @endif @endforeach </x-filament::section> @endforeach </x-filament::page>
avatar

Anyone using WSL2 facing issues running composer require filament/filament can follow here to install necessary PHP extensions. If you're using Laragon, you need to install it/enable it manually.