2017 © Pedro Peláez
 

library coaster

image

sukohi/coaster

  • Wednesday, August 19, 2015
  • by Sukohi
  • Repository
  • 1 Watchers
  • 1 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Coaster

A PHP package mainly developed for Laravel to make array for Form::select() with/without a placeholder.
(This is for Laravel 5+. For Laravel 4.2), (*1)

Installation

Add this package name in composer.json, (*2)

"require": {
  "sukohi/coaster": "2.*"
}

Execute composer command., (*3)

composer update

Register the service provider in app.php, (*4)

'providers' => [
    ...Others...,  
    Sukohi\Coaster\CoasterServiceProvider::class,
]

Also alias, (*5)

'aliases' => [
    ...Others...,  
    'Coaster'   => Sukohi\Coaster\Facades\Coaster::class
]

Usage

Minimal Way, (*6)

$lists = \Coaster::get([
    '1' => 'Text - 1',
    '2' => 'Text - 2',
    '3' => 'Text - 3',
], 'Please choose');
echo Form::select('test1', $lists);

/* Output

    <select name="test1">
        <option value="" selected="selected">Please choose</option>
        <option value="0">Text - 1</option>
        <option value="1">Text - 2</option>
        <option value="2">Text - 3</option>
    </select>

*/

with Displaying Flag (If $placeholder_flag is false, the placeholder will not be displayed), (*7)

$lists = \Coaster::get([
    '1' => 'Text - 1',
    '2' => 'Text - 2',
    '3' => 'Text - 3',
], 'Please choose', $placeholder_flag = true);
echo Form::select('test2', $lists);

/* Output

    <select name="test2">
        <option value="" selected="selected">Please choose</option>
        <option value="0">Text - 1</option>
        <option value="1">Text - 2</option>
        <option value="2">Text - 3</option>
    </select>

*/

Using Closure, (*8)

$lists = \Coaster::get(function(){

    return \App\User::where('id', '<', 5)->lists('name', 'id')->all();    // You need to return array values.

}, 'Please choose');
echo Form::select('test3', $lists);

/* Output

    <select name="test3">
        <option value="" selected="selected">Please choose</option>
        <option value="0">title - 0</option>
        <option value="1">title - 1</option>
        <option value="2">title - 2</option>
        <option value="3">title - 3</option>
    </select>

*/

with Default Value, (*9)

$lists = \Coaster::get([
    '1' => 'Text - 1',
    '2' => 'Text - 2',
    '3' => 'Text - 3',
], ['default' => 'Please choose'], true);
echo Form::select('test4', $lists);

/* Output

<select name="test4">
    <option value="default">Please choose</option>
    <option value="0">Text - 1</option>
    <option value="1">Text - 2</option>
    <option value="2">Text - 3</option>
</select>

*/

License

This package is licensed under the MIT License., (*10)

Copyright 2015 Sukohi Kuhoh, (*11)

The Versions

19/08 2015

1.0.x-dev

1.0.9999999.9999999-dev

  Sources   Download

The Requires

 

by Avatar Sukohi

19/08 2015

1.0.1

1.0.1.0

  Sources   Download

The Requires

 

by Avatar Sukohi

16/08 2015

2.0.x-dev

2.0.9999999.9999999-dev

A PHP package mainly developed for Laravel to make array for Form::select() with/without a placeholder.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

16/08 2015

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

16/08 2015

2.0.0

2.0.0.0

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

16/08 2015

2.0.1

2.0.1.0

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

16/08 2015

1.0.0

1.0.0.0

  Sources   Download

The Requires

 

by Avatar Sukohi