36 questions
0
votes
1
answer
110
views
Undefined variable $data in Blade component despite passing data from controller
I am working on a Laravel project and I have a Blade component for displaying a data table. However, I am encountering an Undefined variable $data error when trying to pass data from my controller to ...
-1
votes
1
answer
81
views
laravel variable not reading from mysql
I've come back to a Laravel project having been away from coding to deal with a personal situation. Now I've hit a brick wall. I'm getting an "Undefined variable" error which I don't know ...
0
votes
2
answers
596
views
LiveWire & Laravel Component: Html Not SHOW UP
I'm working with Laravel v10 and in my project I tried the following to make a custom component with livewire.
I ran: php artisan make:component CounterDisplay
created a new file named: resources/...
0
votes
1
answer
473
views
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 ...
2
votes
1
answer
749
views
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\...
0
votes
1
answer
427
views
laravel - passing data to class-based component, without @props
I have this component:
class CategorySelect extends Component
{
public $id_name, $selected;
public function __construct($selected=-1, $id_name="default_id")
{
$this->...
1
vote
0
answers
370
views
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 ...
0
votes
0
answers
337
views
How submitting this form trigger method of a component?
In laravel 9 I have component which I created with command
php artisan make:component ProductCardReport
In app/View/Components/ProductCardReport.php I get some data with eloquent :
<?php
...
1
vote
2
answers
226
views
Why I can not call Implementation method from library class?
In laravel 9 app I created class app/Implementations/LocalStorageUploadedFileManagement.php :
<?php
namespace App\Implementations;
use App\Interfaces\UploadedFileManagement;
...
use Intervention\...
0
votes
1
answer
635
views
Laravel : Conditional block for the @foreach() in blade
@foreach (($loop->index == 3 ? FILTER_OPTION_NEW_EXISTING : ($loop->index == 4 ? $franchiseTypes : $categories)) as ($loop->index == 3 ? $key => $value : $item))
How can I attain this one?...
3
votes
1
answer
4k
views
How to pass a string to a blade component?
As an example there is this component:
resources/views/components/example.blade.php
<div>
@if($foo === "bar")
Bar
@else
Foo
@endif
</div>
that I ...
0
votes
1
answer
924
views
Laravel - One component class for multiple component views
I would like to create one "parent" component class that can render multiple different views based on which "child" view you pass in.
For example, I would like to create a ...
1
vote
1
answer
86
views
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 ...
0
votes
2
answers
513
views
pushing javascript codes at blade does not work out
I have a file called all.blade.php which goes like this:
@component('admin.layouts.content' , ['title' => 'example file'])
@slot('breadcrumb')
<li class="breadcrumb-item active&...
0
votes
1
answer
191
views
Including Javascript codes with @stack not working
I'm working with Laravel 8 and I have a master.blade.php goes like this:
<!DOCTYPE html>
<html>
<head>
<!-- including scripts and stylesheets -->
</head>
&...
0
votes
0
answers
277
views
php artisan make:component not exist after upgrade from Laravel 6 to Laravel 9
i have upgraded from laravel 6 to 7 then 8 then 9 and make:component command not exist how to update it ?
0
votes
1
answer
3k
views
Difference between @aware and @props directives in laravel 9
The @aware Laravel Blade template directive was introduced in Laravel 8, but I still don't understand what it does differently from the already existing @props directive.
For instance, if I use a ...
5
votes
3
answers
18k
views
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:
<div>
{{...
7
votes
0
answers
3k
views
Laravel blade template inheritance vs Laravel component [closed]
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
@...
1
vote
0
answers
1k
views
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, ...
0
votes
1
answer
870
views
Can i set a custom tag and a custom value in laravel component?
<div class="bg-white dark:bg-custom-black-600 dark:text-white rounded px-4 pb-4 pt-2">
<div class="flex-shrink-0 flex justify-between items-center">
<h4 ...
0
votes
1
answer
543
views
Laravel can not pass variable from controller to component
I can not see my variable in component
Controller
class DigitalContentController extends Controller
{
public function productsList(){
$contents = DigitalContent::all();
return view(...
6
votes
1
answer
14k
views
$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
<button {{ $attributes->merge(['type' => 'button', 'class' => '...
0
votes
2
answers
2k
views
Laravel: getting blade components syntax error, unexpected 'endif' (T_ENDIF), expecting end of file
I am learning laravel on Laracast however I am having some issues
I have this code on file components/layout.blade.php
<!DOCTYPE html>
<head>
<title>Host Cloud Template - ...
0
votes
1
answer
4k
views
Laravel component not showing
I'm trying to learn laravel and I'm trying to use some components.
I've created a layout component which is including the navbar and it's correctly working.
I'm still working with key/values arrays ...
2
votes
0
answers
622
views
Access component data from current loop iteration in parent - Laravel component Scoped Slot
I have a component table
<x-table :rows="$rowsArray"></x-table>
I pass array of arrays where each inner array represents <tr> row to be printed.
$rowsArray = [
['name'=&...
0
votes
0
answers
291
views
Yajra Datatable and Laravel-breeze, maybe csrf_token problem
I made a table using yajra datatables, everything works fine (buttons, table title, table data, editing, etc.) (Listing 1). Now I am trying to implement this using Laravel 8 components, but I do not ...
3
votes
3
answers
3k
views
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
<input @foreach ($attrs as $attr=>$val)
{{ $attr }} = "{{ $val }}&...
0
votes
1
answer
913
views
In a Laravel component, how to do I remove a default class?
In a Laravel component, you can specify default classes and merge them with extra classes that get passed in, something like this:
<a {{ $attributes->merge(['class' => 'text-white']) }}>{{ ...
0
votes
0
answers
763
views
Laravel 8: How to pass data from grand parent component to grand children?
I've recently started working with Laravel during one of my courses and those components look really promising. One problem though, that I've come across, is passing data from, let's say, the ...
5
votes
2
answers
5k
views
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 --}}
<h1>
@section('heading')
Heading from Template
@...
4
votes
1
answer
695
views
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:
<body>
@stack('styles')
<x-navigation/>
</body>
The ...
0
votes
1
answer
288
views
Laravel Cant return collection/array to component from component class
Heres the output to the screen if I dd() in the render method
Illuminate\Support\Collection {#1355 ▼
#items: array:1 [▼
0 => {#1360 ▼
+"provider": "provider"
+&...
1
vote
1
answer
2k
views
@include Laravel Blade Template to append using Javascript
I'm trying to reuse the same HTML code in both PHP and Javascript. In PHP I'm using Laravel's component mechanism to load the file passing the necessary parameters.
@foreach($files as $file)
<x-...
0
votes
1
answer
843
views
Laravel component class ignore due to component create in different folder
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class Admin.-newclubform extends Component
{
/**
* Create a new component instance.
*
* @return void
*...
0
votes
1
answer
784
views
Logic in Laravel components
I have a laravel component
<section class="section {{ $classes }}">
<div class="inner">
<h1>{{ $heading }}</h1>
<h2>{{ $subheading }}&...