What is the difference between these pieces of code. Articles - model

$article = Articles::find($id); $article = Articles::all()->toArray()->get($id); 

The first way works in the php page: {{article ['title']}} And the second way is not. When will the second method work and what is the difference between these methods of data extraction?

    1 answer 1

    • select all entries - use all()
    • use conditions - call get()
    • know id - find() , findOrFail() , etc.

    After toArray() you have an array. He has no methods.
    In other words, the second option will not work at all.

    see Eloquent :: Adding Additional Constraints