forked from nishangupta/Mart
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Showing
11 changed files
with
326 additions
and
176 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\User; | ||
use Illuminate\Console\Command; | ||
use Laravel\Pennant\FeatureManager; | ||
|
||
class VipActivate extends Command | ||
{ | ||
protected $signature = 'app:vip:activate {emails*}'; | ||
|
||
protected $description = 'Activate VIP permission'; | ||
|
||
public function handle(User $userModel, FeatureManager $feature): int | ||
{ | ||
$users = $userModel->newQuery() | ||
->select('id', 'email') | ||
->whereIn('email', $this->argument('emails')) | ||
->get(); | ||
|
||
$feature->for($users)->activate('vip'); | ||
|
||
return self::SUCCESS; | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\User; | ||
use Illuminate\Console\Command; | ||
use Laravel\Pennant\FeatureManager; | ||
|
||
class VipDeactivate extends Command | ||
{ | ||
protected $signature = 'app:vip:deactivate {emails*}'; | ||
|
||
protected $description = 'Deactivate VIP permission'; | ||
|
||
public function handle(User $userModel, FeatureManager $feature): int | ||
{ | ||
$users = $userModel->newQuery() | ||
->select('id', 'email') | ||
->whereIn('email', $this->argument('emails')) | ||
->get(); | ||
|
||
$feature->for($users)->deactivate('vip'); | ||
|
||
return self::SUCCESS; | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\User; | ||
use Illuminate\Console\Command; | ||
use Laravel\Pennant\Feature; | ||
|
||
class VipStatus extends Command | ||
{ | ||
protected $signature = 'app:vip:status {emails*}'; | ||
|
||
protected $description = 'Inspect VIP status'; | ||
|
||
public function handle(User $userModel): int | ||
{ | ||
$emails = $this->argument('emails'); | ||
|
||
$users = $userModel->newQuery() | ||
->select('id', 'email') | ||
->whereIn('email', $emails) | ||
->get(); | ||
|
||
Feature::for($users)->load('vip'); | ||
|
||
$status = $users->map(function (User $user) { | ||
$user['vip'] = $user->features()->active('vip') ? 'ON' : 'OFF'; | ||
|
||
return $user->toArray(); | ||
}); | ||
|
||
$this->table(['ID', 'Email', 'status'], $status->toArray()); | ||
|
||
return self::SUCCESS; | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace App\Features; | ||
|
||
use Illuminate\Support\Lottery; | ||
|
||
class Vip | ||
{ | ||
public readonly string $name; | ||
|
||
public function __construct() | ||
{ | ||
$this->name = 'vip'; | ||
} | ||
|
||
public function resolve(mixed $scope): bool | ||
{ | ||
return false; | ||
} | ||
} |
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.