<?php $units = Unit::all(); View::share('units', $units); Route::get('/', ['as' => 'home', function () { if (Auth::user()->check()) { $user = Auth::user()->get()->name; return Redirect::route('admin.index', ['user' => $user]); } elseif (Auth::admin()->check()) { $admin = Auth::admin()->get()->name; return Redirect::route('admin.index', ['admin' => $admin]); } return View::make('login'); }]); Route::get('login', function () { if (Auth::user()->check()) { $user = Auth::user()->get()->name; return Redirect::route('admin.index', ['user' => $user]); } elseif (Auth::admin()->check()) { $admin = Auth::admin()->get()->name; return Redirect::route('admin.index', ['admin' => $admin]); } return View::make('login'); }); Route::post('/', ['as' => 'user.login', 'uses' => 'UsersController@login']); Route::get('logout', ['as' => 'user.logout', 'uses' => 'UsersController@logout']); Route::get('users/create', ['as' => 'users.create', 'uses' => 'UsersController@create']); Route::post('users', ['as' => 'users.store', 'uses' => 'UsersController@store']); Route::get('admin/{admin}', ['as' => 'admin.index', 'uses' => 'AdminsController@index']); Route::resource('admin.users', 'UsersController', ['except' => ['edit', 'update']]); Route::resource('admin.units', 'UnitsController');
/** * Display a listing of products * * @return Response */ public function index() { return Response::json(Unit::all()); }
public function listUnit() { return Response::json(array('unit' => Unit::all(), 'type' => DrugType::all())); }