Skip to content

Commit 791ba55

Browse files
barryvdhlaravel-ide-helper
andauthored
Add meta override for user return types (#1642)
* Add meta override for user return types * composer fix-style --------- Co-authored-by: laravel-ide-helper <laravel-ide-helper@users.noreply.github.com>
1 parent c324438 commit 791ba55

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

resources/views/meta.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
]));
2222
<?php endforeach; ?>
2323

24+
<?php foreach ($userMethods as $method) : ?>
25+
override(<?= $method ?>, map([
26+
'' => \<?= $userModel ?>::class,
27+
]));
28+
<?php endforeach; ?>
29+
2430
<?php foreach ($configMethods as $method) : ?>
2531
override(<?= $method ?>, map([
2632
<?php foreach ($configValues as $name => $value) : ?>

src/Console/MetaCommand.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ class MetaCommand extends Command
7373
'\Illuminate\Support\Facades\Config::set()',
7474
];
7575

76+
protected $userMethods = [
77+
'\auth()->user()',
78+
'\Illuminate\Contracts\Auth\Guard::user()',
79+
'\Illuminate\Support\Facades\Auth::user()',
80+
'\request()->user()',
81+
'\Illuminate\Http\Request::user()',
82+
'\Illuminate\Support\Facades\Request::user()',
83+
];
84+
7685
protected $templateCache = [];
7786

7887
/**
@@ -135,6 +144,8 @@ public function handle()
135144
return gettype($value);
136145
});
137146

147+
$defaultUserModel = $this->config->get('auth.providers.users.model', $this->config->get('auth.model', 'App\User'));
148+
138149
$content = $this->view->make('ide-helper::meta', [
139150
'bindings' => $bindings,
140151
'methods' => $this->methods,
@@ -143,6 +154,8 @@ public function handle()
143154
'configValues' => $configValues,
144155
'expectedArgumentSets' => $this->getExpectedArgumentSets(),
145156
'expectedArguments' => $this->getExpectedArguments(),
157+
'userModel' => $defaultUserModel,
158+
'userMethods' => $this->userMethods,
146159
])->render();
147160

148161
$filename = $this->option('filename');

0 commit comments

Comments
 (0)