mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 06:26:16 +00:00
wip
This commit is contained in:
32
app/Cli/Commands/AbstractCommand.php
Normal file
32
app/Cli/Commands/AbstractCommand.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cli\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use function Laravel\Prompts\error;
|
||||
|
||||
abstract class AbstractCommand extends Command
|
||||
{
|
||||
private User|null $user = null;
|
||||
|
||||
public function user()
|
||||
{
|
||||
if ($this->user) {
|
||||
return $this->user->refresh();
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = User::query()->first();
|
||||
|
||||
if (!$user) {
|
||||
error('The application is not setup');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$this->user = $user;
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user