Tag Archive for: Laravel

Update 4:

Even though Filament v3 has been officially released a few hours ago, it is not recommended to install or upgrade it for production at this time. This caution arises from Filament v3’s dependency on Livewire v3, which is currently in beta version and facing difficulties in upgrading from Filament v2 to v3.

Update 3:

Filament plugins have been reduced from almost 200 to only 37 in version 3. These have been verified and selected to be compatible with the current version.

Update 2:

I realized that Filament install requires to enable intl php extension.

Update 1:

Filament allow install multiple panels at the same time 

Laravel Filament

Laravel Filament, one of the most popular Laravel packages for creating admin panels, has recently released its highly anticipated version 3. With a plethora of new features and improvements, Laravel Filament v3 promises to make the development of admin interfaces even more enjoyable and efficient. In this post, we will dive into some of the exciting features that come with Laravel Filament v3 and see how they can enhance our admin panel development experience.

1. Elegant UI Components:

One of the standout features of Laravel Filament v3 is its sleek and elegant user interface components. From data tables to form inputs, each component has been meticulously designed to provide a modern and user-friendly experience. The new UI components are highly customizable, allowing developers to easily match them with the application’s branding and design aesthetics.

2. Blade Views Integration:

In v3, Laravel Filament introduces seamless Blade views integration. Now developers can leverage the power of Blade templates to build custom views within their admin panels. This enhancement allows for better code reusability and makes it easier to incorporate existing Blade components from other parts of the application.

3. Improved CRUD Generator:

With version 3, Laravel Filament’s CRUD generator has received significant upgrades. Creating CRUD (Create, Read, Update, Delete) interfaces for database models is now faster and more intuitive. Developers can easily define model attributes, relationships, and validation rules, and Filament will take care of the rest, generating fully functional CRUD interfaces instantly.

4. Multi-language Support:

Localization is a crucial aspect of any web application, and Laravel Filament v3 understands that. The new version offers robust multi-language support out of the box, making it a breeze to build admin panels for applications with a global audience. Translating your admin panel into multiple languages is now as simple as defining translation files.

5. Custom Actions & Metrics:

Filament v3 empowers developers to create custom actions and metrics tailored to their application’s specific needs. Whether it’s batch processing, data export, or any other custom operation, developers can now seamlessly integrate them into the admin panel with just a few lines of code.

6. Improved Security:

Security is paramount in any admin panel, and Laravel Filament v3 ensures that your application remains secure by implementing the latest security best practices. Role-based access control and permissions management have been further enhanced, allowing administrators to define granular access levels for different user roles.

 

Laravel Filament v3 raises the bar for admin panel development with its remarkable set of features and improvements. From the stunning user interface to the seamless integration of Blade views and the flexibility to define custom actions and metrics, it offers everything developers need to build powerful and user-friendly admin interfaces. With a dedicated focus on performance, security, and ease of use, Laravel Filament v3 has undoubtedly become the go-to choice for developers looking to create exceptional admin panels for their Laravel applications. So, if you haven’t already, it’s time to upgrade to Laravel Filament v3 and witness the magic it brings to your admin panel development workflow. Happy coding!

 

 

 

 

In this post, we are going to explain the shortest path to add many languages to Laravel 8 including RTL language and language switcher.

1- Add languages to app/config/app.php file

'languages' => [
        'ar', 'en'
    ],

2- Create middleware component

php artisan make:middleware Localization

3- Add Localization class to web group in app/kernal file

\App\Http\Middleware\Localization::class,


4- In app/http/middleware/Localization.php

public function handle(Request $request, Closure $next)
    {
        $languages = config('app.languages');
        $lang = session()->has('lang') ? session()->get('lang') : '';
        if (in_array($lang, $languages)) {
            App::setLocale($lang);
        }
        return $next($request);
    }

5- In the web routes add the following route

Route::get('lang/{locale}', function ($locale) {
    $languages = config('app.languages');
    if (in_array($locale, $languages)) {
        session()->put('lang', $locale);
    }
    return redirect()->back();
})->name('setlanguage');

6- Add languages switcher in the Navbar
@foreach (config('app.languages') as $locale)
> a href="{{ route('setlanguage', $locale) }}"
class=" {{ app()->getLocale() == $locale ? ' border dark:border-white border-gray-800' : '' }} p-1 m-1 rounded-md hover:text-white active:text-white focus:text-white">
@if ($locale == 'ar')
AR flag
@elseif($locale == 'en')
EN flag
@endif
>/a>
@endforeach

7- Add language file in lang folder
ar.json for example and add json array to it.

Done.

There are many tutorials about installing Laravel 8 with the necessary tools and packages.Also the steps to install dark and light, system mode. In addition to adding the proper way to install mutil-lingual site. Here I’m going to put all the effort and installation steps in one place so easy to recall and follow. Before starting, we would like to install the following:

1- Laravel 8.x

2- Jetstream and livewire

3- Tailwindcss 3.x

4- Spatie roles and permissions management

5- Turbo links for faster navigation and surfing pages.

6- Alpinejs for dynamic dropdown, navigation, and other user interactions.
7- Add themes
8- Add multi-languages
So let us start.

Install Laravel and Packages

1- Install fresh Laravel

 laravel new project_name 

2- Generate key

 php artisan key:generate

3- Setup database and app name from .env
4- Install Jetstream with livewire

 composer require laravel/jetstream
 php artisan jetstream:install livewire 

5- Install npm package

 npm install
 npm run dev
 php artisan migrate 

6- Publish jetstearm views

 php artisan vendor:publish --tag=jetstream-views
npm run dev 

7- Install spatie roles and permissions

 composer require spatie/laravel-permission
 php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
 php artisan migrate:fresh --seed

Optional: The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

 'providers' => [
    // ...
    Spatie\Permission\PermissionServiceProvider::class,
]; 

You should publish the migration and the config/permission.php config file with:

 php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider 

 

8- Add HasRoles to User model and add to header file

use Spatie\Permission\Traits\HasRoles;

 

9- Schema::defaultStringLength(125) maybe not necessary
10 – Clear your web cache.

 php artisan config:clear
 php artisan view:clear
 php artisan cache:clear
 php artisan route:cache
 composer dump-autoload 

 

11- Install Tailwindcss
Tailwindcss the latest version comes automatically with Laravel. However if you want to install it or update it.

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init

 

12- Install Alpinejs
Alpinejs already installed in Laravel 8 by default. However, if you want to instaal/update it.

npm install alpinejs
npm run watch

 

13- Add turbo links

 composer require tonysm/turbo-laravel

14- Turbo Laravel scaffolding install with jetstream

 php artisan turbo:install --jet 

Then, you can run install your NPM dependencies and compile your assets normally.

npm install

You may wants to add trubolinks to web

namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
    protected $middlewareGroups = [
        'web' => [
            \Tonysm\TurboLaravel\Http\Middleware\TurboMiddleware::class,
            // other middlewares...
        ],
    ];
}

15- Add social login package

 composer require laravel/socialite

Create Multi-themes

Add Dark, light, and system mode.

Create Multilingual Website

Please read how to create a multilingual website on this website.