laravel-shift/blueprint

Add type hints to event classes

faustbrian opened this issue · 0 comments

Synopsis:

Event classes are currently generated without type hints while most (all?) other classes have type hints. Either the type could be specified via @TYPE or we could derive it from the controller name like is done for other things. The latter wouldn't require any syntax changes but only support type hints for the model, not other properties.

Proposed Syntax:

controllers:
  Ticket:
    store:
      fire: NewTicket with:ticket@Ticket
<?php

namespace App\Events;

use Illuminate\Queue\SerializesModels;

class NewTicket
{
    use SerializesModels;

    public $ticket;

    /**
     * Create a new event instance.
     */
    public function __construct($ticket)
    {
        $this->ticket = $ticket;
    }
}

Expected Behavior:

<?php

namespace App\Events;

use App\Models\Ticket;
use Illuminate\Queue\SerializesModels;

class NewTicket
{
    use SerializesModels;

    public Ticket $ticket;

    /**
     * Create a new event instance.
     */
    public function __construct(Ticket $ticket)
    {
        $this->ticket = $ticket;
    }
}