All Projects → izica → relations-widgets-for-backpack

izica / relations-widgets-for-backpack

Licence: MIT license
Views/widgets for preview laravel relations in laravel backpack

Programming Languages

Blade
752 projects
PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to relations-widgets-for-backpack

madzipper
Wannabe successor of Chumper/Zipper package for Laravel
Stars: ✭ 114 (+442.86%)
Mutual labels:  laravel-package
laravel-migrate-check
An artisan command to check for pending migrations with proper exit code
Stars: ✭ 53 (+152.38%)
Mutual labels:  laravel-package
unobserve
Mute and unmute Laravel observers at will.
Stars: ✭ 82 (+290.48%)
Mutual labels:  laravel-package
Instagram-for-PHP
PHP SDK for Instagram API
Stars: ✭ 82 (+290.48%)
Mutual labels:  laravel-package
laravel-packages
Useful packages for Laravel projects
Stars: ✭ 22 (+4.76%)
Mutual labels:  laravel-package
openfoodfacts-laravel
Open Food Facts API wrapper for Laravel
Stars: ✭ 117 (+457.14%)
Mutual labels:  laravel-package
Laravel User Activity
Monitor user activity easily!
Stars: ✭ 253 (+1104.76%)
Mutual labels:  laravel-package
laravel-two-factor-authentication
A two-factor authentication package for Laravel >= 8
Stars: ✭ 37 (+76.19%)
Mutual labels:  laravel-package
LaravelPostcodes
A service wrapper around postcodes.io
Stars: ✭ 73 (+247.62%)
Mutual labels:  laravel-package
academico
Lavarel-based school management platform for small and medium institutions
Stars: ✭ 164 (+680.95%)
Mutual labels:  backpack
boilerplate
Laravel AdminLTE 3 Boilerplate package with blade components, users, roles and permissions management
Stars: ✭ 167 (+695.24%)
Mutual labels:  laravel-package
blurhash
A PHP implementation of BlurHash with Laravel integration.
Stars: ✭ 46 (+119.05%)
Mutual labels:  laravel-package
laravel-jwt
A seamless JWT implementation for Laravel
Stars: ✭ 71 (+238.1%)
Mutual labels:  laravel-package
nova-rating-field
A Star rating field to use in your Laravel Nova apps.
Stars: ✭ 42 (+100%)
Mutual labels:  laravel-package
Laravel-Youtube-API
A way to add an API to your Laravel app that converts youtube video's to mp3/mp4 and returns a download/stream link and information.
Stars: ✭ 19 (-9.52%)
Mutual labels:  laravel-package
Translation Sheet
Translating Laravel languages files using a Google Spreadsheet.
Stars: ✭ 254 (+1109.52%)
Mutual labels:  laravel-package
trader
Laravel package for trader extension interface.
Stars: ✭ 43 (+104.76%)
Mutual labels:  laravel-package
flash
An easy way for Laravel flash notifications.
Stars: ✭ 14 (-33.33%)
Mutual labels:  laravel-package
jwt-auth
🔐 JSON Web Token Authentication for Laravel & Lumen
Stars: ✭ 525 (+2400%)
Mutual labels:  laravel-package
laravel-api-tool-kit
Laravel api tool kit is a set of tools that will help you to build a fast and well-organized API using laravel best practices.
Stars: ✭ 107 (+409.52%)
Mutual labels:  laravel-package

Laravel Backpack Relations Widgets

  1. Installation
  2. Screenshots
  3. Features
  4. Documentation
  5. Usage
  6. How to enable creating related model

3.0 Whats new:

  • relation_table search input
  • relation_table create button with relation attribute reference
  • relation_table pagination

Alt text

Installation

composer require izica/relations-widgets-for-backpack

Screenshots

Alt text Alt text

Features

  • use widgets for showing relations in show operation
  • show or hide panels or fields by conditions
  • build field value by closure
  • use dot orm notation for accessing relation fields

Documentation

  • relation_panel

    • name - name of relation
    • label - panel label
    • backpack_crud - backpack crud url,
    • buttons (optional) - set false to hide all action buttons
    • button_show (optional) - set false to hide
    • button_edit (optional) - set false to hide
    • visible (optional) - closure for hiding or showing panel
    • fields (optional) - fields array, by default get columns from fillable in model
      • name - name
      • label - for field
      • closure - use closure instead of name field,
      • visible(optional) - closure for hiding or showing panel
  • relation_table

    • name - (required) name of relation
    • label - panel label
    • relation_attribute - (optional) used for passing url parameter name for button_create
    • search - (optional) closure, enables search input
    • per_page - (optional) enables pagination, null by default
    • backpack_crud - backpack crud url,
    • buttons (optional) - set false to hide all action buttons
    • button_create (optional) - set false to hide
    • button_show (optional) - set false to hide
    • button_edit (optional) - set false to hide
    • button_delete (optional) - set false to hide
    • visible (optional) - closure for hiding or showing panel
    • columns (optional) - columns array, by default get columns from fillable in model
      • name - name
      • label - for field
      • closure - use closure instead of name field for passing value,

Usage

Relation panel

belongsTo, hasOne

use Backpack\CRUD\app\Library\Widget;

protected function setupShowOperation()
{
    Widget::add([
        'type'           => 'relation_panel',
        'name'           => 'account_contact',
        'label'          => 'Account contact info',
        'backpack_crud'  => 'accountcontact',
        'visible' => function($entry){
            return $entry->is_public_person;
        },
        'buttons' => false,
        'fields'         => [
            [
                'label' => 'Birthdate',
                'closure' => function($entry){
                    return date('d.M.Y', $entry->birthdate);
                }
            ],
            [
                'label' => 'Contact phone',
                'name'  => 'contact_phone',
            ],
            [
                'label' => 'Contact email',
                'name'  => 'contact_email',
            ],
            [
                'label' => 'Address',
                'name'  => 'address.name',
                'visible' => function($entry){
                    return !!$entry->address;
                }       
            ],
        ],
    ])->to('after_content');
}

Relation table

hasMany

protected function setupShowOperation()
{
    Widget::add([
        'type'           => 'relation_table',
        'name'           => 'order_cargos',
        'label'          => 'Order cargo list',
        'backpack_crud'  => 'ordercargo',
        'visible' => function($entry){
            return $entry->order_cargos->count() > 0;
        },
        'search' => function ($query, $search) {
            return $query->where('name', 'like', "%{$search}%");
        },
        'relation_attribute' => 'order_id',
        'button_create' => true,
        'button_delete' => false,
        'columns' => [
            [
                'label' => 'Type',
                'name'  => 'order_cargo_type.name',
            ],
            [
                'label' => 'Weight',
                'name'  => 'weight',
            ],
            [
                'label' => 'Value, $',
                'closure' => function($entry){
                    return "{$entry->value}$";
                }
            ],
        ],
    ])->to('after_content');
}

How to enable creating related model

You need to set:

  • button_create => true
  • relation_attribute => attribute_name

Next you need to add to relation/select field default value:

    CRUD::addField([
        'type' => "relationship",
        'name' => 'order',
        'default' => $_GET['order_id'] ?? null
    ]);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].