Skip to content

Commit 4dddcae

Browse files
committed
Start ripping out old search functionality for models
1 parent 3c7ffaa commit 4dddcae

16 files changed

+15
-182
lines changed

app/Contracts/Repository/Attributes/SearchableInterface.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

app/Contracts/Repository/LocationRepositoryInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
use Pterodactyl\Models\Location;
66
use Illuminate\Support\Collection;
7-
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
87

9-
interface LocationRepositoryInterface extends RepositoryInterface, SearchableInterface
8+
interface LocationRepositoryInterface extends RepositoryInterface
109
{
1110
/**
1211
* Return locations with a count of nodes and servers attached to it.

app/Contracts/Repository/NodeRepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
99
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
1010

11-
interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterface
11+
interface NodeRepositoryInterface extends RepositoryInterface
1212
{
1313
const THRESHOLD_PERCENTAGE_LOW = 75;
1414
const THRESHOLD_PERCENTAGE_MEDIUM = 90;

app/Contracts/Repository/ServerRepositoryInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
use Pterodactyl\Models\Server;
66
use Illuminate\Support\Collection;
77
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
8-
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
98

10-
interface ServerRepositoryInterface extends RepositoryInterface, SearchableInterface
9+
interface ServerRepositoryInterface extends RepositoryInterface
1110
{
1211
/**
1312
* Returns a listing of all servers that exist including relationships.

app/Contracts/Repository/UserRepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
77
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
88

9-
interface UserRepositoryInterface extends RepositoryInterface, SearchableInterface
9+
interface UserRepositoryInterface extends RepositoryInterface
1010
{
1111
/**
1212
* Return all users with counts of servers and subusers of servers.

app/Models/Node.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Symfony\Component\Yaml\Yaml;
66
use Illuminate\Container\Container;
77
use Illuminate\Notifications\Notifiable;
8-
use Pterodactyl\Models\Traits\Searchable;
98
use Illuminate\Contracts\Encryption\Encrypter;
109

1110
/**
@@ -40,7 +39,6 @@
4039
class Node extends Model
4140
{
4241
use Notifiable;
43-
use Searchable;
4442

4543
/**
4644
* The resource name for this model when it is transformed into an
@@ -95,18 +93,6 @@ class Node extends Model
9593
'description', 'maintenance_mode',
9694
];
9795

98-
/**
99-
* Fields that are searchable.
100-
*
101-
* @var array
102-
*/
103-
protected $searchableColumns = [
104-
'name' => 10,
105-
'fqdn' => 8,
106-
'location.short' => 4,
107-
'location.long' => 4,
108-
];
109-
11096
/**
11197
* @var array
11298
*/
@@ -216,7 +202,7 @@ public function getJsonConfiguration(bool $pretty = false)
216202
*/
217203
public function getDecryptedKey(): string
218204
{
219-
return (string) Container::getInstance()->make(Encrypter::class)->decrypt(
205+
return (string)Container::getInstance()->make(Encrypter::class)->decrypt(
220206
$this->daemon_token
221207
);
222208
}

app/Models/Server.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Pterodactyl\Models;
44

55
use Illuminate\Notifications\Notifiable;
6-
use Pterodactyl\Models\Traits\Searchable;
76
use Illuminate\Database\Query\JoinClause;
87
use Znck\Eloquent\Traits\BelongsToThrough;
98

@@ -58,7 +57,6 @@ class Server extends Model
5857
{
5958
use BelongsToThrough;
6059
use Notifiable;
61-
use Searchable;
6260

6361
/**
6462
* The resource name for this model when it is transformed into an
@@ -154,21 +152,6 @@ class Server extends Model
154152
'backup_limit' => 'integer',
155153
];
156154

157-
/**
158-
* Parameters for search querying.
159-
*
160-
* @var array
161-
*/
162-
protected $searchableColumns = [
163-
'name' => 100,
164-
'uuid' => 80,
165-
'uuidShort' => 80,
166-
'external_id' => 50,
167-
'user.email' => 40,
168-
'user.username' => 30,
169-
'node.name' => 10,
170-
];
171-
172155
/**
173156
* Returns the format for server allocations when communicating with the Daemon.
174157
*

app/Models/Traits/Searchable.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/Models/User.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Illuminate\Auth\Authenticatable;
99
use Illuminate\Notifications\Notifiable;
1010
use Illuminate\Database\Eloquent\Builder;
11-
use Pterodactyl\Models\Traits\Searchable;
1211
use Illuminate\Auth\Passwords\CanResetPassword;
1312
use Pterodactyl\Traits\Helpers\AvailableLanguages;
1413
use Illuminate\Foundation\Auth\Access\Authorizable;
@@ -52,7 +51,6 @@ class User extends Model implements
5251
use AvailableLanguages;
5352
use CanResetPassword;
5453
use Notifiable;
55-
use Searchable;
5654

5755
const USER_LEVEL_USER = 0;
5856
const USER_LEVEL_ADMIN = 1;
@@ -120,20 +118,6 @@ class User extends Model implements
120118
*/
121119
protected $hidden = ['password', 'remember_token', 'totp_secret', 'totp_authenticated_at'];
122120

123-
/**
124-
* Parameters for search querying.
125-
*
126-
* @var array
127-
*/
128-
protected $searchableColumns = [
129-
'username' => 100,
130-
'email' => 100,
131-
'external_id' => 80,
132-
'uuid' => 80,
133-
'name_first' => 40,
134-
'name_last' => 40,
135-
];
136-
137121
/**
138122
* Default values for specific fields in the database.
139123
*

app/Repositories/Concerns/Searchable.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ trait Searchable
1111
*/
1212
protected $searchTerm;
1313

14-
/**
15-
* Set the search term.
16-
*
17-
* @param string|null $term
18-
* @return $this
19-
* @deprecated
20-
*/
21-
public function search($term)
22-
{
23-
return $this->setSearchTerm($term);
24-
}
25-
2614
/**
2715
* Set the search term to use when requesting all records from
2816
* the model.
@@ -41,24 +29,4 @@ public function setSearchTerm(string $term = null)
4129

4230
return $clone;
4331
}
44-
45-
/**
46-
* Determine if a valid search term is set on this repository.
47-
*
48-
* @return bool
49-
*/
50-
public function hasSearchTerm(): bool
51-
{
52-
return ! empty($this->searchTerm);
53-
}
54-
55-
/**
56-
* Return the search term.
57-
*
58-
* @return string|null
59-
*/
60-
public function getSearchTerm()
61-
{
62-
return $this->searchTerm;
63-
}
6432
}

0 commit comments

Comments
 (0)