Laramie
Laramie is a nice dashboard based on Laravel 5.8+ Framework, (*1)
Installation
Requirements
- Composer
- Laravel Framework 5.8+
- Laravel Mix
- Node.js & NPM
Installing Laramie
Run the following command in your console terminal:, (*2)
$ composer require pandorga/laramie
Or if you want to download the files, add the following configuration to the composer.json file:, (*3)
"repositories": [
{
"type": "path",
"url": "../laramie"
}
],
or if you are symlinking the package locally:, (*4)
$ ln -s ../laramie laramie
"repositories": [
{
"type": "path",
"url": "laramie",
"symlink": true
}
],
Next, add the package to the require section of your composer.json file:, (*5)
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"pandorga/laramie": "*"
},
Now run composer update
command:, (*6)
$ composer update
Database Credentials
Next make sure to create a new database and add your database credentials to your .env
file:, (*7)
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Run the installer
Finally, run the install command and migrate Artisan commands., (*8)
$ php artisan laramie:install
$ php artisan migrate
Seeding
In order to init the wizard, run the next command:, (*9)
$ php artisan laramie:seed
Admin User Provider
Your admin user must subclass from Laramie Admin Model, you can change this in laramie.php
config file:, (*10)
'providers' => [
'admins' => [
'driver' => 'eloquent',
'model' => \Pandorga\Laramie\Models\Admin::class,
],
// ...
],
Usage
Defining resources
You may want to generate a new resource using the laramie:resource
Artisan command:, (*11)
$ php artisan laramie:resource bookmarks --icon=bookmark
Specify an icon from BoxIcons with the --icon
option., (*12)
This will create the following files:, (*13)
// Model
app/Models/Bookmark.php
// Controller
app/Http/Controllers/Backend/BookmarkController.php
// Migration
database/migrations/YYYY_MM_DD_HHIISS_create_bookmarks_table.php
// Views
resources/views/bookmarks/create.blade.php
resources/views/bookmarks/edit.blade.php
resources/views/bookmarks/form.blade.php
resources/views/bookmarks/index.blade.php
resources/views/bookmarks/show.blade.php
Note: You may want to run php artisan migrate
command to create the table in the database., (*14)
Register Resources
Once the resource are created, we need to add them to the project:, (*15)
1. Add route
Edit your routes/web.php
and the new resource:, (*16)
Route::group([
'prefix' => config('laramie.route.prefix'),
'middleware' => config('laramie.route.middleware'),
], function () {
Route::resource('bookmarks', 'BookmarkController');
});
2. Create permission
Navigate to your application's /admin
path in your browser, login and go to the Permissions section under the profile context menu and create new bookmarks
permission., (*17)
3. Assign permission to role
Now it's time to assign your new permissions your role. You can do so by navigating to the Roles section, edit your role and select all the new permissions created., (*18)
Edit your resources/views/vendor/laramie/sidebar/general.blade.php
file and add the code below:, (*19)
<li>
<a href="{{ route('bookmarks.index') }}">
<i data-feather="bookmark" class="text-muted"></i>
<span>Bookmarks</span>
</a>
</li>
That's all! You may refresh your dashboard page and you'll see a new item in the sidebar, click on it and explore your new resource., (*20)
Todo
- [x] Assign permissions automatically to role Developer when creating a resource
- [x] Add middleware for auth routes redirect when login
- [ ] Migration file stub
- [ ] Menus Admin
- [ ] Media Library Admin
- [ ] Conditionals for stubs files (Case: not all models will use SoftDelete feature)
- [ ] Analyze Scaffold vs Runtime Gen
- [ ] Separate blog as a package
Security
If you discover any security related issues, please use the issue tracker., (*21)
Credits
License
The MIT License (MIT). Please see License File for more information., (*22)