generated from spatie/package-skeleton-laravel
-
-
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.
New Feat: Generate Views together with Tests
- Added a view generator - Added an optional test generator for the view - BUG FIX: Added missing stubs in Commands - BUG FIX: Look for stubs in Commands as well as a fallback for all generators
- Loading branch information
1 parent
052332f
commit c8c41ed
Showing
61 changed files
with
1,266 additions
and
5 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
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,41 @@ | ||
<?php | ||
|
||
namespace Savannabits\Modular\Commands; | ||
|
||
use Illuminate\Support\Str; | ||
use Savannabits\Modular\Facades\Modular; | ||
use Savannabits\Modular\Support\Concerns\GeneratesModularFiles; | ||
|
||
class ViewMakeCommand extends \Illuminate\Foundation\Console\ViewMakeCommand | ||
{ | ||
use GeneratesModularFiles; | ||
protected $name = 'modular:make-view'; | ||
|
||
protected $description = 'Create a new view file in a modular package'; | ||
|
||
protected function getPath($name) | ||
{ | ||
return $this->viewPath( | ||
$this->getNameInput().'.'.$this->option('extension'), | ||
); | ||
} | ||
|
||
protected function getTestPath(): string | ||
{ | ||
return $this->getModule()->path( | ||
Str::of($this->testClassFullyQualifiedName()) | ||
->replace('\\', '/') | ||
->replaceFirst('Tests/Feature', 'tests/Feature') | ||
->append('Test.php') | ||
->value() | ||
); | ||
} | ||
|
||
protected function getTestStub(): string | ||
{ | ||
$stubName = 'view.'.($this->usingPest() ? 'pest' : 'test').'.stub'; | ||
$stubName = '/stubs/'.$stubName; | ||
|
||
return parent::resolveStubPath($stubName); | ||
} | ||
} |
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 | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Route; | ||
|
||
Route::get('/user', function (Request $request) { | ||
return $request->user(); | ||
})->middleware('auth:sanctum'); |
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,7 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Broadcast; | ||
|
||
Broadcast::channel('App.Models.User.{id}', function ($user, $id) { | ||
return (int) $user->id === (int) $id; | ||
}); |
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,19 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes; | ||
|
||
class {{ class }} implements CastsInboundAttributes | ||
{ | ||
/** | ||
* 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,29 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||
|
||
class {{ class }} 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,24 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use {{ namespacedUserModel }}; | ||
|
||
class {{ class }} | ||
{ | ||
/** | ||
* Create a new channel instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Authenticate the user's access to the channel. | ||
*/ | ||
public function join({{ userModel }} $user): array|bool | ||
{ | ||
// | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
class {{ class }} | ||
{ | ||
/** | ||
* Create a new class instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Invoke the class instance. | ||
*/ | ||
public function __invoke(): 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
class {{ class }} | ||
{ | ||
/** | ||
* Create a new class instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class {{ class }} extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = '{{ command }}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Command description'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
// | ||
} | ||
} |
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,7 @@ | ||
/** | ||
* Echo exposes an expressive API for subscribing to channels and listening | ||
* for events that are broadcast by Laravel. Echo and event broadcasting | ||
* allow your team to quickly build robust real-time web applications. | ||
*/ | ||
|
||
import './echo'; |
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 @@ | ||
import Echo from 'laravel-echo'; | ||
|
||
import Pusher from 'pusher-js'; | ||
window.Pusher = Pusher; | ||
|
||
window.Echo = new Echo({ | ||
broadcaster: 'reverb', | ||
key: import.meta.env.VITE_REVERB_APP_KEY, | ||
wsHost: import.meta.env.VITE_REVERB_HOST, | ||
wsPort: import.meta.env.VITE_REVERB_PORT ?? 80, | ||
wssPort: import.meta.env.VITE_REVERB_PORT ?? 443, | ||
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https', | ||
enabledTransports: ['ws', 'wss'], | ||
}); |
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 {{ namespace }}; | ||
|
||
enum {{ class }}: {{ type }} | ||
{ | ||
// | ||
} |
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 {{ namespace }}; | ||
|
||
enum {{ class }} | ||
{ | ||
// | ||
} |
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 {{ namespace }}; | ||
|
||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class {{ class }} | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return array<int, \Illuminate\Broadcasting\Channel> | ||
*/ | ||
public function broadcastOn(): array | ||
{ | ||
return [ | ||
new PrivateChannel('channel-name'), | ||
]; | ||
} | ||
} |
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 {{ namespace }}; | ||
|
||
use Exception; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
|
||
class {{ class }} extends Exception | ||
{ | ||
/** | ||
* Report the exception. | ||
*/ | ||
public function report(): void | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Render the exception as an HTTP response. | ||
*/ | ||
public function render(Request $request): Response | ||
{ | ||
// | ||
} | ||
} |
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 Exception; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
|
||
class {{ class }} extends Exception | ||
{ | ||
/** | ||
* Render the exception as an HTTP response. | ||
*/ | ||
public function render(Request $request): Response | ||
{ | ||
// | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Exception; | ||
|
||
class {{ class }} extends Exception | ||
{ | ||
/** | ||
* Report the exception. | ||
*/ | ||
public function report(): 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Exception; | ||
|
||
class {{ class }} extends Exception | ||
{ | ||
// | ||
} |
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 {{ namespace }}; | ||
|
||
interface {{ class }} | ||
{ | ||
// | ||
} |
Oops, something went wrong.