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