-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Гарбуз Иван
committed
Oct 23, 2021
1 parent
0bfc820
commit b73123f
Showing
18 changed files
with
291 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Garbuzivan\Laraveltokens\Commands; | ||
|
||
use Carbon\Carbon; | ||
use Garbuzivan\Laraveltokens\Exceptions\UserNotExistsException; | ||
use Garbuzivan\Laraveltokens\TokenManager; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Composer; | ||
|
||
class CreateGlobalTokenCommand extends Command | ||
{ | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'tokens:global-create {title} {day}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Создать новый токен (tokens:create {title} {количество дней действия или 0 - бессрочно})'; | ||
|
||
/** | ||
* The console command signature. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'tokens:global-create {title} {day}'; | ||
|
||
/** | ||
* @var Composer | ||
*/ | ||
public Composer $composer; | ||
|
||
/** | ||
* @var TokenManager | ||
*/ | ||
public TokenManager $TokenManager; | ||
|
||
/** | ||
* Create a new command instance. | ||
*/ | ||
public function __construct(TokenManager $TokenManager) | ||
{ | ||
parent::__construct(); | ||
$this->TokenManager = $TokenManager; | ||
} | ||
|
||
/** | ||
* Execute the command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$arguments = $this->arguments(); | ||
$title = $arguments['title'] ?? date('Y-m-d H:i:s'); | ||
$day = intval($arguments['day']); | ||
$expiration = $day > 0 ? Carbon::now()->addDays($day) : null; | ||
$token = $this->TokenManager->createGlobalToken($title, $expiration); | ||
$date = is_null($expiration) ? 'навсегда' : 'до ' . $expiration->format('Y-m-d H:i:s'); | ||
$this->line('Глобальный токен ' . $token->token . ' создан '. $date . '.'); | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Garbuzivan\Laraveltokens\Interfaces; | ||
|
||
interface ModelToken | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.