luilliarcec /
laravel-user-commands
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Luilliarcec\UserCommands\Commands; |
||
| 4 | |||
| 5 | use Illuminate\Console\Command; |
||
| 6 | |||
| 7 | class UserCommand extends Command |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var \Illuminate\Foundation\Auth\User|string|null |
||
| 11 | */ |
||
| 12 | protected $user; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var \Illuminate\Database\Eloquent\Model|string|null |
||
| 16 | */ |
||
| 17 | protected $permission; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var \Illuminate\Database\Eloquent\Model|string|null |
||
| 21 | */ |
||
| 22 | protected $role; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * UserCommand constructor. |
||
| 26 | */ |
||
| 27 | public function __construct() |
||
| 28 | { |
||
| 29 | parent::__construct(); |
||
| 30 | |||
| 31 | $this->user = config('user-commands.user'); |
||
| 32 | $this->permission = config('user-commands.permission.model'); |
||
| 33 | $this->role = config('user-commands.role.model'); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Create a new user instance |
||
| 38 | * |
||
| 39 | * @return mixed |
||
| 40 | */ |
||
| 41 | protected function newUserInstance() |
||
| 42 | { |
||
| 43 | return new $this->user; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Create a new permission instance |
||
| 48 | * |
||
| 49 | * @return mixed |
||
| 50 | */ |
||
| 51 | protected function newPermissionInstance() |
||
| 52 | { |
||
| 53 | return new $this->permission; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Create a new role instance |
||
| 58 | * |
||
| 59 | * @return mixed |
||
| 60 | */ |
||
| 61 | protected function newRoleInstance() |
||
| 62 | { |
||
| 63 | return new $this->role; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Get user model |
||
| 68 | * |
||
| 69 | * @return \Illuminate\Database\Eloquent\Model|null |
||
| 70 | */ |
||
| 71 | protected function getUserModel() |
||
| 72 | { |
||
| 73 | $value = $this->argument('value'); |
||
| 74 | $field = $this->argument('field'); |
||
| 75 | |||
| 76 | if ($field) { |
||
| 77 | return $this->user::query() |
||
|
0 ignored issues
–
show
|
|||
| 78 | ->where($field, $value) |
||
| 79 | ->first(); |
||
| 80 | } |
||
| 81 | |||
| 82 | return $this->user::query() |
||
| 83 | ->where('email', $value) |
||
| 84 | ->first() ?: $this->user::query()->find($value); |
||
| 85 | } |
||
| 86 | } |
||
| 87 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.