php - Laravel ORM method vs attribute -


when dealing laravel's relations use this:

user::where(...)       ->first()       ->securityquestions()       ->take(2)       ->orderby(db::raw('rand()'))       ->get(); 

note use of securityquestions() instead of securityquestions otherwise raisethe error:

missing argument 1 illuminate\support\collection::get() 

now, on other parts away using:

user::where(...)       ->first()       ->securityquestions       ->contains(...) 

note use of securityquestions instead of securityquestions().

my guess in order retrieve stuff (and keep chaining wheres , stuff) database have use method while attribute has immutable resultset. knows if that's right?


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -