Package Data | |
---|---|
Maintainer Username: | craigzearfoss |
Maintainer Contact: | craigzearfoss@yahoo.com (Craig Zearfoss) |
Package Create Date: | 2016-04-23 |
Package Last Update: | 2017-01-15 |
Home Page: | |
Language: | PHP |
License: | MIT License |
Last Refreshed: | 2025-01-23 15:02:24 |
Package Statistics | |
---|---|
Total Downloads: | 41 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This package allows you to attach bullet points to an Eloquent model in Laravel 5.
It can be found on Packagist. The recommended way is through composer.
Edit composer.json
and add:
{
"require": {
"craigzearfoss/bullets": "dev-master"
}
}
And install dependencies:
$ composer update
If you do not have Composer installed, run these two commands:
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install
Find the providers
array key in config/app.php
and register the Bullets Service Provider.
'providers' => array(
// ...
Craigzearfoss\Bullets\BulletsServiceProvider::class,
)
Run the migration to create the bullets
table.
php artisan vendor:publish --provider="Craigzearfoss\Bullets\Providers\BulletsServiceProvider"
php artisan migrate
In your model add the BulletableTrait.
<?php
// ...
use Craigzearfoss\Bullets\BulletableTrait;
class MyModel extends Model
{
use BulletableTrait;
To fetch the bullets for your model:
$bullets = $myModel->bullets()->get();
To sync the bullets for your model when storing or updating:
$myModel->syncBullets(isset($data['bullet_list']) ? $data['bullet_list'] : []);
To add the bullets for your model to you forms blade templates:
<div class="form-group">
{!! Form::label('bullet_list', 'Bullet Points:') !!}
{!! Form::select('bullet_list[]', $myModel->bullets()->lists('comment', 'comment')->toArray(), array_keys($myModel->bullets()->lists('comment', 'comment')->toArray()), ['id' => 'bullet_list', 'class' => 'form-control select2-bullet-list', 'multiple']) !!}
</div>
<script type="text/javascript" src="js/select2.min.js"></script>
.select2-bullet-list + .select2-container--default .select2-selection--multiple .select2-selection__choice {
width: 100%;
}
```
4. Add the following JavaScript to the form page.
```javascript
<script type="text/javascript">
$("#bullet_list").select2({
placeholder: "Add Bullet Points",
tags: true,
tokenSeparators: ["\n"],
maximumSelectionLength: 255
});
</script>
@if (!empty($bullets))
<ul>
@foreach($bullets as $bullet)
<li>{{ $bullet->comment }}</li>
@endforeach
</ul>
@endif
Please open an issue on GitHub
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Bullets is released under the MIT License. See the bundled LICENSE file for details.