davide-casiraghi/laravel-form-partials

A collection of partials blade views for Bootstrap 4 forms controls.

2.0.0 2020-04-05 09:25 UTC

This package is auto-updated.

Last update: 2024-09-05 19:51:39 UTC


README

Latest Version on Packagist StyleCI Quality Score Coverage Status GitHub last commit

A collection of partials Blade views for Bootstrap 4 forms controls.

Available controls

  • Input
  • Input Hidden
  • Input Readonly
  • Select
  • Checkbox
  • Datepicker
  • Timepicker
  • Textarea (with WYSWYG editor)
  • Textarea plain
  • Password
  • Upload image
  • Alert (to show an bootstrap alert)

Installation

You can install the package via composer:

composer require davide-casiraghi/laravel-form-partials

Publish all the vendor files

php artisan vendor:publish --force

Then select the number that correspont to the package.

Usage

The partials can be included in any blade view in this way:

for a create view

@include('laravel-form-partials::input', [
    'title' => __('views.title'),
    'name' => 'title',
    'placeholder' => 'Post title',
    'value' => old('title'),
    'required' => true,
])

for an edit view

@include('laravel-form-partials::input', [
    'title' => __('views.title'),
    'name' => 'title',
    'placeholder' => 'Post title',
    'value' => $post->title,
    'required' => true,
])

Upload file

for a create view

@include('laravel-form-partials::upload-image', [
   'title' => 'Card image', 
   'name' => 'image_file_name',
   'folder' => 'cards',
   'value' => '',
   'required' => false,
])

for an edit view

@include('laravel-form-partials::upload-image', [
   'title' => 'Card image', 
   'name' => 'image_file_name',
   'folder' => 'cards',
   'value' => $card->image_file_name,
   'required' => false,
])

In the controller store method

use DavideCasiraghi\LaravelFormPartials\Facades\LaravelFormPartials;
...
$imageSubdir = 'cards';
$imageWidth = '1067';
$thumbWidth = '690';
$card->image_file_name = LaravelFormPartials::uploadImageOnServer($request->file('image_file_name'), $request->image_file_name, $imageSubdir, $imageWidth, $thumbWidth);

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email davide.casiraghi@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.