php - Component Construct not loading default values
one text
I have a Laravel 8 Project running on PHP 8.1 which fails to load components correctly when loading in linux via apache2 but works fine on dev environment through artisan serve on Windows Machine
resources/views/components/input-floating.blade.php `
<div class="form-group mb-3">
<label class="form-label">{{$label}}</label>
<input type="{{$type}}" id="input{{$slug}}" name="{{$name}}" class="form-control {{!$error? '' : 'is-invalid'}}" placeholder="{{$label}}" value="{{$value}}" {{$properties}}>
</div>
`
app/View/Components/inputFloating.php `
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class inputFloating extends Component
{
public $name;
public $value;
public $label;
public $slug;
public $error;
public $properties;
public $type;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($label, $name, $value = '', $properties='' , $error = false, $type='text')
{
$this->type = $type;
$this->label = $label;
$this->properties = $properties;
$this->value = $value;
$this->name = $name;
$this->slug = preg_replace('/\s+/', '', ucwords($label));
$this->error = $error;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.input-floating');
}
}
**Call to Component in Blade:**
<x-input-floating type="text" label="Email" name="email" value="admin@localhost.net" :error="$errors->has('email')" />
`
Error:
ErrorException Undefined variable $type (View: /var/www//html/resources/views/components/input-floating.blade.php) http://.com/login
Source