Skip to content
Advertisement

Tag: eloquent

Error: Object of class AppHttpResourcesProductAttributeResource could not be converted to int

I’m using method in my model to mutate a single response to my client When call product Laravel using this method name by default? Debugger show this area: C:xampphtdocs…/…vendorLaravelframeworksrcIlluminateDatabaseEloquentConcernsHasAttributes.php:521 How can I resolve this error? Answer in my case i use a reserved method name in my model for example i define a new attribute() method for my one to

Store product multiple colors to the database Laravel

I have a product table which has price, name, stock etc. and color_products table which has color_id, product_id. I want to store a product to the database with selected colors so far I’m getting an error Invalid argument supplied for foreach(). How can I fix this? Controller Blade file Answer try to rename your select field to be something like

Query a model using a relationship

I have a model called unit that has this relationship In the UserData model there is a column called user_id which I am trying to put in my condition in my query. I am trying to do a query like this but there is no user_id column in the Unit table, only though the users relationship Answer Ended up doing

Use Laravel Eloquent joining

Hello I want to retrieve only rows of quizzes that the student didn’t take yet When he completes a quiz the variable done in QuizStudent table is going to become 1 Quiz table My relationships: …

Advertisement