the42coders/the-laravel-admin-panel

A package to create an Admin panel with basic crud.

0.3.4 2022-09-28 08:41 UTC

This package is auto-updated.

Last update: 2024-04-09 15:29:04 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

Installation

You can install the package via composer:

composer require the42coders/the-laravel-admin-panel

You need to register the routes to your web.php routes File as well. Since the-laravel-admin-panel Package is very powerful make sure to secure the routes with whatever authentication you use in the rest of your app.

Route::group(['middleware' => ['auth']], function () {
    \the42coders\TLAP\TLAP::routes();
});

You need to publish the assets of the Package

php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider"  --tag=assets  

Other publishable Contents are

config

php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider"  --tag=config  

language

php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider"  --tag=lang  

views

php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider"  --tag=views  

Usage

To generate the CRUD for a Model just add the TLAPAdminTrait to your Model.

use the42coders\TLAP\Traits\TLAPAdminTrait;

class User extends Model
{
    use TLAPAdminTrait;

and register it in the config tlap.php.

'models' => [
    'users' => 'App\Models\User',
]

Now you can just visit the url of https://your-website.de/admin. You can change the url under which the admin panel will be accessible in the tlap.php config file with the path variable.

This package autoload your relations if you use return types on them.

public function posts(): HasMany
{
    return $this->hasMany('App\Models\Post');
}

The package is guessing your application by its Database structure. Including validation. But you can overwrite this guessing by your own wishes.

You only need to add the static function fields to your Model and set the $fields array with your Field definitions. This is the area which might change a little before the final release.

public static function fields()
{
    self::$fields = [
        new TextField('name', 'Name'),
        new TextField('slug', 'Slug'),
        new TextField('description', 'Description', false),
        new TextField('menu', 'Menu'),
        new TextField('image', 'Image'),
        new TextField('parent_id', 'Parent ID'),
    ];

    return self::$fields;
}

By now we have the following Fields out of the box.

Field Description
Checkbox Default bs5 Checkbox
File Default bs5 Filepicker
Select Default bs5 Select field
Text Default bs5 text input field
TextField Default bs5 Textarea.

In the future it will be possible to add your own Fields as well.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email max@42coders.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.