PHPackages                             sukohi/coaster - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sukohi/coaster

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sukohi/coaster
==============

2.0.1(10y ago)1271MITPHP

Since Aug 16Pushed 10y ago1 watchersCompare

[ Source](https://github.com/SUKOHI/Coaster)[ Packagist](https://packagist.org/packages/sukohi/coaster)[ RSS](/packages/sukohi-coaster/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Coaster
=======

[](#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](https://github.com/SUKOHI/Coaster/tree/1.0))

Installation
============

[](#installation)

Add this package name in composer.json

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

```

Execute composer command.

```
composer update

```

Register the service provider in app.php

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

```

Also alias

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

```

Usage
=====

[](#usage)

**Minimal Way**

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

/* Output

        Please choose
        Text - 1
        Text - 2
        Text - 3

*/

```

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

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

/* Output

        Please choose
        Text - 1
        Text - 2
        Text - 3

*/

```

**Using Closure**

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

    return \App\User::where('id', '
