app/Http/Controllers/SearchController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function tag(Request $request, $slug)
    {
        $videos = DB::table('videos')
                    ->join('video_tags', 'video_tags.video_id', '=', 'videos.id')
                    ->join('tags', 'tags.id', '=', 'video_tags.tag_id')
                    ->select('videos.*')
                    ->where('tags.slug', $slug)
                    ->where('videos.status', '1')
                    ->orderBy('videos.id', 'desc')
                    ->distinct('videos.id')
                    ->paginate(16);
        $tags = Tag::where('slug', $slug)->take(1)->get();
        foreach($tags as $tag){
            $search = $tag->title;
        }
        $tagKey = 'tag_' . $slug;
        if (!Session::has($tagKey)) {
            Tag::where('slug', $slug)->increment('views');
            Session::put($tagKey, 1);
        }
        return view('search', compact('videos', 'search'));
    }
public function tag ( Request $ request , $ slug ) { $ videos = DB :: table ( 'videos' ) -> join ( 'video_tags' , 'video_tags.video_id' , '=' , 'videos.id' ) -> join ( 'tags' , 'tags.id' , '=' , 'video_tags.tag_id' ) -> select ( 'videos.*' ) -> where ( 'tags.slug' , $ slug ) -> where ( 'videos.status' , '1' ) -> orderBy ( 'videos.id' , 'desc' ) -> distinct ( 'videos.id' ) -> paginate ( 16 ) ; $ tags = Tag :: where ( 'slug' , $ slug ) -> take ( 1 ) -> get ( ) ; foreach ( $ tags as $ tag ) { $ search = $ tag -> title ; } $ tagKey = 'tag_' . $ slug ; if ( ! Session :: has ( $ tagKey ) ) { Tag :: where ( 'slug' , $ slug ) -> increment ( 'views' ) ; Session :: put ( $ tagKey , 1 ) ; } return view ( 'search' , compact ( 'videos' , 'search' ) ) ; }
Display a listing of the resource.
Display a listing of the resource .
// Videos                                 // Search Tag Display // Increment Views