2017 © Pedro Peláez
 

project laraman

Laravel crud manager.

image

christhompsontldr/laraman

Laravel crud manager.

  • Thursday, July 26, 2018
  • by ChrisThompsonTLDR
  • Repository
  • 1 Watchers
  • 7 Stars
  • 175 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 17 Versions
  • 6 % Grown

The README.md

Laraman - Laravel Data Manager

Laraman is a Laravel based administration panel., (*1)

Laraman provides a quick user interface for reviewing and managing data stored in your database., (*2)

Laraman is really good at the index route, searching, filtering and pagination. It leaves the create, update and delete to the application., (*3)

Installation

Composer

Require this package with composer:, (*4)

composer require christhompsontldr/laraman

Service Provider

After updating composer, add the ServiceProvider to the providers array in config/app.php, (*5)

Laravel 5.x:

Christhompsontldr\Laraman\ServiceProvider::class,

Config

Copy the config/laraman.php file from the packge to your applications config directory., (*6)

Routes

Laraman utilizes the resource method in routes to build all the required routes., (*7)

In routes/web.php add", (*8)

Laraman::resource('users');

Laraman will now look for a app/Http/Controllers/Manage/UserController.php., (*9)

The namespace of the Laraman controllers can be changed in the config/laraman.php file. Manage is the default namespace., (*10)

Models

Include the Laraman trait on your model, (*11)

use Christhompsontldr\Laraman\Traits\LaramanModel;

and then use it, (*12)

use LaramanModel;

Laraman utilizes something we call formatters. We have included a few default formatters, but you are welcome to write your own. Review the Christhompsontldr\Laraman\Traits\LaramanModel class for examples., (*13)

Think of these as post-accessors. This allows Laraman to manipulate model data after the application's accessors have been applied., (*14)

Example of using the date formatter, (*15)

public function __configure()
{
    $this->columns = [
        [
            'field' => 'created_at',
            'display' => 'Created',
            'formatter' => 'datetime',
            'options'   => [
                'format' => 'F j, Y g:ia',
            ]
        ],

Controllers

Include the Laraman trait on your controller, (*16)

use Christhompsontldr\Laraman\Traits\LaramanController;

and then use it, (*17)

use LaramanController;

Laraman expects your controller to have a __configure() method where a few things are configured., (*18)

public function __configure()
{
    $this->columns = [
        [
            'field' => 'id',
        ],
        [
            'field' => 'name',
        ],
        [
            'field' => 'email',
        ],
        [
            'field'   => 'organization.name',
            'display' => 'Organization',
        ],
    ];

    $this->buttons = [
        config('laraman.view.hintpath') . '::buttons.view',
    ];
}

This example will build an index route with a table with 4 columns and 1 button., (*19)

Options

Model

If the model name you want to use doesn't make the naming convention you used for your controller, it can be set with the model attribute, (*20)

    public function __configure()
    {
        $this->model = \App\Mail::class;

Views

Need to load views from another path, use the viewPath attribute, (*21)

    public function __configure()
    {
        $this->viewPath = config('laraman.view.hintpath') . '::mail';

Route

The route where laraman lives for this controller can be changed, (*22)

    public function __configure()
    {
        $this->routePath = config('laraman.route.prefix') . '.mail';

You can enable model level searches with the searchEnabled attribute, (*23)

public function __configure()
{
    $this->searchEnabled = true;

Your model will need to have implemented a search() method. This is commonly found in the Laravel Scout library or the Algolia Search for Laravel library., (*24)

Columns

The only required array key for a column is the field. This will be the database column name you want to display., (*25)

display

display will change the name displayed to the user in the top of the table., (*26)

The dot notation can be used to reach related model data., (*27)

public function __configure()
{
    $this->columns = [
        [
            'field' => 'id',
        ],
        [
            'field' => 'name',
        ],
        [
            'field' => 'email',
        ],
        [
            'field'   => 'organization.name',
            'display' => 'Organization',
        ],
    ];

organization.name will load the name from the related organization., (*28)

blade

If you need to use a custom blade for a field, define it like this, (*29)

public function __configure()
{
    $this->columns = [
        [
            'field' => 'braintree_customer_id',
            'display' => 'Braintree Customer',
            'options' => [
                'blade' => config('laraman.view.hintpath') . '::fields.memberships.customer'
            ]
        ],

Filters

Laraman can utilize filters defined on the model, (*30)

public function __configure()
{
    $this->filters = [
        [
            'field' => 'event',
            'display' => 'Event',
            'type' => 'select',
            'values' => [
                'send'  => 'send',
                'hard_bounce' => 'hard bounce',
                'open'   => 'open',
                'soft_bounce' => 'soft bounce',
                'deferral' => 'clickdeferral',
                'delivered' => 'delivered',
                'reject' => 'reject',
                'spam' => 'spam',
            ]
        ],
    ];

If the model has a filterEvent defined, it will be utilized, (*31)


public function filterEvent($builder, $val) { return $builder->{$val}(); }

Could be used to apply model scopes like scopeSend() and scopeOpen()., (*32)

Buttons

Action buttons can be added with the buttons attribute, (*33)

public function __configure()
{
    $this->buttons = [
        'laraman::buttons.braintree-transaction',
        'laraman::buttons.receipt',
    ];

Scopes

If you need to scope the model being used, define a scope method in your controller, (*34)

class TrialController extends Controller
{
    use LaramanController;

    public function scope($builder)
    {
        //  only show trials
        return $builder->trial();
    }

Extras

Have extra data to pass from the controller to the view, use extras, (*35)

class TrialController extends Controller
{
    use LaramanController;

    public function __configure()
    {
        $this->columns = [
            [
                'field' => 'created_at',
                'display' => 'Created',
                'formatter' => 'datetime',
                'options'   => [
                    'format' => 'F j, Y g:ia',
                ]
            ]
        ];

        //  active trials
        $this->extras['active'] = Membership::trial()->active()->count();

        //  by day
        $this->extras['byday'] = [];
        foreach (range(0, 30) as $day) {
            $date = Carbon::now()->subDays($day)->format('Y-m-d');

            $this->extras['byday'][$date] = Membership::trial()->active()->whereDate('created_at', $date)->count();
        }
    }

The Versions

26/07 2018

dev-master

9999999-dev

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

18/05 2018

v2.0.1

2.0.1.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

26/03 2018

v2.0.0

2.0.0.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

26/03 2018

dev-fixing-construct

dev-fixing-construct

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

04/12 2017

1.1.21

1.1.21.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

01/12 2017

v1.1.20

1.1.20.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

30/11 2017

v1.1.9

1.1.9.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

22/11 2017

v1.1.8

1.1.8.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

15/11 2017

v1.1.7

1.1.7.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

15/11 2017

v1.1.6

1.1.6.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

06/09 2017

v1.1.5

1.1.5.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

06/09 2017

v1.1.4

1.1.4.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

16/08 2017

v1.1.3

1.1.3.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

14/08 2017

v1.1.2

1.1.2.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

01/08 2017

v1.1.1

1.1.1.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

30/06 2017

v1.1.0

1.1.0.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager

02/05 2017

v1.0.0

1.0.0.0

Laravel crud manager.

  Sources   Download

MIT

The Requires

 

laravel admin manager