forked from livewire/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
making-components.blade.php
57 lines (41 loc) · 1.44 KB
/
making-components.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Run the following artisan command to create a new Livewire component:
@component('components.code', ['lang' => 'bash'])
php artisan make:livewire ShowPosts
@endcomponent
Livewire also supports "kebab" notation for new components.
@component('components.code', ['lang' => 'bash'])
php artisan make:livewire show-posts
@endcomponent
Two new files were created in your project:
* `app/Http/Livewire/ShowPosts.php`
* `resources/views/livewire/show-posts.blade.php`
If you wish to create components within sub-folders, you can use the following different syntaxes:
@component('components.code', ['lang' => 'bash'])
php artisan make:livewire Post\\Show
php artisan make:livewire Post/Show
php artisan make:livewire post.show
@endcomponent
Now, the two created files will be in sub-folders:
* `app/Http/Livewire/Post/Show.php`
* `resources/views/livewire/post/show.blade.php`
## Inline Components
If you wish to create Inline components (Component's without `.blade.php` files), you can add the `--inline` flag to the command:
@component('components.code', ['lang' => 'bash'])
php artisan make:livewire ShowPosts --inline
@endcomponent
Now, only one file will be created:
* `app/Http/Livewire/ShowPosts.php`
Here's what it would look like:
@component('components.code', ['lang' => 'php'])
@verbatim
class ShowPosts extends Component
{
public function render()
{
return <<<'blade'
<div></div>
blade;
}
}
@endverbatim
@endcomponent