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

Unable to open serial port using Putty to bluetooth device on windows 7 64 bit -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -