Example #1
0
 public function index($slug = null)
 {
     //No document requested, list documents
     if (null == $slug) {
         $docs = Doc::all();
         $data = array('docs' => $docs, 'page_id' => 'docs', 'page_title' => 'All Documents');
         return View::make('doc.index', $data);
     }
     try {
         //Retrieve requested document
         $doc = Doc::where('slug', $slug)->with('statuses')->with('userSponsor')->with('groupSponsor')->with('categories')->with('dates')->first();
         if (!isset($doc)) {
             App::abort('404');
         }
         $showAnnotationThanks = false;
         if (Auth::check()) {
             $userId = Auth::user()->id;
             $userMeta = UserMeta::where('user_id', '=', $userId)->where('meta_key', '=', UserMeta::TYPE_SEEN_ANNOTATION_THANKS)->take(1)->first();
             if ($userMeta instanceof UserMeta) {
                 $showAnnotationThanks = !$userMeta->meta_value;
             } else {
                 $showAnnotationThanks = true;
             }
         }
         //Set data array
         $data = array('doc' => $doc, 'page_id' => strtolower(str_replace(' ', '-', $doc->title)), 'page_title' => $doc->title, 'showAnnotationThanks' => $showAnnotationThanks);
         //Render view and return
         return View::make('doc.reader.index', $data);
     } catch (Exception $e) {
         return Redirect::to('/')->with('error', $e->getMessage());
     }
     App::abort('404');
 }
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
//Route::get('/', function()
//{
//return View::make('hello');
//});
Route::get('test', function () {
    return 'heoolo';
});
Route::get('/doc', function () {
    $docs = Doc::all();
    $list = ['docs' => $docs];
    return View::make('article', $list);
});
Route::any('foo', function () {
    return 'Hello World';
});
Route::resource('home', 'HomeController');
Route::resource('login', 'AuthController');
//用户登录验证控制器类
Route::resource('signup', 'RegistController');
//用户注册控制器类
Route::resource('user', 'UserController');
//用户信息访问、修改类RESTful控制器
Example #3
0
 /**
  * 	Document Creation/List or Document Edit Views.
  */
 public function getDocs($id = '')
 {
     $user = Auth::user();
     if (!$user->can('admin_manage_documents')) {
         return Redirect::to('/dashboard')->with('message', "You do not have permission");
     }
     if ($id == '') {
         $docs = Doc::all();
         $data = array('page_id' => 'doc_list', 'page_title' => 'Edit Documents', 'docs' => $docs);
         return View::make('dashboard.docs', $data);
     } else {
         $doc = Doc::find($id);
         if (isset($doc)) {
             $data = array('page_id' => 'edit_doc', 'page_title' => 'Edit ' . $doc->title, 'doc' => $doc, 'contentItem' => $doc->content()->where('parent_id')->first());
             return View::make('documents.edit', $data);
         } else {
             return Response::error('404');
         }
     }
 }