ahmedmalmoselhy / laravel-dashboard

Laravel dashboard designed to work from a single controller
0 stars 0 forks source link

About Laravel Dashboard

Laravel Dashboard is a free admin dashboard template built with adminty template. It is a fully responsive bootstrap admin template built with Bootstrap 4 Framework, HTML5, CSS and JQuery. It has a huge collection of reusable UI components and integrated with latest jQuery plugins. It can be used for all type of web applications like custom admin panel, project management system, admin dashboard, application backend, CMS, CRM, business website, corporate, portfolio, blog, etc.

More info will be added soon.

This is still work in progress and subject to change.

Main Features

How to configure for anything

use App\Bll\Constants;
use App\Modules\Country\Models\Country;
use App\Modules\Country\Models\CountryData;

return [
    'baseModel' => Country::query(),
    'dataModel' => CountryData::query(),
    'allow_edit' => true,
    'base_route' => route('dashboard.country.index'),
    'route' => 'country',
    'title' => ('Countries'),
    'createTitle' => ('Create Country'),
    'editTitle' => ('Edit Country'),
    'uploads' => Constants::CountryPath,
    'columns' => [
        [
            'name' => 'id',
            'type' => 'hidden',
            'model' => 'base',
            'label' => ('ID'),
            'editable' => false,
            'searchable' => false,
            'sortable' => true,
            'showInForm' => true,
            'required' => true,
        ],
        [
            'name' => 'title',
            'type' => 'text',
            'model' => 'data',
            'label' => ('Title'),
            'editable' => true,
            'searchable' => true,
            'sortable' => true,
            'placeholder' => ('Country Title'),
            'required' => true,
            'showInForm' => true,
        ],
        [
            'name' => 'dialing_code',
            'type' => 'text',
            'model' => 'base',
            'label' => ('Phone Code'),
            'editable' => true,
            'searchable' => true,
            'sortable' => true,
            'placeholder' => ('Country Phone Code'),
            'required' => true,
            'showInForm' => true,
        ],
        [
            'name' => 'status',
            'type' => 'checkbox',
            'model' => 'base',
            'label' => ('Status'),
            'editable' => true,
            'searchable' => true,
            'sortable' => true,
            'required' => true,
            'showInForm' => true,
        ],
        [
            'name' => 'created_at',
            'type' => 'text',
            'model' => 'base',
            'label' => ('Created At'),
            'editable' => false,
            'searchable' => false,
            'sortable' => true,
            'showInForm' => false,
        ],
        [
            'name' => 'action',
            'type' => 'action',
            'model' => 'action',
            'label' => ('Options'),
            'editable' => false,
            'searchable' => false,
            'sortable' => false,
            'data' => [
                'edit' => 'admin.components.buttons.edit',
                'delete' => 'admin.components.buttons.delete',
            ],
            'showInForm' => false,
        ]
    ],
    'validation' => [
        'rules' => [
            'title' => 'required|string|max:255|min:3',
            'code' => 'required|string|max:10|min:2|unique:countries,code',
            'dialing_code' => 'required|string|max:10|min:2|unique:countries,dialing_code',
            'lang_id' => 'required|integer',
        ],
        'messages' => [
            'title.required' => ('Title is required'),
            'code.required' => ('Code is required'),
            'code.unique' => ('Code is already exists'),
            'dialing_code.required' => ('Dialing code is required'),
            'dialing_code.unique' => ('Dialing code is already exists'),
        ]
    ]
];

The above configuration is for the country module, you can configure any module with the same configuration, you just create your controller and have it extend the App\Modules\Admin\Controllers\DashboardController and your models to extend the App\Models\BaseModel and you are good to go.

Create a config.php file in your module folder and add the above configuration.

You'll have your controller like this

class CountryController extends DashboardController
{
    public function __construct()
    {
        $this->config = require_once(app_path('Modules/Country/config.php'));
        parent::__construct();
    }
}

All the crud logic is already written in the DashboardController so you don't have to write anything, just extend the DashboardController and you are good to go.