TarikAli
2 months ago
548
8
Laravel

is url path in model make a query ?

Posted 2 months ago by TarikAli

Hello, in Post model i use this method to get the path of current post

Post Model : public function path () { return url ( 'posts/'.{$this->id} ); }

when i make loop throw posts like

foreach ( $posts as $post) { $post->path }

is $post->path here will make another query to the database or will take the id from current $post of loop of course i'dont want to make another query because i already has it in $post of the loop . Thanks

Please sign in or create an account to participate in this conversation.