Official documentation: https://laravel.com/docs/8.x/blade#components
Questions tagged [laravel-components]
34 questions
                    
                    6
                    
            votes
                
                0 answers
            
        Laravel blade template inheritance vs Laravel component
I'm wondering if it is worth moving from this code.
@extends('layouts.app')
 
@section('title', 'Page Title')
 
@section('content')
    @foreach ($tasks as $task)
        {{ $task }}
    @endforeach
@endsection
To this one.
   … 
        
        Issa Abdulaziz
        
- 93
 - 1
 - 7
 
                    4
                    
            votes
                
                3 answers
            
        Passing Php variable to Laravel Blade Component
I have made a laravel component using php artisan make:component testcomponent for which two files are created; one is blade and second one is php class file.
here is the blade file:
        
    {{ $data }}
and here is the php…
        Hammad Butt
        
- 73
 - 2
 - 7
 
                    4
                    
            votes
                
                2 answers
            
        Laravel Components: default content in {{ slots }}
In old-style Laravel blade templated we used to use @section('section-name') in the following way:
{{-- h1para.blade.php --}}
        @section('heading') Heading from Template @endsection
@yield('details')
And then…
        cartbeforehorse
        
- 3,045
 - 1
 - 34
 - 49
 
                    3
                    
            votes
                
                1 answer
            
        $attributes->merge : what am i doing wrong
I have the following blade component in laravel. I am using tailwind.  located in
views/components/indigo-button-sm.blade.php
        
        Robert Bryan Davis
        
- 183
 - 2
 - 12
 
                    3
                    
            votes
                
                1 answer
            
        Push css/js files from one component to another
I created 2 components: layouts/app.blade.php and navigation.blade.php
The layouts/app.blade.php looks like this:
    @stack('styles')
     
The navigation.app.blade looks like this:
        
        Ioan Andrei
        
- 93
 - 1
 - 16
 
                    2
                    
            votes
                
                1 answer
            
        How to pass a string to a blade component?
As an example there is this component:
resources/views/components/example.blade.php
 
what…
        
    @if($foo === "bar")
        Bar
    @else
        Foo
    @endif
that I render like
@php
   $foo = "bar";
@endphp
        JanBoehmer
        
- 395
 - 3
 - 14
 
                    2
                    
            votes
                
                0 answers
            
        Access component data from current loop iteration in parent - Laravel component Scoped Slot
I have a component table
 
I pass array of arrays where each inner array represents  row to be printed.
$rowsArray = [
  ['name'=>'Marko', 'age'=>21],
  ['name'=>'John', 'age'=>33]
]
Inside a component…
        
            
            
                
                    
    
    
        
    
    
                
            
        
    
                    
                
                    
                    
    
        
            
                
            
    
    
        
        
            
            
                
                    
    
    
        
    
    
                
            
        
    
                    
                
                    
                    
    
        
            
                
            
    
    
        
        
            
            
                
                    
    
    
        
    
    
                
            
        
    
                    
                
                    
                    
    
        
            
                
            
    
    
        
        
            
            
                
                    
    
    
        
    
    
                
            
        
    
                    
                
                    
                    
    
        
            
                
            
    
    
        
        
                    
                
                    
                    
    
        
            
                
            
    
    
        
        
            
            
                
                    
    
    
        
    
    
                
            
        
    
                    
                
                    
                    
    
        
            
                
            
    
    
        
        
            
            
                
                    
    
    
        
    
    
                
            
        
    
                    
                
                    
                    
    
        
            
                
            
    
    
        
        
            
            
                
                    
    
    
        
    
    
                
            
        
    
                    
                
                    
                    
    
        
            
                
            
    
    
        
        
            
            
                
                    
    
    
        
    
    
                
            
        
    
                    
                
                
            
        
            
        
        
        
        
     
        Marko
        
- 349
 - 2
 - 14
 
                    2
                    
            votes
                
                3 answers
            
        Pass array as attribute in blade custom component
I have defied a generic input component in Laravel like this:
//file: views/components/input.balde.php    
$val)
                {{ $attr }} = "{{ $val }}"
            @endforeach
            >
And I would like to…
        
        Lamar
        
- 1,761
 - 4
 - 24
 - 50
 
                    1
                    
            vote
                
                1 answer
            
        Laravel Component does not work on the hosting
I have created a Laravel Component and it works fine on my local machine, but when I deploy the project to the hosting it stops working there and the error Undefined variable $navbar occurs.
app\View\Components
class navbar extends Component
{
   …
        
        Oleh
        
- 55
 - 9
 
                    1
                    
            vote
                
                0 answers
            
        Why I failed to catch ModelNotFoundException ths error in controller block?
In laravel 9 I have ProductCardReport component which is on blade form and data are retrieved
from ReportProduct class. I got data with firstOrFail in this class and I failed to catch this
error in controller block.  I have in ProductController…
        
        mstdmstd
        
- 2,195
 - 17
 - 63
 - 140
 
                    1
                    
            vote
                
                2 answers
            
        Why I can not call Implementation method from library class?
In laravel 9 app I created class  app/Implementations/LocalStorageUploadedFileManagement.php :
        
            
            
                
                    
    
    
        
    
    
                
            
        
    
        mstdmstd
        
- 2,195
 - 17
 - 63
 - 140
 
                    1
                    
            vote
                
                1 answer
            
        Why $variable++ not working properly in Lavarel Blade?
I just encounter a situation where I need to display index for each row of table, For this I created a variable ($number) in blade view file and set it to 0. For row of my table I created a component and pass my data to it, incrementing index…
        
        Usama Jalal
        
- 105
 - 1
 - 8
 
                    1
                    
            vote
                
                0 answers
            
        Laravel Livewire full page component with additional parameters
I'm trying to implement an EasyCRUD full page component that would permit basic operations on indicated model. Just for the simplicity, all models would have the same structure (id, name, timestamps, etc.).
The idea is to define multiple routes…
        
        dmikam
        
- 992
 - 1
 - 18
 - 27
 
                    1
                    
            vote
                
                0 answers
            
        New Blade Component Laravel 7
I created this new Laravel component, how can I use a custom foreach using {{ $name }} blade variable?
View -> Components
class SearchDropdownField extends Component
{
    public $name;
    public function __construct($name = 'name text')
    {
 …
        
        cloude
        
- 338
 - 5
 - 18
 
                    0
                    
            votes
                
                1 answer
            
        Trix editor with laravel livewire not displaying database data
im trying to display data from the database from the trix editor using laravel livewire. The content gets saved in the database but after i reload content disappears from the page even though the content is saved in the database. This is my livewire…
        
        kristi tanellari
        
- 95
 - 2
 - 12