Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate basic Livewire components with Blueprint #712

Merged
merged 5 commits into from
Dec 11, 2024

Conversation

jasonmccreary
Copy link
Collaborator

@jasonmccreary jasonmccreary commented Dec 11, 2024

This adds basic Livewire component generation to Blueprint.

At the time of merge it supports generating a component with mounted properties and using most of the controller statements.

Here's an example draft.yaml for generating a Livewire component:

components:
  UpdateProfile:
    mount: user
    update:
      fire: ProfileUpdated with:user

Here's the generated Livewire component class:

<?php

namespace App\Livewire;

use App\Events\ProfileUpdated;
use Illuminate\View\View;
use Livewire\Attributes\Locked;
use Livewire\Component;

class UpdateProfile extends Component
{
    #[Locked]
    public $user;

    public function mount($user): void
    {
        $this->user = $user;
    }

    public function render(): View
    {
        return view('livewire.update-profile');
    }

    public function update()
    {
        ProfileUpdated::dispatch($this->user);
    }
}

Just like generating a controller with Blueprint, the Blade template (livewire/update-profile.blade.php) and associated classes for any statements are generated. In this case, the ProfileUpdated event.

Again, this is basic generation. Generating the corresponding test and several controller statements (validate, find, save, delete, update, query) are still todo. However, I figured some generation is better than nothing.

This additional generation will be completed before the next release is tagged. If you want to generate Livewire components with Blueprint, you may set your constraint to dev-master.

@jasonmccreary jasonmccreary merged commit a73387e into master Dec 11, 2024
18 of 27 checks passed
@jasonmccreary jasonmccreary deleted the generate-livewire branch December 11, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant