Deprecated
This repo will no longer be maintained and will be deleted in the start of 2017.
About
Auja is an easy-to-use, easy-to-implement admin interface. It provides an easy and intuitive way for you to view and manipulate your data, so you can focus on more important matters. Auja is designed to be both user-friendly and developer-friendly by providing you with tools to setup your admin interface in a couple of minutes.
The Auja javascript frontend provides the graphical user interface. To determine its content, it relies on a JSON web-service you implement. Auja-PHP in turn, provides an Object Oriented approach to provide these JSON messages from a PHP application. In this repository you will find a Laravel implementation which you can use to setup Auja for your Laravel project.
- Auja - The frontend JavaScript GUI
- Auja PHP Development Kit - A web service development kit for communicating with the Auja javascript frontend
Because Auja uses both a library for the PHP backand and a library for the JavaScript frontend there a few more steps required to install Auja that you may be used to with other libraries.
-
Setup Laravel to work with Bower and Gulp, if you haven't already. This is done by default in Laravel 5, but you still need to install bower and gulp globaly with npm.
-
Modify the
gulpfile.js
so all Auja's assets and scripts are placed in the correct folders when runninggulp
.var elixir = require('laravel-elixir'); elixir(function(mix) { mix // .sass('app.scss') // included in Laravel 5 but not manditory .copy('auja/auja.min.js', 'public/js/vendor/auja.js') .copy('auja/auja.css', 'public/css/vendor/auja.css') .copy('trumbowyg/dist/ui/trumbowyg.min.css', 'public/css/vendor/trumbowyg.css') .copy('Ionicons/css/ionicons.min.css', 'public/css/vendor/ionicons.css') .copy('Ionicons/fonts/ionicons.ttf', 'public/css/fonts/ionicons.ttf') .copy('Ionicons/fonts/ionicons.woff', 'public/css/fonts/ionicons.woff') .copy('animate.css/animate.min.css', 'public/css/vendor/animate.css'); });
-
Install the Auja javascript files through bower. When installing through bower the
gulp
command is automaticly called by bower.$ bower install auja
-
Install the Auja Laravel library through composer. The library depends on Auja-PHP which is a API wrapper for communicating with the javascript frontend.
$ composer require label305/auja-laravel:dev-dev
-
Publish the Auja config file and main view
$ php artisan config:publish label305/auja-laravel $ php artisan view:publish label305/auja-laravel
-
Add the
AdminServiceProvider
,AujaFacade
andAujaRouteFacade
to yourapp.php
config file.'providers' => [ ... 'YourApp\Providers\AdminServiceProvider', ], 'aliases' => [ ... 'Auja' => 'Label305\AujaLaravel\Facade\AujaFacade', 'AujaRoute' => 'Label305\AujaLaravel\Facade\AujaRouteFacade', ],
-
Customize the
auja-laravel/config.php
file and specify the models you wish to be included in the Admin interface. -
Create a
app/controllers/Admin/ClubsController.php
orapp/Http/Controllers/Admin/ClubsController.php
, to manage theClubs
in your admin interface. You can do this for all your models. Here is an example:<?php namespace YourApp\Http\Controllers\Admin; use Illuminate\Routing\Controller; class ClubsController extends Controller { public function index() { if (Input::has('q')) { $items = Club::where('title', 'LIKE', sprintf('%%%s%%', Input::get('q')))->simplePaginate(10); } else { $items = Club::simplePaginate(10); } $linkTarget = urldecode(URL::route(AujaRoute::getEditName('Club'), '%d')); return Response::json( Auja::itemsFor($this, $items, $linkTarget) ); } public function store() { Club::create(Input::all()); return Response::json( new Message() ); } public function update($id) { $page = Club::find($id); $page->fill(Input::all()); $page->save(); return Response::json( new Message() ); } public function delete($id) { $page = Club::find($id); $page->delete($id); return Response::json( new Message() ); } }
-
Now setup the routes for the administration panel.
```php
AujaRoute::group(['before'=> 'auth'], function() {
AujaRoute::resource('Club', 'YourApp\Http\Controllers\Admin\ClubsController');
AujaRoute::resource('Team', 'YourApp\Http\Controllers\Admin\TeamsController');
});
```
- Tip: add the following lines to your
.gitignore
:
```
node_modules
/public/css/vendor
/public/js/vendor
```
-
Make sure node.js and npm are installed.
-
$ npm install -g bower gulp
-
Make sure you have setup the
.bowerrc
file for Laravel and gulp. By the way these are the Laravel 5 defaults but will work on other versions as well.{ "directory": "vendor/bower_components", "scripts": { "postinstall": "gulp publish" } }
-
Install the javascript dependencies that are included in Laravel 5 by default. If you work with another version add the
package.json
file to your projects root.{ "devDependencies": { "gulp": "^3.8.8", "laravel-elixir": "*" } }
And run:
$ npm install
-
Setup the
gulpfile.js
in your projects root.var elixir = require('laravel-elixir'); elixir(function(mix) { // mix.sass('app.scss'); // included in Laravel 5 but not manditory });
-
Now you're all setup. Laravel 5 also includes a
bower.json
file but placing this file is not mandatory for other versions.{ "name": "Laravel Application", "dependencies": { "bootstrap-sass-official": "~3.3.1", "font-awesome": "~4.2.0", "auja": "~3.0.0" } }
You can provide your own subclasses of ModelConfig
to the Auja config file in the models
key. This way you can customize icons
for example.
-
Create a new class that extends
ModelConfig
, for exampleUserConfig
.class UserConfig extends ModelConfig { public function getModelClass() { return 'User'; } public function getIcon() { return Icons::ion_ios7_person; } public function isSearchable() { return false; } }
-
Modify the
auja-laravel/config.php
file to reference this new class.'models' => [ ... 'YourApp\Admin\Configurations\UserConfig' ],
By default Auja provides a default support controller to handle authentication and providing the main interface manifest. If you want your own AujaSupportController to handle authentication you can implement your own. Create a YourSupportController.php
. This file contains information on what kind of information the admin area should contain and how administrators authenticate.
-
Set
route
tonull
in the configucation and create your own route to the controller.AujaRoute::group(['prefix' => 'admin'], function() { AujaRoute::support('YourApp\Http\Controllers\Admin\YourSupportController'); }); AujaRoute::group(['before'=> 'auth', 'prefix' => 'admin'], function() { AujaRoute::resource('Club', 'YourApp\Http\Controllers\Admin\ClubsController'); AujaRoute::resource('Team', 'YourApp\Http\Controllers\Admin\TeamsController'); });
-
Create the
YourSupportController.php
file and make sure it implementsAujaSupportControllerInterface
.<?php namespace YourApp\Http\Controllers\Admin; use Illuminate\Routing\Controller; use Label305\Auja\Shared\Message; class YourSupportController extends Controller implements AujaSupportControllerInterface { public function index() { return View::make('auja-laravel::admin/index'); } public function manifest() { $username = Auth::user() == null ? null : Auth::user()->name; $authenticationForm = Auja::authenticationForm('Welcome Administrator!', 'admin/login'); $main = Auja::main( 'Your Awesome App', Auth::check(), $username, 'admin/logout', $authenticationForm ); $main->setColor(Main::COLOR_MAIN, '#00FF00'); $main->setColor(Main::COLOR_ALERT, '#00FF00'); $main->setColor(Main::COLOR_SECONDARY, '#666666'); return Response::json($main); } public function login() { Auth::attempt(['email' => Input::get('email'), 'password' => Input::get('password')]); $message = new Message(); $message->setAuthenticated(Auth::check()); return Response::json($message); } public function logout() { Auth::logout(); return Redirect::to('admin'); } }
Copyright 2014 Label305 B.V.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.