Alive2212 /
LaravelSmartRestful
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Alive2212\LaravelSmartRestful; |
||
| 4 | |||
| 5 | use Illuminate\Auth\Authenticatable; |
||
| 6 | use Laravel\Lumen\Auth\Authorizable; |
||
|
0 ignored issues
–
show
|
|||
| 7 | use Illuminate\Database\Eloquent\Model; |
||
| 8 | use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; |
||
| 9 | use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; |
||
| 10 | use Laravel\Scout\Searchable; |
||
| 11 | use App\Resources\Reflection\LaravelReflectionHelper; |
||
|
0 ignored issues
–
show
The type
App\Resources\Reflection\LaravelReflectionHelper was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 12 | |||
| 13 | class BaseAuthLumenModel extends Model implements AuthenticatableContract, AuthorizableContract |
||
| 14 | { |
||
| 15 | use Authenticatable, Authorizable,Searchable; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * default relations of method |
||
| 19 | * |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | protected $relation = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * searchable columns in this model |
||
| 26 | * |
||
| 27 | * @var array |
||
| 28 | */ |
||
| 29 | protected $searchableColumns = []; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * searchable columns of one model into this model |
||
| 33 | * |
||
| 34 | * @var array |
||
| 35 | */ |
||
| 36 | protected $searchableInnerColumns = []; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * searchable columns of many model into this model |
||
| 40 | * |
||
| 41 | * @var array |
||
| 42 | */ |
||
| 43 | protected $searchableManyInnerColumns = []; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Get the indexable data array for the model. |
||
| 47 | * |
||
| 48 | * @return array |
||
| 49 | */ |
||
| 50 | public function toSearchableArray() |
||
| 51 | { |
||
| 52 | if (!sizeof($this->searchableColumns)) { |
||
| 53 | $result = collect($this); |
||
| 54 | } else { |
||
| 55 | $result = collect([ |
||
| 56 | 'id' => $this['id'], |
||
| 57 | ]); |
||
| 58 | foreach ($this->searchableColumns as $searchableColumn) { |
||
| 59 | $result->put($searchableColumn, collect($this)->get($searchableColumn)); |
||
| 60 | } |
||
| 61 | } |
||
| 62 | if (sizeof($this->searchableInnerColumns)) { |
||
| 63 | foreach ($this->searchableInnerColumns as $searchableInnerColumnKey => $searchableInnerColumnValue) { |
||
| 64 | $searchableInnerColumnKey = explode('-', $searchableInnerColumnKey)[0]; |
||
| 65 | $innerModels = explode('.', $searchableInnerColumnKey); |
||
| 66 | $values = $this; |
||
| 67 | foreach ($innerModels as $innerModel) { |
||
| 68 | $values = $values->{$innerModel}; |
||
| 69 | } |
||
| 70 | $values = collect($values); |
||
| 71 | $result->put($searchableInnerColumnKey . '-' . $searchableInnerColumnValue, |
||
| 72 | collect($values)->get($searchableInnerColumnValue)); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | if (sizeof($this->searchableManyInnerColumns)) { |
||
| 76 | foreach ($this->searchableManyInnerColumns as $searchableInnerColumnKey => $searchableInnerColumnValue) { |
||
| 77 | $searchableInnerColumnKey = explode('-', $searchableInnerColumnKey)[0]; |
||
| 78 | $innerModels = explode('.', $searchableInnerColumnKey); |
||
| 79 | $values = $this; |
||
| 80 | foreach ($innerModels as $innerModel) { |
||
| 81 | $values = $values->{$innerModel}; |
||
| 82 | } |
||
| 83 | $values = collect($values); |
||
| 84 | $counter = 0; |
||
| 85 | foreach ($values as $value) { |
||
| 86 | $result->put($searchableInnerColumnKey . '-' . $searchableInnerColumnValue . '-' . $counter, |
||
| 87 | collect($value)->get($searchableInnerColumnValue)); |
||
| 88 | $counter++; |
||
| 89 | } |
||
| 90 | } |
||
| 91 | } |
||
| 92 | return $result->toArray(); |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * get methods names of child class in array type |
||
| 97 | * |
||
| 98 | * @return array |
||
| 99 | */ |
||
| 100 | public function getMethods() |
||
| 101 | { |
||
| 102 | return (new LaravelReflectionHelper())->getClassMethodsNames($this,\ReflectionMethod::IS_PUBLIC); |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @return array |
||
| 107 | */ |
||
| 108 | public function getRelatedMethods() |
||
| 109 | { |
||
| 110 | return (new LaravelReflectionHelper())->getClassRelationMethodsNames($this); |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @return mixed |
||
| 115 | */ |
||
| 116 | public function withRelation() |
||
| 117 | { |
||
| 118 | return $this->with($this->getRelatedMethods()); |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @return mixed |
||
| 123 | */ |
||
| 124 | public function loadRelation() |
||
| 125 | { |
||
| 126 | return $this->load($this->getRelatedMethods()); |
||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Determine if the entity has a given ability. |
||
| 131 | * |
||
| 132 | * @param string $ability |
||
| 133 | * @param array|mixed $arguments |
||
| 134 | * @return bool |
||
| 135 | */ |
||
| 136 | public function can($ability, $arguments = []) |
||
| 137 | { |
||
| 138 | // TODO: Implement can() method. |
||
| 139 | } |
||
| 140 | } |
||
| 141 | |||
| 142 | |||
| 143 | |||
| 144 | |||
| 145 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths