Skip to content

Commit 5c2b9de

Browse files
committed
Push initial implementations of new repository structure
This breaks almost the entire panel, do not pull this branch in this state. Mostly just moved old repository files to a new folder without updating anything else in order to start doing new things. Structure is not finalized.
1 parent 65957e7 commit 5c2b9de

39 files changed

+1084
-167
lines changed

app/Console/Commands/MakeUser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
namespace Pterodactyl\Console\Commands;
2626

2727
use Illuminate\Console\Command;
28-
use Pterodactyl\Repositories\UserRepository;
28+
use Pterodactyl\Repositories\oldUserRepository;
2929

3030
class MakeUser extends Command
3131
{
@@ -80,7 +80,7 @@ public function handle()
8080
$data['root_admin'] = is_null($this->option('admin')) ? $this->confirm('Is this user a root administrator?') : $this->option('admin');
8181

8282
try {
83-
$user = new UserRepository;
83+
$user = new oldUserRepository;
8484
$user->create($data);
8585

8686
return $this->info('User successfully created.');
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/*
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Contracts\Criteria;
26+
27+
use Pterodactyl\Repositories\Repository;
28+
29+
interface CriteriaInterface
30+
{
31+
/**
32+
* Apply selected criteria to a repository call.
33+
*
34+
* @param \Illuminate\Database\Eloquent\Model $model
35+
* @param \Pterodactyl\Repositories\Repository $repository
36+
* @return mixed
37+
*/
38+
public function apply($model, Repository $repository);
39+
}
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<?php
2+
/*
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Contracts\Repositories;
26+
27+
use Illuminate\Container\Container;
28+
29+
interface RepositoryInterface
30+
{
31+
/**
32+
* RepositoryInterface constructor.
33+
*
34+
* @param \Illuminate\Container\Container $container
35+
*/
36+
public function __construct(Container $container);
37+
38+
/**
39+
* Define the model class to be loaded.
40+
*
41+
* @return string
42+
*/
43+
public function model();
44+
45+
/**
46+
* Returns the raw model class.
47+
*
48+
* @return \Illuminate\Database\Eloquent\Model
49+
*/
50+
public function getModel();
51+
52+
/**
53+
* Make the model instance.
54+
*
55+
* @return \Illuminate\Database\Eloquent\Model
56+
* @throws \Pterodactyl\Exceptions\Repository\RepositoryException
57+
*/
58+
public function makeModel();
59+
60+
/**
61+
* Return all of the currently defined rules.
62+
*
63+
* @return array
64+
*/
65+
public function getRules();
66+
67+
/**
68+
* Return the rules to apply when updating a model.
69+
*
70+
* @return array
71+
*/
72+
public function getUpdateRules();
73+
74+
/**
75+
* Return the rules to apply when creating a model.
76+
*
77+
* @return array
78+
*/
79+
public function getCreateRules();
80+
81+
/**
82+
* Add relations to a model for retrieval.
83+
*
84+
* @param array $params
85+
* @return $this
86+
*/
87+
public function with(...$params);
88+
89+
/**
90+
* Add count of related items to model when retrieving.
91+
*
92+
* @param array $params
93+
* @return $this
94+
*/
95+
public function withCount(...$params);
96+
97+
/**
98+
* Get all records from the database.
99+
*
100+
* @param array $columns
101+
* @return mixed
102+
*/
103+
public function all(array $columns = ['*']);
104+
105+
/**
106+
* Return a paginated result set.
107+
*
108+
* @param int $limit
109+
* @param array $columns
110+
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
111+
*/
112+
public function paginate($limit = 15, array $columns = ['*']);
113+
114+
/**
115+
* Create a new record on the model.
116+
*
117+
* @param array $data
118+
* @return \Illuminate\Database\Eloquent\Model
119+
*/
120+
public function create(array $data);
121+
122+
/**
123+
* Update the model.
124+
*
125+
* @param $attributes
126+
* @param array $data
127+
* @return int
128+
*/
129+
public function update($attributes, array $data);
130+
131+
/**
132+
* Delete a model from the database. Handles soft deletion.
133+
*
134+
* @param int $id
135+
* @return mixed
136+
*/
137+
public function delete($id);
138+
139+
/**
140+
* Destroy the model from the database. Ignores soft deletion.
141+
*
142+
* @param int $id
143+
* @return mixed
144+
*/
145+
public function destroy($id);
146+
147+
/**
148+
* Find a given model by ID or IDs.
149+
*
150+
* @param int|array $id
151+
* @param array $columns
152+
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection
153+
*/
154+
public function find($id, array $columns = ['*']);
155+
156+
/**
157+
* Finds the first record matching a passed array of values.
158+
*
159+
* @param array $attributes
160+
* @param array $columns
161+
* @return \Illuminate\Database\Eloquent\Model
162+
*/
163+
public function findBy(array $attributes, array $columns = ['*']);
164+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/*
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Contracts\Repositories;
26+
27+
interface SearchableRepositoryInterface extends RepositoryInterface
28+
{
29+
/**
30+
* Pass parameters to search trait on model.
31+
*
32+
* @param string $term
33+
* @return mixed
34+
*/
35+
public function search($term);
36+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/*
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Contracts\Repositories;
26+
27+
interface UserInterface extends RepositoryInterface, SearchableRepositoryInterface
28+
{
29+
//
30+
}

app/Exceptions/DisplayException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
use Log;
2828

29-
class DisplayException extends \Exception
29+
class DisplayException extends PterodactylException
3030
{
3131
/**
3232
* Exception constructor.

app/Exceptions/DisplayValidationException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
namespace Pterodactyl\Exceptions;
2626

27-
class DisplayValidationException extends \Exception
27+
class DisplayValidationException extends PterodactylException
2828
{
2929
//
3030
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/*
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Exceptions;
26+
27+
class PterodactylException extends \Exception
28+
{
29+
//
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/*
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Exceptions\Repository;
26+
27+
class RepositoryException extends \Exception
28+
{
29+
//
30+
}

0 commit comments

Comments
 (0)