okipa/laravel-bootstrap-components

This package is abandoned and no longer maintained. The author suggests using the https://github.com/Okipa/laravel-form-components package instead.

Ready-to-use and customizable components.


README

Laravel Bootstrap Components

Latest Stable Version Total Downloads Build Status Coverage Status License: MIT

⚠️ THIS PACKAGE HAS BEEN ABANDONED IN FAVOR OF https://github.com/Okipa/laravel-form-components. ⚠️
=> Only bug fixes will be merged. Please consider moving to the new package.

Save time and take advantage of a set of dynamical, ready-to-use and fully customizable bootstrap form components.

Found this package helpful? Please consider supporting my work!

Donate Donate

Compatibility

Laravel PHP Bootstrap Package
^7.0 ^7.4 ^4.0 ^5.0
^7.0 ^7.4 ^4.0 ^4.0
^7.0 ^7.4 ^4.0 ^3.0
^5.8 ^7.2 ^4.0 ^2.0
^5.5 ^7.1 ^4.0 ^1.0

Upgrade guide

Usage

Just call the components you need in your views and let this package take care of the HTML generation annoying part.

Standard use case

Call this component in your view:

{{-- Helper style --}}
{{ inputText()->name('name') }}

{{-- Facade style --}}
{{ InputText::name('name') }}

And get this HTML generated for you:

<div class="component-container form-group">
    <label for="text-name">
        Name
    </label>
    <div class="input-group">
        <div class="input-group-prepend">
            <span class="input-group-text">
                <i class="fas fa-font"></i>
            </span>
        </div>
        <input id="text-name"
            class="component form-control"
            type="text"
            name="name"
            value=""
            placeholder="Name">
    </div>
</div>

Multilingual use case

Call this component in your view:

{{-- Helper style --}}
{{ inputText()->name('title')->localized(['fr', 'en']) }}

{{-- Facade style --}}
{{ InputText::name('title')->localized(['fr', 'en']) }}

And get this HTML generated for you:

<div class="component-container form-group">
    <label for="text-title-fr">
        Title (FR)
    </label>
    <div class="input-group">
        <div class="input-group-prepend">
            <span class="input-group-text">
                <i class="fas fa-font"></i>
            </span>
        </div>
        <input id="text-title-fr"
            class="component form-control"
            type="text"
            name="title[fr]"
            value=""
            placeholder="Title (FR)"
            data-locale="fr">
    </div>
</div>
<div class="component-container form-group">
    <label for="text-title-en">
        Title (EN)
    </label>
    <div class="input-group">
        <div class="input-group-prepend">
            <span class="input-group-text">
                <i class="fas fa-font"></i>
            </span>
        </div>
        <input id="text-title-en"
            class="component form-control"
            type="text"
            name="title[en]"
            value=""
            placeholder="Title (EN)"
            data-locale="en">
    </div>
</div>

Table of Contents

Installation

  • Install the package with composer:
composer require okipa/laravel-bootstrap-components

Configuration

Publish the package configuration file to customize it if necessary:

php artisan vendor:publish --tag=bootstrap-components:config

⚠️ You may have to run a composer dump-autoload after changing a path in your configuration file.

Translations

All displayed labels or sentences are translatable.

See how to translate them on the Laravel official documentation: https://laravel.com/docs/localization#using-translation-strings-as-keys.

Here is the list of the words and sentences available for translation:

  • Create
  • Update
  • Validate
  • Back
  • Cancel
  • Remove
  • No file selected.
  • Awaited format: Day/Month/Year.
  • Awaited format: Hour:Minutes.
  • Awaited format: Day/Month/Year Hour:Minutes.
  • Your browser does not support the :tag HTML5 tag.

You will also have to define each attribute you define in the ->name() method in the validation (attributes key) translation file.

Views

Publish the package views to customize them if necessary:

php artisan vendor:publish --tag=bootstrap-components:views

API documentation

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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