PHPackages                             torgheh/bootmodal - 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. torgheh/bootmodal

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

torgheh/bootmodal
=================

v0.1.0(9y ago)111PHPPHP &gt;=5.4.0

Since May 17Pushed 8y ago1 watchersCompare

[ Source](https://github.com/torgheh/bootmodal)[ Packagist](https://packagist.org/packages/torgheh/bootmodal)[ RSS](/packages/torgheh-bootmodal/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Laravel Bootstrap Modal
=======================

[](#laravel-bootstrap-modal)

Bootmodal makes it easier for Laravel (currently only for Laravel 4.2) back-end and front-end developers to use Bootstrap modals. In administration interfaces modal dialogs are widely used but implementing them is always time consuming and involves lots of repetition especially if the requests are made through AJAX.
Bootmodal Laravel package provides back-end and front-end classes and plug-ins to accelerate this process.

Installation
------------

[](#installation)

### Composer

[](#composer)

```
"require": {
    "torgheh/bootmodal": "v0.1.0"
}
```

Then run the `composer update`.

### Laravel configuration

[](#laravel-configuration)

Add the Bootmodal service provider to the `providers` array in `app/cofig/app.php`:

```
	'Torgheh\Bootmodal\BootmodalServiceProvider'
```

Next under the `aliases` array in `app/cofig/app.php`, you may add the Modal facade.

```
	'Modal'  => 'Torgheh\Bootmodal\Facades\Modal',
```

Finally to move the package Javascript asset to the public folder run the follwoing command.

```
php artisan asset:publish torgheh/bootmodal
```

The Javascript plugin must be added to the front-end layout.1

```

```

Backend
-------

[](#backend)

### Modal

[](#modal)

In your controller the same way you make views in Laravel you can make modal views and return an Ajax response. The view should extend the default `Bootmodal::layout`.

```
return \Modal::make('dialogs.login')->with('data', $data);
```

You can also add validation errors and the old input data to the modal view. This is useful when you have Ajax form validation inside your modal.

```
return \Modal::make('dialogs.login')->withInput()->withErrors($validation);
```

### Redirect

[](#redirect)

In some cases you might want to go from an Ajax response to a normal redirect, for instance after a successful sign in.

```
return \Modal::redirect($url);
```

You can also add the Laravel session data to the redirect response the same way Laravel works.

```
retun \Modal::redirect($url)->withError($validator)->with('message', 'error');
```

### Options

[](#options)

Some of the Bootstrap modal options are adjustable through the Modal object:

- size: size of the dialog (normal, lg or sm)
- title: modal title
- animation: modal animation
- dismiss: dismiss button

```
return \Modal::make('dialogs.login')->with('data', $data)->setOption('size', 'sm')->setOption('title', 'Login');
```

### View

[](#view)

The view extends on the `bootmodal::layout`. There are three sections in a Bootstrap modal that can be extended: `modal-body` and `modal-footer` or using `modal-content` you can replace the entire modal content.

Frontend
--------

[](#frontend)

```

```

### Data attributes

[](#data-attributes)

You can bind two types of events to your HTML elements that will trigger the Bootmodal, click and submit.

#### Click:

[](#click)

```
Login
```

This will create and show a modal dialog directed through `data-action` attributes.

#### Sumbit:

[](#sumbit)

```
