Пример #1
0
 public function index()
 {
     $news = $this->news->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
     $sliders = Photo::join('photo_album', 'photo_album.id', '=', 'photo.photo_album_id')->where('photo.slider', 1)->orderBy('photo.position', 'DESC')->orderBy('photo.created_at', 'DESC')->select('photo.filename', 'photo.name', 'photo.description', 'photo_album.folderid')->get();
     $photoalbums = PhotoAlbum::select(array('photo_album.id', 'photo_album.name', 'photo_album.description', 'photo_album.folderid', DB::raw('(select filename from ' . DB::getTablePrefix() . 'photo WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'photo.photo_album_id=' . DB::getTablePrefix() . 'photo_album.id) AS album_image'), DB::raw('(select filename from ' . DB::getTablePrefix() . 'photo WHERE ' . DB::getTablePrefix() . 'photo.photo_album_id=' . DB::getTablePrefix() . 'photo_album.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $videoalbums = VideoAlbum::select(array('video_album.id', 'video_album.name', 'video_album.description', 'video_album.folderid', DB::raw('(select youtube from ' . DB::getTablePrefix() . 'video as v WHERE album_cover=TRUE and v.video_album_id=' . DB::getTablePrefix() . 'video_album.id) AS album_image'), DB::raw('(select youtube from ' . DB::getTablePrefix() . 'video WHERE ' . DB::getTablePrefix() . 'video.video_album_id=' . DB::getTablePrefix() . 'video_album.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     return view('site.home.index', compact('news', 'sliders', 'videoalbums', 'photoalbums'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     try {
         $post_tag = new Post();
         $post_tag->title = $request->input('title');
         $post_tag->body = $request->input('body');
         $post_tag->save();
         return response()->json(array('error' => false, 'message' => 'Post tag added successfully.'), 200);
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #3
0
 /**
  * [list description]
  * @return [type] [description]
  */
 public function blog()
 {
     // $post = \Post::type('post')->status('published');
     $posts = \Post::type('post')->published()->get();
     // dd($posts);
     return view('posts.list', compact('posts'));
 }
Пример #4
0
 /**
  * Metodo para se recuperar a entidade que tem o $id passado por parametro
  * OBS: necessita do input hidden tipoEntidade;
  */
 public function getEntidade($id)
 {
     $tipoEntidade = Input::get('tipoEntidade', '');
     switch ($tipoEntidade) {
         case 'App\\Perfil':
             $entidade = Perfil::findOrFail($id);
             break;
         case 'App\\Ong':
             $entidade = Ong::findOrFail($id);
             break;
         case 'App\\Empresa':
             $entidade = Empresa::findOrFail($id);
             break;
         case 'App\\Post':
             $entidade = Post::findOrFail($id);
             break;
         default:
             $entidade = '';
             // Se nao encontrar nenhuma entidade, quebrar?
             // App::abort(500, 'Entidade nao identificada');
             break;
     }
     return $entidade ? $entidade : false;
 }
Пример #5
0
 public function delete($id)
 {
     Post::destroy($id);
     return redirect('/post/index');
 }
Пример #6
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $post = Post::all();
     return view('post.index', compact('post'));
 }
Пример #7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $post = Post::find($id);
     $post->delete();
     return Redirect::to('post');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $tag = Post::find($id);
     if ($tag->delete()) {
         return response()->json(array('error' => false, 'message' => 'Tag has been deleted.'), 200);
     } else {
         return response()->json(array('error' => false, 'message' => 'Tag has not been deleted.'), 200);
     }
 }