Answers for "find with relation laravel"

PHP
0

laravel relations find

$comment = Post::find(1)->comments()
                    ->where('title', 'foo')
                    ->first();
Posted by: Guest on May-26-2021
0

laravel relations find

use AppModelsComment;

$comment = Comment::find(1);

return $comment->post->title;
Posted by: Guest on June-10-2021
0

laravel relations find

class Project extends Model
{
    public function deployments()
    {
        return $this->hasManyThrough(
            Deployment::class,
            Environment::class,
            'project_id', // Foreign key on the environments table...
            'environment_id', // Foreign key on the deployments table...
            'id', // Local key on the projects table...
            'id' // Local key on the environments table...
        );
    }
}
Posted by: Guest on June-10-2021

Code answers related to "find with relation laravel"

Browse Popular Code Answers by Language