How to create a Eloquent model instance from a raw Object?

后端 未结 3 1828
被撕碎了的回忆
被撕碎了的回忆 2020-12-31 10:18

I need to make a raw database query using Laravel:

$results = DB::select(\"SELECT * FROM members 
    INNER JOIN (several other tables) 
    WHERE (horribly          


        
3条回答
  •  生来不讨喜
    2020-12-31 10:30

    You can simply init a new model:

    $member = new App\Member;
    

    Then you can assign the columns:

    $member->column = '';
    

    Or if all columns are mass assignable:

    $member->fill((array)$results);
    

    Or have I misunderstood something?

提交回复
热议问题