Esempio n. 1
0
 public function getTag($tag_id, $tag_name)
 {
     $posts = Post::where('active', true)->whereHas('skills', function ($query) use($tag_id) {
         $query->where('skills.id', $tag_id);
     })->orderBy('active_at', 'desc')->paginate(30);
     return view('search.tag')->with('posts', $posts)->with('tag_name', $tag_name);
 }
Esempio n. 2
0
 public function getMatched(\Illuminate\Http\Request $request)
 {
     $skills_old = [];
     if ($request->old('skills')) {
         $skills = (array) explode(",", $request->old('skills'));
         $skills = array_filter(array_unique($skills));
         foreach ($skills as $value) {
             $skill = Skill::find($value);
             if ($skill) {
                 $skills_old[] = $skill->toArray();
             }
         }
     } else {
         $skills_old = Auth::user()->skills()->get()->toArray();
     }
     $arrayId = [];
     foreach ($skills_old as $key => $value) {
         $arrayId[] = $value['id'];
     }
     $posts = Post::where('active', true)->whereHas('skills', function ($query) use($arrayId) {
         $query->whereIn('skills.id', $arrayId);
     })->orderBy('active_at', 'desc')->paginate(30);
     return view('post.matched')->with('posts', $posts)->with('skills', json_encode($skills_old));
 }
Esempio n. 3
0
 public function posts()
 {
     $posts = Post::where('active', true)->orderBy('active_at', 'desc')->paginate(30);
     return view('home.posts')->with('posts', $posts);
 }