Beispiel #1
0
 public function edit($id)
 {
     $user = Auth::user();
     $article = article::find($id);
     /**
      * 9/21 驗證非本人登入
      */
     if ($user->id != $article->user_id) {
         return Redirect::to('/article');
     }
     return view('Mars.article.edit')->withTitle(self::$title)->withFun(self::$fun)->withArticle($article);
 }
Route::get('getcabang', 'QuoteController@getCabang');
// Articles//
// OrderOnline
Route::post('quote/create', 'QuoteController@quoteCreate');
// About /////
// Tracking ////
Route::resource('tracking/search', 'TrackingController');
// News ////
Route::get('news/{id}', function ($id) {
    $dnews = \App\article::select('article.*', 'users.first_name', 'users.last_name')->leftJoin('users', 'article.user', '=', 'users.id')->where('article.id', '=', $id)->first();
    return view('master')->with('dnews', $dnews);
});
/// End World section
// Info //
Route::get('info/{id}', function ($id) {
    $dinfo = \App\article::find($id);
    return view('world.info')->with('dinfo', $dinfo);
});
//// End Info Selection //////
////////////////////////////////////////
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::group(['prefix' => 'test'], function () {
    $i = ['cabang', 'kota', 'konsumen'];
    $c = ['cabang' => 'CabangController', 'konsumen' => 'KonsumenController', 'kota' => 'KotaController'];
    $user = \App\User::first();
    foreach ($i as $v) {
        Route::get($v, function () use($c, $v, $user) {
            return ucfirst($user->name) . " say : Ini routing " . $v . ' dihandle oleh Controller ' . $c[$v];
        });
    }
});
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     try {
         $article = article::find($id);
         $article->type = Request::get('jenis');
         $article->title = Request::get('judul');
         $article->author = Request::get('author');
         $article->description = Request::get('description');
         $article->keywords = Request::get('keywords');
         $article->tags = Request::get('tags');
         $article->scontent = Request::get('short');
         $article->content = Request::get('content');
         $article->user = Session::get('user')->id;
         $article->save();
     } catch (QueryException $e) {
         return view()->withErrors($e->getMessage());
     }
     return Redirect::to('/article');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     echo session::get('is_logged_in');
     $article = article::find($id);
     return View::make('articles.edit')->with('article', $article);
 }