PHP code example of prabowosd / laravel-collective-html
1. Go to this page and download the library: Download prabowosd/laravel-collective-html library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
prabowosd / laravel-collective-html example snippets
{{-- Render the feedback element only when the field has an error --}}
{!! Form::error('email') !!} // <div class="invalid-feedback">The email field is ptions when the field errors --}}
{!! Form::text('email', null, Form::withValidationClass('email', ['class' => 'form-control'])) !!}
{{-- PHP enum: backed enums use their value; a label() method is honored, --}}
{{-- otherwise the case name is humanized. --}}
{!! Form::enumSelect('status', App\Enums\OrderStatus::class, $selected) !!}
{{-- Eloquent: pass a model class, query/relation, collection, or array --}}
{!! Form::modelSelect('category_id', App\Models\Category::class, 'name', 'id', $selected) !!}
{!! Form::modelSelect('category_id', $categories /* a Collection */, 'title', 'uuid') !!}
enum OrderStatus: string
{
case Pending = 'pending';
case Shipped = 'shipped';
public function label(): string
{
return ucfirst($this->value);
}
}