x- indicates component and input indicates component name -<x-input />
We can reuse a code multiple times without repeatations.
Write the code as given below and start creating components.
Registration Form
After that run this command -
php artisan make:component Input
in the vs code terminal or do it mannually.
After executing this command two folders and files will be created.
1. views>components>input.blade.php
2. apps>views>components>Input.php
Your component code will be in views>components>input.blade.php -
{{$demo}}
@error($name)
{{$message}}
@enderror
And all the values fetch from apps>views>components>Input.php -
namespace App\View\Components;
use Illuminate\View\Component;
class Input extends Component
{
public $type;
public $label;
public $name;
public $placeholder;
public $demo;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($type, $label, $name, $placeholder, $demo=0)
{
$this->type = $type;
$this->label = $label;
$this->name = $name;
$this->placeholder = $placeholder;
$this->demo = $demo;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.input');
}
}
Now you can try http://127.0.0.1:8000/register on brower if you have started your localhost. if not started then - follow these steps.
Comments
Post a Comment