Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #287
    dan
    Participant

    Both are used to extract rows from the database. Let us say I have a User model, what is the difference between User::all() and User::get()

    #288

    all() is a method of Eloquent\Model while get() is a method of Eloquent\Builder

    With all() you cannot modify the query while with get() you can.

    Example:

    all()

    $user = User::all();

    get()

    $user = User::select(‘id’, ‘name’)->where(‘name’, ”)->orderBy(‘id’, ‘desc’)->get();

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.