A package designed to help create Meta options for the extending core functions of Backpack such as users and other packages.
This package is currently in development and is not recommended for a production environment.
- In your terminal:
$ composer require abbyjanke/backpackmeta
- Publish the config file & run migrations.
$ php artisan vendor:publish --provider="AbbyJanke\BackpackMeta\MetaServiceProvider" #publish config files and migrations
$ php artisan migrate #create the role and permission tables
- Within the new
config/backpack/meta.php
configuration file you will need to set a list of all models you wish to be accessible via the admin interface for meta fields. If you do not intend to use the admin interface then you can skip this step. Example:
'models' => [
'App\Models\Monster',
'App\User'
],
- Use the following traits on your Controller
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\MonsterRequest as StoreRequest;
use App\Http\Requests\MonsterRequest as UpdateRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use AbbyJanke\BackpackMeta\PanelTraits\Meta as MetaTrait; // <!-------------- This One
class MonsterCrudController extends CrudController
{
use MetaTrait; // <!-------------- This one too
public function setup()
{
$this->getMetaFields(); // <!-------------- And finally this one
}
- Run the migration to have the database table we need:
php artisan migrate
- [optional] Add a menu item for it in
resources/views/vendor/backpack/base/inc/sidebar.blade.php
:
<li><a href="{{ url(config('backpack.base.route_prefix').'/meta') }}"><i class="fa fa-plus-square"></i> <span>Meta Options</span></a></li>
To retrieve a Meta value from a specific Record within your database you can call it the same was as any column within the model's main database such as:
$record->metaKeyName;
If you discover any security related issues with this package, please email [email protected] instead of using the issue tracker. If you discover any security related issues with the Backpack core, please email [email protected] instead of using the issue tracker.