Latest Premium Tutorial
-
· 11 mins, 2097 words · premium
Laravel Reverb Demo: Real-Time Notification on Completed Task
Some Laravel tasks are running in the background. What if you want to "listen" for those events to finish? Let's implement exactly this real-time feedback with the Reverb server.
Newest content
-
· 2 mins, 215 words
This Week: 40% Discount for Yearly and Lifetime Plans!
-
· 1 min, 107 words
Laravel 11: New Artisan "make:trait" Command
-
Random Quick Laravel Tip:
Override Permissions for Super AdminIf you've defined your Gates but want to override all permissions for SUPER ADMIN user, to give that superadmin ALL permissions, you can intercept gates with
Gate::before()
statement, inAuthServiceProvider.php
file.// Intercept any Gate and check if it's super adminGate::before(function($user, $ability) {if ($user->is_super_admin == 1) {return true;}});// Or if you use some permissions package...Gate::before(function($user, $ability) {if ($user->hasPermission('root')) {return true;}});If you want to do something in your Gate when there is no user at all, you need to add a type hint for
$user
allowing it to benull
. For example, if you have a role called Anonymous for your non-logged-in users:Gate::before(function (?User $user, $ability) {if ($user === null) {$role = Role::findByName('Anonymous');return $role->hasPermissionTo($ability) ? true : null;}return $user->hasRole('Super Admin') ? true : null;}); -
· 1 min, 110 words
Laravel 11: New Artisan "make:interface" Command
-
· 1 min, 159 words
Laravel 11: New Artisan "make:enum" Command
-
· 1 min, 194 words
Laravel 11: New Artisan "make:class" Command
-
Premium Course: How to Build Laravel 11 API From Scratch
-
· 7 mins, 1314 words
Laravel 11: Main New Features and Changes
-
· 1 min, 171 words
Laravel 11: How to Change Default SQLite to MySQL
-
· Updated Mar 2024 · 3 mins, 477 words
Caching in Laravel with Redis: Simple Example
-
· 5 mins, 890 words
Virtual DB Columns in Laravel Migrations and MySQL
-
· 2 mins, 291 words
CarbonImmutable Class: Why You Would Need It