-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
1 parent
bed01fa
commit 41b5ca6
Showing
16 changed files
with
212 additions
and
11 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
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,13 @@ | ||
# `beyond:make:cast` | ||
Creates a new cast. | ||
|
||
## Signature | ||
`beyond:make:cast {name} {--force}` | ||
|
||
| Parameters | Description | | ||
|------------|-----------------------| | ||
| name | The name of your cast | | ||
|
||
| Flags | Description | | ||
|----------|-------------------------| | ||
| --force | Overwrite existing file | |
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,14 @@ | ||
# `beyond:make:scope` | ||
Creates a new scope. | ||
|
||
## Signature | ||
`beyond:make:scope {name} {--g|global} {--force}` | ||
|
||
| Parameters | Description | | ||
|------------|------------------------| | ||
| name | The name of your scope | | ||
|
||
| Flags | Description | | ||
|----------|-------------------------------------------| | ||
| --global | Creates the scope inside `Support\Scopes` | | ||
| --force | Overwrite existing file | |
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,23 @@ | ||
<?php | ||
|
||
namespace AkrilliA\LaravelBeyond\Commands; | ||
|
||
use AkrilliA\LaravelBeyond\Commands\Abstracts\SupportCommand; | ||
use AkrilliA\LaravelBeyond\Type; | ||
|
||
final class MakeCastCommand extends SupportCommand | ||
{ | ||
protected $signature = 'beyond:make:cast {name} {--force}'; | ||
|
||
protected $description = 'Make a new cast'; | ||
|
||
protected function getStub(): string | ||
{ | ||
return 'cast.stub'; | ||
} | ||
|
||
public function getType(): Type | ||
{ | ||
return new Type('Cast'); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace AkrilliA\LaravelBeyond\Commands; | ||
|
||
use AkrilliA\LaravelBeyond\Commands\Abstracts\DomainCommand; | ||
use AkrilliA\LaravelBeyond\Type; | ||
|
||
final class MakeScopeCommand extends DomainCommand | ||
{ | ||
protected $signature = 'beyond:make:scope {name} {--g|global} {--force}'; | ||
|
||
protected $description = 'Make a new scope'; | ||
|
||
protected function getStub(): string | ||
{ | ||
return 'scope.stub'; | ||
} | ||
|
||
public function getType(): Type | ||
{ | ||
return new Type('Scope'); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class {{ className }} implements CastsAttributes | ||
{ | ||
/** | ||
* Cast the given value. | ||
* | ||
* @param array<string, mixed> $attributes | ||
*/ | ||
public function get(Model $model, string $key, mixed $value, array $attributes): mixed | ||
{ | ||
return $value; | ||
} | ||
|
||
/** | ||
* Prepare the given value for storage. | ||
* | ||
* @param array<string, mixed> $attributes | ||
*/ | ||
public function set(Model $model, string $key, mixed $value, array $attributes): mixed | ||
{ | ||
return $value; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Scope; | ||
|
||
class {{ className }} implements Scope | ||
{ | ||
/** | ||
* Apply the scope to a given Eloquent query builder. | ||
*/ | ||
public function apply(Builder $builder, Model $model): void | ||
{ | ||
// | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
namespace Tests\Commands; | ||
|
||
use Tests\TestCase; | ||
|
||
class MakeCastCommandTest extends TestCase | ||
{ | ||
public function testCanMakeCast(): void | ||
{ | ||
$this->artisan('beyond:make:cast TimezoneCast'); | ||
|
||
$file = beyond_support_path('Casts/TimezoneCast.php'); | ||
$contents = file_get_contents($file); | ||
|
||
$this->assertFileExists($file); | ||
$this->assertStringNotContainsString('{{ namespace }}', $contents); | ||
$this->assertStringNotContainsString('{{ className }}', $contents); | ||
} | ||
|
||
public function testCanMakeCastUsingForce(): void | ||
{ | ||
$this->artisan('beyond:make:cast TimezoneCast'); | ||
|
||
$file = beyond_support_path('Casts/TimezoneCast.php'); | ||
$contents = file_get_contents($file); | ||
|
||
$this->assertFileExists($file); | ||
$this->assertStringNotContainsString('{{ namespace }}', $contents); | ||
$this->assertStringNotContainsString('{{ className }}', $contents); | ||
|
||
$code = $this->artisan('beyond:make:cast TimezoneCast --force'); | ||
|
||
$code->assertOk(); | ||
} | ||
} |
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 Tests\Commands; | ||
|
||
use Tests\TestCase; | ||
|
||
class MakeScopeCommandTest extends TestCase | ||
{ | ||
public function testCanMakeScope(): void | ||
{ | ||
$this->artisan('beyond:make:scope User.ActiveScope'); | ||
|
||
$file = beyond_domain_path('User/Scopes/ActiveScope.php'); | ||
$contents = file_get_contents($file); | ||
|
||
$this->assertFileExists($file); | ||
$this->assertStringNotContainsString('{{ namespace }}', $contents); | ||
$this->assertStringNotContainsString('{{ className }}', $contents); | ||
} | ||
|
||
public function testCanMakeScopeUsingForce(): void | ||
{ | ||
$this->artisan('beyond:make:scope User.ActiveScope'); | ||
|
||
$file = beyond_domain_path('User/Scopes/ActiveScope.php'); | ||
$contents = file_get_contents($file); | ||
|
||
$this->assertFileExists($file); | ||
$this->assertStringNotContainsString('{{ namespace }}', $contents); | ||
$this->assertStringNotContainsString('{{ className }}', $contents); | ||
|
||
$code = $this->artisan('beyond:make:scope User.ActiveScope --force'); | ||
|
||
$code->assertOk(); | ||
} | ||
} |