dev-master
9999999-devA Laravel 5.5 Package that expands LaravelCollective/html further with different js plugins.
MIT
The Requires
- php >=7.0
- laravelcollective/html ^5.4.0
by Peter Keogan
laravel blade adminlte
Wallogit.com
2017 © Pedro Peláez
A Laravel 5.5 Package that expands LaravelCollective/html further with different js plugins.
Package is under heavy development and not ready for release, Package is complete and working. I am just working on all of the bugs and perfecting it before I release. At the time there is no install guide. Will be soon though! Make sure you watch!, (*1)
A Laravel 5.5 Package that extendsLaravelCollective/html further with different js plugins. Every component is also setup to be displayed the same, with label, the input, a some helper text., (*3)
This package extends LaravelCollective/html package to include the following * Text Inputs (Same as LaravelCollective/html, but build in with labels ect) * Date Picker * Toggle * Select/Pillbox * Slider * Text Editor * Fileuploader (Not Decided Yet) * Image Uploaded and Cropper, (*4)
There are two ways to implement this package into your code. You can use the Form:: facade that is created by laravelCollective/html, or you can use the custom HtmlExtra Facade. The differnce, is that the HtmlExtra facade uses method chaining, to create components and render them, where as the laravelCollective/html facade just calls the views and you must inject the parameters in the right order., (*5)
{{ Form::textInput('Name', 'id', 'helper_text', 'Type', $attributes[...]) }}
{{ HtmlExtra::text()->name('Name')->id('1')->helperText('This is an input')->attributes(['required' => 'true'])->render() }}
You can all for a component over LaravelCollective/html's Component Magic Methods, (*6)
{{ Form::textInput('Name', 'id', 'helper_text', 'Type', $attributes[...]) }}
Future Documentation on how to use this coming in the future., (*7)
Using the HtmlExtra method chaining can be easy, and more friendly to look at. most importantly it can be done with a smaller amount of code, due to the fact you do not have to declare null variables., (*8)
First Step Is To Declare the type, you can do this two ways, which ever you prefer., (*9)
// Facade Based, with build() and without
{{ HtmlExtra::build()->text->... }}
{{ HtmlExtra::text()->... }}
// Service Binding Based
{{ app()->htmlextra()->build()->text->... }}
{{ app()->htmlextra()->text()->... }}
HtmlExtra::text()-> -Text Input Type - basic text inputHtmlExtra::textarea()-> -Text Input Type - basic text area inputHtmlExtra::textField()-> -TextField Input Type - basic textField inputHtmlExtra::password()-> -Text Input Type - password inputHtmlExtra::email()-> -Text Input Type - email inputHtmlExtra::hidden()-> -Text Input Type - hidden inputHtmlExtra::summernote()-> -Summernote Type - creates a summernote editorHtmlExtra::slider()->-NoUiSlider Type - creates a NoUISlider componentHtmlExtra::toggle()-> -Bootstrap Toggle Type - creates a Bootstrap Toggle componentHtmlExtra::select()-> - Select2 Type - creates a Select2 component, select only 1HtmlExtra::multiple()-> - Select2 Type - creates a Select2 component, select multiple* HtmlExtra::date()-> - Flatpickr Type - creates a Flatpickr component, with only the dateHtmlExtra::time()-> - Flatpickr Type - creates a Flatpickr component, with only the timeHtmlExtra::dateTime()-> - Flatpickr Type - creates a Flatpickr component, with the dateTimeHtmlExtra::cropper()-> - Cropper Type - creates a CroppercomponentHtmlExtra::file()-> - UNDECIDEDHtmlExtra::drawing()-> - UNDECIDEDNext step you must declare the parameters and set them!, (*10)
{{ HtmlExtra::build()->text->name('Some Name')->id('Some Id')->helperText('This is some helping Text') }}
{{ HtmlExtra::toggle()->name('Some Name')->helperText('Some Helper Text')->id('Some Id')->data(['some-atttribute' => 'some value'])... }}
...->name('Some Name')->... - The name of the input, used for label REQUIRED! $string...->id('Foo')->... - The name of the ID, needs to be alpha-numeric-dash (If not supplied, this will take the name and convert it to alpha numeric) $string...->helperText('Some Details')->... - The Helper Text, under the input REQUIRED! $string...->value('Bar')->... - The default value of the input $mixed ...->attributes(['class' => 'form-control', 'style' => 'color: fff;'])->... - Attributes that get passed directly to the html <input> Element. $array...->data(['data-width' => 100])->... - The data that will be passed into the view. Used to control the JavaScript! $arrayYou may also pass varibles, attributes and data to your component without using the above parameter methods the first 4 letters must be the same as below, then te letters following it will be the name/key. The method will then take the value you are sending.
* ...->withFoo($var)->... //Replace foo- pass a variable into the component view
* ...->attrBar($var)->... //Replace Bar- add to the attributes array
* ...->dataBaz($var)->... //Replace Baz- add to the data array, (*11)
{{ HtmlExtra::text()->name('Some Name')withRole('admin')... }} // Would pass $role = admin into the view.
{{ HtmlExtra::toggle()->name('Some Name')attrClass('hide-div')... }} // Would add 'class' => 'hide-div' to the attributes array
{{ HtmlExtra::select()->name('Some Name')dataDisable(true)... }} // would add 'disable' => true to the data array
you may also pass single values into the attribute or data arrays.
* ...->attrFoo->... //Replace Foo - add to the attributes array
* ...->attrBaz->... // Replace Baz - add to the data array, (*12)
{{ HtmlExtra::text()->name('Some Name')->attrRequired->... }} // would add 'required' to the end of the attributes array
{{ HtmlExtra::toggle()->name('Some Name')->attrDisabled->... }} // would add 'disabled' to the end of the attributes array
{{ HtmlExtra::select()->name('Some Name')->dataStop->... }} // would add 'stop' to the end of the data array
The last thing you need to do, is tell the HtmlExtra to render what you gave it.
Simply chain the ...->render() method to the end of a Facade Chain, (*13)
`{{ HtmlExtra::select()->name('Some Name')->id('1')->render() }}`
In the future I will look into expanding this into other ways., (*14)
Provides access to Form's basic form input, only difference is this will have the same style as all the other inputs, and create the label and helper text for you., (*15)
{{ Form::textInput('Name', 'id', 'helper_text', 'Type', $attributes[...]) }}
Again, you can use anything that you would normaling use in the Form::text method call for the attributes HTML5 Inputs Attributes, (*16)
['value' => 'String', // Value of the input upon page load DEFAULT: NULL 'placeholder' => 'String', // placeholder text DEFAULT: 'Enter ' . $Name 'maxlength' => 'String', // max amount of chars allowed 'required' => boolean, // If use, label will get a * after it 'autocomplete' => 'String', // Use On or Off Only 'autofocus' => boolean, // Specifies that an <input> element should automatically get focus when the page loads, only use once!
{{ Form::texInput('Label', 'toggle-id', 'This is some helper text', true}}
{{ Form::datePicker('Name', 'id', 'helper_text', $date, $attributes[...]) }}
{{ Form::timePicker('Name', 'id', 'helper_text', $date, $attributes[...]) }}
{{ Form::dateTimePicker('Name', 'id', 'helper_text', $date, $attributes[...]) }}
['enableTime' => 'boolean', // Allow Time to be selected (you can use dateTimePicker or timePicker instead if you want) 'enableSeconds' => 'boolean', // enable seconds to be captures, but be using dateTimePicker, or timePicker 'noCalendar' => boolean, // will not display a day picking //NOTE the above 3 are linked with the date format. see flatpickr.blade.php //You can also pass in normal text attributes that are HTML complainct
{{ Form::datePicker('Date of Birth', 'date_of_birth', 'Users Date Of Birth', null ) }}
{{ Form::dateTimePicker('Time Clocked In', 'clock_in_at', 'Time Clocked', null ) }}
{{ Form::datePicker('Date of Birth', 'date_of_birth', 'Users Date Of Birth', null, ['required' => 'required'] ) }}
{{ Form::select2('Name', 'id', 'helper_text', $items[], $attributes[...], $logic[...]) }}
['multiple' => 'String', // Allow Multiple Selects 'placeholder' => 'String', // placeholder text DEFAULT: 'Enter ' . $Name 'required' => boolean, // If use, label will get a * after it 'allow-clear' => boolean, // Provides an X to hit so you can clear the selection 'tags' => boolean, //Allows user to type their own awnser in 'maximumSelectionLength' => int, // If mutiple is used, this will set the maxium amount of selectins you can choose
{{ Form::select2('Users', 'user_id', 'A List Of Users', $users) }}
{{ Form::select2('Users', 'user_id', 'A List Of Users', $users, ['mutiple' => 'mutiple', 'tags' => 'true']) }}
Display a Select 2 input, and if peter is selected, then show a div with id, (*17)
@php
$users = ['Peter' => 1, 'John' => 2],
@endphp
...
{{ Form::select2('Users', 'user_id', 'A List Of Users', $users, ['mutiple' => 'mutiple', 'tags' => 'true'], ['Peter', => 'hide-me']) }}
//Show some stuff
A Form::checkbox masked by a bootstrap-toggle, (*18)
{{ Form::toggle('Name', 'id', 'helper_text', $boolean, $attributes[...], $data[...]) }}
{{ HtmlExtra::toggle()->withName()->withId()->withHelperText()->withValue()->withAttributes()->withData() }}
This array is passed to the Form::checkbox beneath all of the javascript, (*19)
['required' => boolean, // If use, label will get a * after it ]
This array is passed to the bootstrap toogle element, (*20)
['data-on' => 'String', //Text Displayed when Toggle Is On DEFAULT = ON 'data-off' => 'String', //Text Displayed when Toggle Is On DEFAULT = OFF 'data-label' => 'String', //label of toggle if data-on and data-off are not set' NO DEFAULT 'data-size' => 'String', //Overrides height and width. OPTIONS: large, normal, small, mini 'data-offstyle' => 'String', // Style OPTIONS: primary, default, warning, danger, success, info 'data-onstyle' => 'String', // Style OPTIONS: primary, default, warning, danger, success, info 'data-width' => int, // Width of toggle DEFAULT 200 'data-height => int, // Height of toggle DEFAULT 30 'show-id-if-toggled' => 'Array', // If turned toggle, this will remove the hide-div from the inputed div#ID 'hide-id-if-toggled' => 'Array', // If turned toggle, this will remove the hide-div from the inputed div#ID 'disable-id-if-toggled' => 'Array', //if the toggle is toggle, disablen another toggle 'enable-id-if-toggled' => 'Array', //if the toggle is enable, enable another toggle
{{ Form::toggle('Label', 'toggle-id', 'This is some helper text', true}}
{{ Form::toggle('Label', 'toggle-id', 'This is some helper text', true, $data['data-label' => 'Hello There'] }}
Displays 3 toggles, 2 visble and 1 hidden. If the first one is selected, is will display the third. Only the first and second toggle can be selected at the same time. (like radio buttons), (*21)
{{ Form::toggle('Label', 'toggle-id', 'This is some helper text', false, $attributes['data-label' => 'Hello There', 'show-id-if-selected' => 'hide-me'], ['toggle-id2'] }}
{{ Form::toggle('Label', 'toggle-id2', 'This is some helper text', false, $attributes['data-label' => 'Hello There2'], ['toggle-id'] }}
{{ Form::toggle('Label', 'toggle-id3', 'This is some helper text', false, $attributes['data-label' => 'Hello There3', ], ['toggle-id'] }}
There are some custom blade directives added in order to make this all work., (*22)
@pushonce('stack:component')
//stuff to push to stack
@endpushonce
Lets say you want to push a script to the stack scripts and the name of your widget is select2, (*23)
// In Blade View
...
@pushonce('scripts:select2')
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
@endpushonce
On the first time loading this blade view, it will push, but the second time it will be false and not push anything, (*24)
Please see LICENSE.md, (*25)
A Laravel 5.5 Package that expands LaravelCollective/html further with different js plugins.
MIT
laravel blade adminlte