PHP code example of zigastrgar / orderable

1. Go to this page and download the library: Download zigastrgar/orderable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zigastrgar / orderable example snippets


use ZigaStrgar\Orderable\Orderable;

class Article extends Model {
    use Orderable;
    
    public function orderable(){
        return [
            'id' => 'DESC',
            'title' => 'ASC',
            'user_id'
        ];
    }
}

Article::all();

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

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

Article::unorderable();

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