2017-07-02 21:29:58 -05:00
|
|
|
<?php
|
2017-09-25 21:43:01 -05:00
|
|
|
/**
|
2017-07-02 21:29:58 -05:00
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-25 21:43:01 -05:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-07-02 21:29:58 -05:00
|
|
|
*/
|
|
|
|
|
2017-08-18 22:19:06 -05:00
|
|
|
namespace Pterodactyl\Repositories\Concerns;
|
2017-07-02 21:29:58 -05:00
|
|
|
|
2017-08-18 22:19:06 -05:00
|
|
|
trait Searchable
|
2017-07-02 21:29:58 -05:00
|
|
|
{
|
2017-07-08 14:07:51 -05:00
|
|
|
/**
|
2017-08-18 22:19:06 -05:00
|
|
|
* The term to search.
|
|
|
|
*
|
2017-07-15 11:52:34 -05:00
|
|
|
* @var bool|string
|
|
|
|
*/
|
|
|
|
protected $searchTerm = false;
|
|
|
|
|
|
|
|
/**
|
2017-08-18 22:19:06 -05:00
|
|
|
* Perform a search of the model using the given term.
|
|
|
|
*
|
2017-08-21 22:10:48 -05:00
|
|
|
* @param string $term
|
2017-08-18 22:19:06 -05:00
|
|
|
* @return $this
|
2017-07-08 14:07:51 -05:00
|
|
|
*/
|
2017-07-15 11:52:34 -05:00
|
|
|
public function search($term)
|
|
|
|
{
|
|
|
|
if (empty($term)) {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
$clone = clone $this;
|
|
|
|
$clone->searchTerm = $term;
|
|
|
|
|
|
|
|
return $clone;
|
|
|
|
}
|
2017-07-02 21:29:58 -05:00
|
|
|
}
|