Installation
composer require tayeb-ali/larazoul
php artisan vendor:publish --provider="TayebAli\Larazoul\LarazoulServiceProvider" --tag="config"
php artisan migrate
config/larazoul.php) and runs migrations for core tables (admin_users, roles, permissions).First Use Case: Admin Panel
routes/web.php:
Route::group(['prefix' => 'admin', 'middleware' => ['web', 'auth:admin']], function () {
\TayebAli\Larazoul\Facades\Larazoul::routes();
});
php artisan larazoul:install to seed default admin credentials (email: admin@example.com, password: password).Key Files to Review
config/larazoul.php (adjust guard, middleware, or default settings).app/Http/Middleware/AuthenticateAdmin.php (customize if needed).app/Providers/LarazoulServiceProvider.php (extend or override bindings).Scaffold a Model/Controller
php artisan larazoul:make:crud Post --fields="title:string,content:text,is_published:boolean"
app/Models/Post.php) with fillable fields.app/Http/Controllers/Admin/PostController.php) with CRUD methods.database/migrations/..._create_posts_table.php).resources/views/admin/posts/).Customize Fields
Edit the generated fields array in the controller’s rules() method or use Laravel’s form helpers:
public function fields()
{
return [
'title' => ['type' => 'text', 'label' => 'Post Title'],
'content' => ['type' => 'textarea', 'rows' => 5],
'is_published' => ['type' => 'checkbox', 'label' => 'Published?'],
];
}
Assign Permissions to Roles
Use the built-in admin panel (/admin/roles) to:
Editor).create-post, edit-post).Gate Checks in Code
if (auth()->user()->can('edit-post')) {
// Allow edit functionality
}
Or use middleware:
Route::group(['middleware' => 'can:edit-post'], function () {
// Protected routes
});
Add Custom Views Override default views by publishing them first:
php artisan vendor:publish --tag="larazoul-views"
Then modify resources/views/vendor/larazoul/....
Customize Layout
Extend the base layout (resources/views/vendor/larazoul/layouts/app.blade.php) or override the admin template:
// In LarazoulServiceProvider::boot()
$this->loadViewsFrom(__DIR__.'/../resources/views/custom/admin', 'larazoul');
Expose CRUD via API Use Laravel’s API resources + Larazoul’s controllers:
// routes/api.php
Route::apiResource('posts', \App\Http\Controllers\Admin\PostController::class)
->middleware('auth:api');
TayebAli\Larazoul\Http\Controllers\CrudController.Filtering/Sorting
Leverage Laravel’s query builder or use packages like spatie/laravel-query-builder for dynamic API requests.
Middleware Conflicts
auth:admin fails, verify:
admin guard is configured in config/auth.php.AuthenticateAdmin middleware is registered in app/Http/Kernel.php.php artisan larazoul:install or manually create the admin user table.Permission Caching
php artisan cache:clear
php artisan config:clear
View Overrides
index.blade.php, create.blade.php). Partial overrides (e.g., only edit.blade.php) may break layouts.Migration Conflicts
admin_users table, reset migrations carefully:
php artisan migrate:fresh --env=testing # Test first
Check Logs
Enable debug mode (APP_DEBUG=true) and inspect storage/logs/laravel.log for permission or route errors.
DD() in Controllers
Debug CRUD logic by adding dd($request->all()) in controller methods (e.g., store()).
Artisan Commands
php artisan list | grep larazoul
php artisan larazoul:assets
Custom Auth Logic
Override the AdminUser model (app/Models/AdminUser.php) or extend the AuthenticatesAdmins trait.
Add Notifications
Extend the AdminUser model to include notify() methods or use Laravel Notifications:
// app/Models/AdminUser.php
use Illuminate\Notifications\Notifiable;
class AdminUser extends Authenticatable {
use Notifiable;
// ...
}
Multi-Tenant Support
spatie/laravel-multitenancy alongside Larazoul.LarazoulServiceProvider to scope queries:
public function boot()
{
\TayebAli\Larazoul\Models\Post::addGlobalScope(new TenantScope());
}
Localization
php artisan vendor:publish --tag="larazoul-lang"
resources/lang/vendor/larazoul/ for custom translations.Eager Load Relationships Manually eager-load in controllers to avoid N+1 queries:
public function index()
{
$posts = Post::with('author')->get();
// ...
}
Disable Debug Bar
If using barryvdh/laravel-debugbar, exclude Larazoul routes to reduce overhead:
// app/Providers/DebugbarServiceProvider.php
$this->excludeRoutes([
'admin/*',
]);
How can I help you explore Laravel packages today?