php - Laravel Models - Grabbing Object's ID -
i know 1 can create object model represents particular entry in db using modelname::find($model_id). i'm curious how 1 goes grabbing current id within model on function - wanted expand user model return of songs uploaded said user.
i want able call $user = user::find($user_id) grab relevant user, , call function within model so: $user->list_songs();. how i, within function in model (public function list_songs()), check see current id is? i'm passing variable, , seems counter-intuitive idea of model.
within model can use $this->id long model has been saved database.
Comments
Post a Comment