2020-04-23 00:49:23 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-04-23 00:49:23 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
2020-05-02 02:04:25 +02:00
|
|
|
namespace App\Utils\Traits;
|
2020-04-23 00:49:23 +02:00
|
|
|
|
|
|
|
trait WithSorting
|
|
|
|
{
|
|
|
|
public $sort_field = 'id'; // Default sortBy. Feel free to change or pull from client/company settings.
|
|
|
|
public $sort_asc = true;
|
|
|
|
|
|
|
|
public function sortBy($field)
|
|
|
|
{
|
|
|
|
$this->sort_field === $field
|
2020-09-06 11:38:10 +02:00
|
|
|
? $this->sort_asc = ! $this->sort_asc
|
2020-04-23 00:49:23 +02:00
|
|
|
: $this->sort_asc = true;
|
|
|
|
|
|
|
|
$this->sort_field = $field;
|
|
|
|
}
|
|
|
|
}
|