|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ianrizky\Illuminate\Database\Eloquent; |
|
4
|
|
|
|
|
5
|
|
|
use Ianrizky\Illuminate\Database\Query\Builder as QueryBuilder; |
|
6
|
|
|
use Illuminate\Database\Eloquent\Model as BaseModel; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @property int $id |
|
10
|
|
|
* @method static \Ianrizky\Illuminate\Database\Eloquent\Builder on(string|null $connection) Begin querying the model on a given connection. |
|
11
|
|
|
* @method static \Ianrizky\Illuminate\Database\Query\Builder onWriteConnection() Begin querying the model on the write connection. |
|
12
|
|
|
* @method static \Ianrizky\Illuminate\Database\Eloquent\Builder with(array|string $relations) Begin querying a model with eager loading. |
|
13
|
|
|
* @method static \Ianrizky\Illuminate\Database\Eloquent\Builder query() Begin querying the model. |
|
14
|
|
|
* @method \Ianrizky\Illuminate\Database\Eloquent\Builder newQuery() Get a new query builder for the model's table. |
|
15
|
|
|
* @method \Ianrizky\Illuminate\Database\Eloquent\Builder|static newModelQuery() Get a new query builder that doesn't have any global scopes or eager loading. |
|
16
|
|
|
* @method \Ianrizky\Illuminate\Database\Eloquent\Builder newQueryWithoutRelationships() Get a new query builder with no relationships loaded. |
|
17
|
|
|
* @method \Ianrizky\Illuminate\Database\Eloquent\Builder registerGlobalScopes(\Ianrizky\Illuminate\Database\Eloquent\Builder $builder) Register the global scopes for this builder instance. |
|
18
|
|
|
* @method \Ianrizky\Illuminate\Database\Eloquent\Builder|static newQueryWithoutScopes() Get a new query builder that doesn't have any global scopes. |
|
19
|
|
|
* @method \Ianrizky\Illuminate\Database\Eloquent\Builder newQueryWithoutScope(\Illuminate\Database\Eloquent\Scope|string $scope) Get a new query instance without a given scope. |
|
20
|
|
|
* @method \Ianrizky\Illuminate\Database\Eloquent\Builder newQueryForRestoration(array|int $ids) Get a new query to restore one or more models by their queueable IDs. |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class Model extends BaseModel |
|
23
|
|
|
{ |
|
24
|
|
|
use Concerns\HandleModel, |
|
|
|
|
|
|
25
|
|
|
Concerns\HasAttributes, |
|
26
|
|
|
Concerns\HasTimestamps, |
|
27
|
|
|
Concerns\Tappable, |
|
28
|
|
|
Docblock\EloquentBuilder; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritDoc} |
|
32
|
|
|
* |
|
33
|
|
|
* @param \Ianrizky\Illuminate\Database\Query\Builder $query |
|
34
|
|
|
* @return \Ianrizky\Illuminate\Database\Eloquent\Builder|static |
|
35
|
|
|
*/ |
|
36
|
|
|
public function newEloquentBuilder($query): Builder |
|
37
|
|
|
{ |
|
38
|
|
|
return new Builder($query); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritDoc} |
|
43
|
|
|
* |
|
44
|
|
|
* @return \Ianrizky\Illuminate\Database\Query\Builder |
|
45
|
|
|
*/ |
|
46
|
|
|
protected function newBaseQueryBuilder(): QueryBuilder |
|
47
|
|
|
{ |
|
48
|
|
|
return parent::newBaseQueryBuilder(); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* {@inheritDoc} |
|
53
|
|
|
* |
|
54
|
|
|
* @return \Ianrizky\Illuminate\Database\Eloquent\Collection |
|
55
|
|
|
*/ |
|
56
|
|
|
public function newCollection(array $models = []): Collection |
|
57
|
|
|
{ |
|
58
|
|
|
return new Collection($models); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|