lucasvdh / laravelmacros
A useful set of HTML and Form macros with css and js made for bootstrap
Installs: 1 715
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Language:CSS
Requires
- php: >=5.3.0
- laravel/framework: 5.3.*
- laravelcollective/html: ^5.3.0
This package is auto-updated.
Last update: 2024-09-06 23:36:31 UTC
README
A useful set of HTML and Form macros with corresponding CSS and Javascript resources. Made for Bootstrap.
Check out the 4.0 branch for Laravel 4 support.
Getting started
- Include the package in your application
- Register the service provider
- Publish and include the styles and scripts
View the examples.
Include the package in your application
composer require lucasvdh/laravelmacros:5.*
Or add a requirement to your project's composer.json
"require": { "lucasvdh/laravelmacros": "5.*" },
Register the service provider
Edit the config/app.php
file. Append the following to the providers
array:
'providers' => [ // ... Lucasvdh\LaravelMacros\MacroServiceProvider::class, // ... ],
If you didn't have the laravelcollective/html
package yet, be sure to add that service provider too:
'providers' => [ // ... Collective\Html\HtmlServiceProvider::class, // ... ],
And register the aliases:
'aliases' => [ // ... 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, // ... ],
Publish and include the styles and scripts
$ php artisan vendor:publish --provider="Lucasvdh\LaravelMacros\MacroServiceProvider"
Publishing a specific resource
$ php artisan vendor:publish --provider="Lucasvdh\LaravelMacros\MacroServiceProvider" --tag="scripts" $ php artisan vendor:publish --provider="Lucasvdh\LaravelMacros\MacroServiceProvider" --tag="styles" $ php artisan vendor:publish --provider="Lucasvdh\LaravelMacros\MacroServiceProvider" --tag="images"
The CSS and Javascript files will be published to public/css
and public/js
.
Make sure to include these in the view where you want to use the macros. You have two choices for including the styles and scripts.
Include all
Either you include all the plugins as a minified file.
<html> <head> ... <link href="/css/laravel-macros.css" rel="stylesheet"> </head> <body> ... <!-- Include Javascript at the end of body to improve page load speed --> <script src="/js/laravel-macros.js" type="text/javascript"></script> </body> </html>
Include specific plugins
Or you include specific plugins.
<html> <head> ... <link href="/css/chosen.css" rel="stylesheet"> <link href="/css/tags-input.css" rel="stylesheet"> </head> <body> ... <!-- Include Javascript at the end of body to improve page load speed --> <script src="/js/chosen.jquery.min.js" type="text/javascript"></script> <script src="/js/tags-input.js" type="text/javascript"></script> <!-- IMPORTANT this file is required for the plugins to function --> <script src="/js/laravel-macros-app.js" type="text/javascript"></script> </body> </html>
That's it
You can now use the macros and all should work. Customization of the CSS and Javascript files should be straight forward.
Below, a few examples are given how to use these macros:
Examples
Date picker
{!! Form::datepicker('field_name', $default, ['class' => 'some-class']) !!}
Chosen select
{!! Form::chosen('field_name', $default, $list, ['class' => 'some-class']) !!}
Material checkbox
{!! Form::materialCheckbox('field_name', $checked, 'This is the checkbox text', 'value', ['class' => 'some-class']) !!}
Material radio
{!! Form::materialRadio('field_name', $default, $options = ['value' => 'label'], ['class' => 'some-class']) !!}