Ejemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($slug)
 {
     $article = \App\Articles::where('slug', '=', $slug)->first();
     $articles = \App\Articles::whereNotIn('slug', array($slug))->take(3)->get();
     $data = array('article' => $article, 'articles' => $articles);
     return view('pages.article', $data);
 }
 /**
  * Display the specified resource.
  *
  * @param $y
  * @param $m
  * @param $d
  * @param $alias
  */
 public function show($y, $m, $d, $alias)
 {
     $article = Articles::where('alias', $alias)->first();
     if (!$article) {
         return redirect('/');
     }
     $pageTitle = $article->title;
     $pageDescription = $article->short_description;
     $pageInfo = 'Posted by ' . $article->user->username . ' on ' . $article->created_at->format('F j, Y');
     return view('articles.show', compact('article', 'pageTitle', 'pageDescription', 'pageInfo'));
 }
Ejemplo n.º 3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $data = array();
     $search = $request->input('search');
     $schools = Schools::where('nama_sekolah', 'like', '%' . $search . '%')->get();
     $articles = Articles::where('title', 'like', '%' . $search . '%')->where('category', 'news')->get();
     $activities = Articles::where('title', 'like', '%' . $search . '%')->where('category', 'activity')->get();
     $events = Events::where('title', 'like', '%' . $search . '%')->get();
     $total = $schools->count() + $articles->count() + $activities->count() + $events->count();
     $data = array('schools' => $schools, 'articles' => $articles, 'activities' => $activities, 'events' => $events, 'search' => $search, 'total' => $total);
     return view('pages.pencarian', $data);
 }
Ejemplo n.º 4
0
 public function delete($tipe, $id)
 {
     if ($tipe == 'event') {
         Events::where('id', $id)->delete();
         return redirect('dashboard/admin/events');
     } elseif ($tipe == 'article') {
         Articles::where('id', $id)->delete();
         $upload_folder = '/img/article/';
         unlink(public_path() . $upload_folder . $id . '.jpg');
         return redirect('dashboard/admin/articles');
     } elseif ($tipe == 'user') {
         $role = Users::where('id', $id);
         Users::where('id', $id)->delete();
         if ($role - role == 'sekolah') {
             Schools::where('user_id', $role->id)->delete();
         }
         return redirect('dashboard/admin/users');
     } elseif ($tipe == 'activity') {
         Articles::where('id', $id)->delete();
         return redirect('dashboard/admin/activities');
     }
 }
Ejemplo n.º 5
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($slug)
 {
     $articles = Articles::where('slug', $slug)->get();
     return view('backend.detail', ['articles' => $articles]);
 }
Ejemplo n.º 6
0
 public function simpanpost($request)
 {
     $user = Auth::user()->id;
     $judul = $request->input('judul');
     $isi = $request->input('isi');
     $gambar = $request->file('gambar');
     Articles::insert(['created_at' => date('Y-m-d h:i:sa'), 'updated_at' => date('Y-m-d h:i:sa'), 'user_id' => $user, 'title' => $judul, 'category' => 'activity', 'slug' => str_replace(' ', '-', $judul), 'intro' => substr($isi, 0, 300), 'content' => $isi]);
     $filename = Articles::where('slug', str_replace(' ', '-', $judul))->first()->id;
     $upload_folder = '/img/article/';
     $gambar->move(public_path() . $upload_folder, $filename . '.jpg');
     return redirect('dashboard/sekolah');
 }
Ejemplo n.º 7
0
 public function index()
 {
     $articles = Articles::where('active', 1)->orderBy('id', 'desc')->get();
     return view('index', ['articles' => $articles]);
 }