dimanche 7 juillet 2019

can someone explain what this laravel function those

I was going through my friends laravel code, i saw some functions like withPost and others, here is the code

public function show($id)
    {
        $categorylist = Category::all();
        $tagfoot = Tag::all();
        $post = Post::find($id); 
        $popularposts= Post::selectRaw("posts.*, count('comments.id') as comments_count")->leftJoin('comments','comments.post_id', '=', 'posts.id')->groupBy('posts.id')->orderBy('comments_count', 'desc')->take(6)->get();
        $prev = Post::where('id', '<', $post->id)->orderBy('id', 'desc')->first();;
        $next = Post::where('id', '>', $post->id)->orderBy('id', 'desc')->first();
        return view('posts.show')->withPost($post)->withTagfoot($tagfoot)->withCategorylist($categorylist)->withPrev($prev)->withNext($next)->withPopularposts($popularposts);
    }

pls what does withPost, withTagfoot, withCategorylist, withPrev, withNext, withPopularposts function actually do, ls its urgent pls



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire