/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $articles = article::latest()->get(); if ($request->ajax() || $request->wantsJson()) { return new JsonResponse($users); } return view('articles.index', compact('articles')); }
public function remove_article($id) { if (Auth::User()->admin) { article::destroy($id); } else { $article = Auth::User()->articles->find($id); if (!is_null($article)) { $article->delete(); } } }
/** * Show the application welcome screen to the user. * * @return Response */ public function index() { $about = array(''); //$news = array(); $articles = article::all(); foreach ($articles as $article) { //echo $article->type; } $about = \App\article::where('type', '=', 'about')->first(); return view('home')->with('credential', $this->credential)->with('about', $about); }
public function showArticle(User $user) { $article = article::with('ArticleCategories')->where('user_id', $user->id)->get(); $checkArticle = $article->isEmpty(); //dd($article); if (\Auth::check()) { $url = str_contains($this->checkloginpage($user->name), \Auth::user()->name); } else { $url = false; } return view('userArticle.index', compact('user', 'article', 'url', 'checkArticle')); }
/** * Bootstrap any application services. * * @return void */ public function boot() { date_default_timezone_set('Asia/Jakarta'); $abouts = array(); $news = array(); $memo = array(); Config::set('registered', false); $articles = \App\article::select('article.*', 'users.first_name', 'users.last_name')->leftJoin('users', 'article.user', '=', 'users.id')->get(); foreach ($articles as $article) { switch ($article->type) { case 'about': $abouts[] = $article; break; case 'news': $news[] = $article; break; case 'memo': $memo[] = $article; break; } } $kota = \App\kota::all(); foreach ($kota as $v) { $dkota[$v->idkota] = $v->nmkota; } $satuan = \App\satuan::all(); foreach ($satuan as $v) { $dsatuan[$v->idsatuan] = $v->namasatuan; } $cabang = \App\cabang::all(); foreach ($cabang as $v) { $dcabang[$v->idcabang] = $v->nama; } $dcabang = \App\Helpers::assoc_merge([0 => '--Daftar Cabang--'], $dcabang); //Hitung total quote yang baru $quotes = \App\quote::where('status', '=', '0'); $quotesData['all'] = $quotes->limit(3)->get(); $quotesData['count'] = $quotes->count(); //Hitung total SJT yang belum tiba $sjt = \App\berangkat::where('status', '<', '3'); $sjtData['all'] = $sjt->limit(3)->get(); $sjtData['count'] = $sjt->count(); //Hitung total tagihan yang belum terbayar $totNotification = $quotes->count() + $sjt->count(); $notification = ['all' => $totNotification, 'quote' => $quotesData, 'sjt' => $sjtData]; $data = array('abouts' => $abouts, 'news' => $news, 'memo' => $memo, 'kota' => $dkota, 'satuan' => $dsatuan, 'cabang' => $dcabang, 'nquotes' => $quotes, 'notification' => $notification); return View::share($data); }
public function update(Request $request, $id) { $this->validate($request, ['name' => 'required|max:64', 'content' => 'required']); $parms = array(); $parms['name'] = Input::get('name'); $parms['content'] = Input::get('content'); /* $article=article::find($id); $article->name = Input::get('name'); $article->content = Input::get('content'); $article->update(); */ $article = new article(); return $article->where('id', $id)->update($parms) ? Redirect::to('/article') : Redirect::back()->withInput()->withErrors('更新失敗!'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(article $article) { $article->delete(); \Session::flash('saved', 'article deleted'); return redirect('articles'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { try { article::destroy($id); } catch (QueryException $e) { return Redirect::back()->with('error', 'Gagal dihapus'); } finally { return Redirect::to('/article')->with('message', 'Data berhasil dihapus'); } }
public function index() { $articles = article::latest()->published()->get(); return view('pages.articles.articles', compact('articles')); }
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]; }); } });
public function getPicture($filename) { $picture = article::where('filename', '=', $filename)->firstOrFail(); $file = Storage::disk('local')->get($picture->filename); return response($file, 200)->header('Content-Type', $picture->mime); }
public function articleTest() { $data = array('article' => article::all()); return View('articleTest', $data); }
/** * 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); }