File tree Expand file tree Collapse file tree 6 files changed +125
-0
lines changed
Expand file tree Collapse file tree 6 files changed +125
-0
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,18 @@ php artisan beyond:make:controller Admin/Users/UserController
3030# Creates an enum at Domain/Users/Enums/UserStatusEnum
3131php artisan beyond:make:enum Users/UserStatusEnum
3232
33+ # Creates an event at Domain/Users/Events/UserCreatedEvent
34+ php artisan beyond:make:event Users/UserCreatedEvent
35+
3336# Creates a data transfer object at Domain/Users/DataTransferObjects/UserData (requires spatie/data-transfer-object)
3437php artisan beyond:make:dto Users/UserData
3538
3639# Creates a job at App/Admin/Users/Jobs/SyncUsersJob
3740php artisan beyond:make:job Admin/Users/SyncUsersJob
3841
42+ # Creates a listener at Doamin/Users/Listeners/UserCreatedListener
43+ php artisan beyond:make:listener Users/Listeners/UserCreatedListener
44+
3945# Creates a model at Domain/Users/Models/User
4046php artisan beyond:make:model Users/User
4147
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Regnerisch \LaravelBeyond \Commands ;
4+
5+ use Illuminate \Console \Command ;
6+ use Regnerisch \LaravelBeyond \Resolvers \DomainNameSchemaResolver ;
7+
8+ class MakeEventCommand extends Command
9+ {
10+ protected $ signature = 'beyond:make:event {name} ' ;
11+
12+ protected $ description = 'Make a new event ' ;
13+
14+ public function handle (): void
15+ {
16+ try {
17+ $ name = $ this ->argument ('name ' );
18+
19+ $ schema = new DomainNameSchemaResolver ($ name );
20+
21+ beyond_copy_stub (
22+ 'event.stub ' ,
23+ base_path () . '/src/Domain/ ' . $ schema ->getPath ('Events ' ) . '.php ' ,
24+ [
25+ '{{ domain }} ' => $ schema ->getDomainName (),
26+ '{{ className }} ' => $ schema ->getClassName (),
27+ ]
28+ );
29+
30+ $ this ->info ("Event created. " );
31+ } catch (\Exception $ exception ) {
32+ $ this ->error ($ exception ->getMessage ());
33+ }
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Regnerisch \LaravelBeyond \Commands ;
4+
5+ use Illuminate \Console \Command ;
6+ use Regnerisch \LaravelBeyond \Resolvers \DomainNameSchemaResolver ;
7+
8+ class MakeListenerCommand extends Command
9+ {
10+ protected $ signature = 'beyond:make:listener {name} ' ;
11+
12+ protected $ description = 'Make a new listener ' ;
13+
14+ public function handle (): void
15+ {
16+ try {
17+ $ name = $ this ->argument ('name ' );
18+
19+ $ schema = new DomainNameSchemaResolver ($ name );
20+
21+ beyond_copy_stub (
22+ 'listener.stub ' ,
23+ base_path () . '/src/Domain/ ' . $ schema ->getPath ('Listeners ' ) . '.php ' ,
24+ [
25+ '{{ domain }} ' => $ schema ->getDomainName (),
26+ '{{ className }} ' => $ schema ->getClassName (),
27+ ]
28+ );
29+
30+ $ this ->info ("Listener created. " );
31+ } catch (\Exception $ exception ) {
32+ $ this ->error ($ exception ->getMessage ());
33+ }
34+ }
35+ }
Original file line number Diff line number Diff line change 99use Regnerisch \LaravelBeyond \Commands \MakeControllerCommand ;
1010use Regnerisch \LaravelBeyond \Commands \MakeDataTransferObjectCommand ;
1111use Regnerisch \LaravelBeyond \Commands \MakeEnumCommand ;
12+ use Regnerisch \LaravelBeyond \Commands \MakeEventCommand ;
1213use Regnerisch \LaravelBeyond \Commands \MakeJobCommand ;
14+ use Regnerisch \LaravelBeyond \Commands \MakeListenerCommand ;
1315use Regnerisch \LaravelBeyond \Commands \MakeModelCommand ;
1416use Regnerisch \LaravelBeyond \Commands \MakePolicyCommand ;
1517use Regnerisch \LaravelBeyond \Commands \MakeQueryBuilderCommand ;
@@ -32,7 +34,9 @@ public function boot()
3234 MakeControllerCommand::class,
3335 MakeDataTransferObjectCommand::class,
3436 MakeEnumCommand::class,
37+ MakeEventCommand::class,
3538 MakeJobCommand::class,
39+ MakeListenerCommand::class,
3640 MakeModelCommand::class,
3741 MakePolicyCommand::class,
3842 MakeQueryBuilderCommand::class,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Domain\{{ domain }}\Events;
4+
5+ use Illuminate\Broadcasting\Channel;
6+ use Illuminate\Broadcasting\InteractsWithSockets;
7+ use Illuminate\Broadcasting\PresenceChannel;
8+ use Illuminate\Broadcasting\PrivateChannel;
9+ use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
10+ use Illuminate\Foundation\Events\Dispatchable;
11+ use Illuminate\Queue\SerializesModels;
12+
13+ class {{ className }}
14+ {
15+ use Dispatchable, InteractsWithSockets, SerializesModels;
16+
17+ public function __construct()
18+ {
19+ //
20+ }
21+
22+ public function broadcastOn()
23+ {
24+ return new PrivateChannel('channel-name');
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Domain\{{ domain }}\Listeners;
4+
5+ use Illuminate\Contracts\Queue\ShouldQueue;
6+ use Illuminate\Queue\InteractsWithQueue;
7+
8+ class {{ className }}
9+ {
10+ public function __construct()
11+ {
12+ //
13+ }
14+
15+ public function handle($event)
16+ {
17+ //
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments