PHPackages                             mr-timofey/laravel-admin-api - 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. [API Development](/categories/api)
4. /
5. mr-timofey/laravel-admin-api

ActiveLibrary[API Development](/categories/api)

mr-timofey/laravel-admin-api
============================

API backend for administration panels

0.5.4(6y ago)104.1k1MITPHPPHP &gt;=7.1.0

Since Dec 1Pushed 6y ago2 watchersCompare

[ Source](https://github.com/mrTimofey/laravel-admin-api)[ Packagist](https://packagist.org/packages/mr-timofey/laravel-admin-api)[ RSS](/packages/mr-timofey-laravel-admin-api/feed)WikiDiscussions master Synced today

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

API backend for administration panels based on [vue-admin-front](https://github.com/mrTimofey/vue-admin) package.

[Demo](http://admin.shit-free.space).

Requirements
------------

[](#requirements)

- PHP 7.1
- Laravel 5

Install
-------

[](#install)

```
npm i -D vue-admin-front
composer require mr-timofey/laravel-admin-api
```

Follow installation instructions from dependent packages: [mr-timofey/laravel-aio-images](https://github.com/mrTimofey/laravel-aio-images) for images processing, [mr-timofey/laravel-simple-tokens](https://github.com/mrTimofey/laravel-simple-tokens) for authorization.

**For Laravel &lt;= 5.4** add `MrTimofey\LaravelAdminApi\ServiceProvider` to your `app.providers` config.

```
php artisan vendor:publish --provider="MrTimofey\LaravelAdminApi\ServiceProvider"
```

Look to `config/admin_api.php` for further package configuration instructions.

Follow [vue-admin-front quick start guide](https://mr-timofey.gitbooks.io/vue-admin/content/quick-start.html).

For development purpose you may also want to execute `npm i -D concurrently` and add this script to your npm scripts:

```
{
	"scripts": {
		"dev": "concurrently --kill-others -n \" api ,admin\" -c \"blue,white\" \"php artisan serve\" \"npm run admin:dev\""
	}
}
```

It will run a development PHP server on port 8000 and vue-admin-front dev server on port 8080.

Authentication and authorization
--------------------------------

[](#authentication-and-authorization)

This package uses [mr-timofey/laravel-simple-tokens](https://github.com/mrTimofey/laravel-simple-tokens)to maintain authentication and authorization logic.

You can change a guard which is used for API by setting a proper `auth:{guard name}` middleware and guard name in `admin_api.api_middleware` and `admin_api.api_guard` config respectively.

Remove `auth` middleware if you want to disable authorization.

Also you can completely replace authentication and authorization logic by rebinding auth controller class: `app()->bind(\MrTimofey\LaravelAdminApi\Http\Controllers\Auth::class, YourController::class)`

Models configuration
--------------------

[](#models-configuration)

Admin API will try to guess attribute types and generate field names by capitalizing attribute names using model's:

- `$visible` to get a list of fields to display on entity index page (if not set explicitly)
- `$fillable` to get a list of fields for editing (if not set explicitly)
- `$hidden` fields will receive a `password` field type
- `$dates` fields will receive a `datetime` field type
- `$casts` will just set field types as-is (don't worry, `vue-admin-front` supports any Eloquent compatible types by aliasing them)
- belongsTo, hasMany and belongsToMany relations will just work

You can also implement a `MrTimofey\LaravelAdminApi\Contracts\ConfiguresAdminHandler` interface and define a `configureAdminHandler($handler)` method to make things more controllable.

Available field types and their options are described in [vue-admin-front field types docs](https://mr-timofey.gitbooks.io/vue-admin/content/fields.html#available-field-types). Same for fields formatting for model index page [vue-admin-front display types docs](https://mr-timofey.gitbooks.io/vue-admin/content/displays.html#available-display-types).

Usage example:

```
