Answers for "with method in laravel"

PHP
0

with function laravel

Post::query()
    ->with(array('user' => function($query) {
        $query->select('id','username');
    }))
    ->get();
Posted by: Guest on March-19-2021
0

Laravel create method

Alternatively, there's also a create method which accepts a plain PHP array instead of an Eloquent model instance.
$post = Post::find(1);

$post->comments()->create([
    'message' => 'This is a new comment message'
]);
Posted by: Guest on July-14-2021

Code answers related to "with method in laravel"

Browse Popular Code Answers by Language