$this->name = $this->dot_str($name);
$name is not an array but an object
dd this variable to see its content and find the attribute you want o get the name.
I have created a component called Input and I'm calling it in the following way:
<x-input type="text" class="test" name="fullname" placeholder="hello" required></x-input>
The component use the following class:
`<?php
namespace App\View\Components;
use Illuminate\View\Component;
class Input extends Component { public $name; public $type; public $prepend; public $prependText; public $append; public $appendText;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($name)
{
$this->name = $this->dot_str($name);
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.input');
}
private function dot_str($string)
{
return str_replace(['[', ']'], ['.', ''], $string);
}
}`
and this is the blade file:
{!! Form::{$type ?? 'text'}($name, old($name, $value ?? ''), $attributes->merge(['class' => $errors->first($name, ' is-invalid')])) !!}
as you can see I'm using laravelcollective/html and when I load the page I get:
array_key_exists(): Argument #2 ($array) must be of type array, Illuminate\View\ComponentAttributeBag given (View: /usr/src/app/resources/views/components/input.blade.php)
Please or to participate in this conversation.