Skip to content

Commit 5b4a65a

Browse files
committed
[L6] Break search functionality without breaking the entire app
1 parent c97461d commit 5b4a65a

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Pterodactyl\Extensions\Illuminate\Database\Eloquent;
4+
5+
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
6+
7+
class Builder extends EloquentBuilder
8+
{
9+
/**
10+
* Do nothing.
11+
*
12+
* @return $this
13+
*/
14+
public function search()
15+
{
16+
return $this;
17+
}
18+
}

app/Models/Node.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace Pterodactyl\Models;
44

55
use Illuminate\Notifications\Notifiable;
6+
use Pterodactyl\Models\Traits\Searchable;
67

78
class Node extends Validable
89
{
9-
use Notifiable;
10+
use Notifiable, Searchable;
1011

1112
/**
1213
* The resource name for this model when it is transformed into an

app/Models/Pack.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
namespace Pterodactyl\Models;
44

5+
use Pterodactyl\Models\Traits\Searchable;
6+
57
class Pack extends Validable
68
{
9+
use Searchable;
10+
711
/**
812
* The resource name for this model when it is transformed into an
913
* API representation using fractal.

app/Models/Server.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Schema;
66
use Illuminate\Notifications\Notifiable;
7+
use Pterodactyl\Models\Traits\Searchable;
78
use Znck\Eloquent\Traits\BelongsToThrough;
89

910
/**
@@ -52,7 +53,7 @@
5253
*/
5354
class Server extends Validable
5455
{
55-
use BelongsToThrough, Notifiable;
56+
use BelongsToThrough, Notifiable, Searchable;
5657

5758
/**
5859
* The resource name for this model when it is transformed into an

app/Models/Traits/Searchable.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Pterodactyl\Models\Traits;
4+
5+
use Pterodactyl\Extensions\Illuminate\Database\Eloquent\Builder;
6+
7+
trait Searchable
8+
{
9+
public function newEloquentBuilder($query)
10+
{
11+
return new Builder($query);
12+
}
13+
}

app/Models/User.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Validation\Rules\In;
88
use Illuminate\Auth\Authenticatable;
99
use Illuminate\Notifications\Notifiable;
10+
use Pterodactyl\Models\Traits\Searchable;
1011
use Illuminate\Auth\Passwords\CanResetPassword;
1112
use Pterodactyl\Traits\Helpers\AvailableLanguages;
1213
use Illuminate\Foundation\Auth\Access\Authorizable;
@@ -20,7 +21,7 @@ class User extends Validable implements
2021
AuthorizableContract,
2122
CanResetPasswordContract
2223
{
23-
use Authenticatable, Authorizable, AvailableLanguages, CanResetPassword, Notifiable;
24+
use Authenticatable, Authorizable, AvailableLanguages, CanResetPassword, Notifiable, Searchable;
2425

2526
const USER_LEVEL_USER = 0;
2627
const USER_LEVEL_ADMIN = 1;

0 commit comments

Comments
 (0)