2017 © Pedro Peláez
 

laravel-package orderable

Ordering package for Laravel 5.x

image

zigastrgar/orderable

Ordering package for Laravel 5.x

  • Saturday, October 8, 2016
  • by ZStrgar
  • Repository
  • 2 Watchers
  • 23 Stars
  • 380 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

Orderable Laravel Package

This is my very first Laravel package. I find it useful for me :) When I work with projects where I need to run a lot of ORDER BY queries., (*1)

Instalation

Add the Orderable package to your composer.json file., (*2)

{
    "require": {
        "zigastrgar/orderable": "^1.0"
    }
}

OR, (*3)

Simply run this in command line, (*4)

composer require zigastrgar/orderable

Usage

Go to any model and add this to the model., (*5)

use ZigaStrgar\Orderable\Orderable;

class Article extends Model {
    use Orderable;

    public function orderable(){
        return [
            'id' => 'DESC',
            'title' => 'ASC',
            'user_id'
        ];
    }
}

If you don't use the key like in user_id case it will default to DESC., (*6)

Running "Orderable"

It's super simple., (*7)

Article::all();

Apply only specific rule

From now on, you can also do something like this., (*8)

Article::order(); //Equals to Article::all();

or, (*9)

Article::order(['title']);

and only rule for title will bi applied., (*10)

Running without "Orderable"

Same. Very simple stuff., (*11)

Article::unorderable();

No scopes applied., (*12)

Remove specific rule

Article::unorderable(['title']);

In this case the rule for title won't be applied., (*13)

The Versions

08/10 2016

dev-master

9999999-dev https://github.com/ZigaStrgar/orderable

Ordering package for Laravel 5.x

  Sources   Download

MIT

The Requires

 

The Development Requires

by ZigaStrgar

08/10 2016

v1.1.0

1.1.0.0 https://github.com/ZigaStrgar/orderable

Ordering package for Laravel 5.x

  Sources   Download

MIT

The Requires

 

The Development Requires

by ZigaStrgar