rezahmady/setting-operation

setting operation for backpackforlaravel package

2.0.1 2024-08-13 16:24 UTC

This package is auto-updated.

Last update: 2024-12-13 17:11:09 UTC


README

Backpack Setting Operation to save customize settings for each CRUD. Uses Backpackforlaravel. Works on Laravel 5.2 to Laravel 10.

Backpackforlaravel is cool admin panel for laravel.

Many times it is necessary to make settings for some CRUDs, for example, for the transactions CRUD, you need bank port settings, or for product management, you need settings related to transportation, taxes, etc.

You can even make many of your backpack settings dynamic with this add-on.

Installation

Via Composer

$ composer require rezahmady/setting-operation

publish vendor :

$ php artisan vendor:publish

migrate add-on table :

$ php artisan migrate

Why do you need this add-on ?

If you, like me, believe that each CRUD can be a separate module, then having the settings for each crud (module) is important.

The backpack has a settings add-on that I don't think is practical at all.Funny, you have to save the fields as json in the database. But in this add-on, like other operations such as CreateOperation and UpdateOperation, easily use the all backpack fields.

Usage

Step 1. In your CrudController, use the operation trait:

<?php

namespace App\Http\Controllers\Admin;

use Backpack\CRUD\app\Http\Controllers\CrudController;

class ProductCrudController extends CrudController
{
    use \Rezahmady\SettingOperation\SettingOperation;

Step 2. In your CrudController, add setupSettingOperation method and add your custom backpack fields:

    /**
    * Define what happens when the Setting operation is loaded.
    * 
    * @see https://github.com/rezahmady/setting-operation
    * @return void
    */
    protected function setupSettingOperation()
    {
        // backpack fields
    }

Step 3. To call the value of each field, you must use the Setting facade:

use Rezahmady\SettingOperation\Setting;

Setting::get(CRUD_TABLE_NAME.FIELD_NAME, DEFAULT);

fast update field To update or set new field you can use this:

use Rezahmady\SettingOperation\Setting;

Setting::set(CRUD_TABLE_NAME.FIELD_NAME, VALUE);

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email ahmadireza15@gmail.com instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.