Giter Site home page Giter Site logo

yassir3wad / nova-order-field Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michielkempen/nova-order-field

0.0 1.0 0.0 109 KB

A field that adds reordering functionality to your Laravel Nova resource's index using the eloquent-sortable package by Spatie.

Vue 36.13% JavaScript 3.67% PHP 60.20%

nova-order-field's Introduction

Nova Order Field

Latest Version on Packagist Total Downloads

Description

A field that adds reordering functionality to your Laravel Nova resource's index using the eloquent-sortable package by Spatie.

Demo

Demo

Installation

This package can be installed through Composer.

composer require michielkempen/nova-order-field

Usage

  1. Follow the usage instructions on the eloquent-sortable repository to make your model sortable.
  2. Add the MichielKempen\NovaOrderField\Orderable trait to your Nova Resource.
  3. Add a public static property called $defaultOrderField to your resource, containing your order column.
  4. Add the OrderField to your Nova Resource fields method.

Grouping

If your model/table has a grouping field (usually a foreign key): id, user_id, title, order_column and you'd like the above methods to take it into considerations, you can create a buildSortQuery method at your model:

public function buildSortQuery()
{
    return static::query()->where('user_id', $this->user_id);
}

This will restrict the calculations to fields value of the model instance.

Example

use MichielKempen\NovaOrderField\Orderable;
use MichielKempen\NovaOrderField\OrderField;

class Page extends Resource
{
    use Orderable;
    
    public static $defaultOrderField = 'order';
    
    public function fields(Request $request)
    {
        return [
            OrderField::make('Order'),
        ];
    }
}

nova-order-field's People

Contributors

darmen avatar michielkempen avatar morphsteve avatar yassir3wad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.