Skip to content
Advertisement

Tag: laravel

Eloquent – Update eloquent relations with foreach loop

I have a controller function to send multiple devices for repair (essentially an update request against multiple existing devices_repairs records). When I try to retrieve the devices from the devices table alongside the repair details (Devices table, devices_repairs table), the records are retrieved but when I try to update the values the update request doesn’t save the new data. This

Can i use where condtiton after calling relation with @with method?

This code: Return output like this: What can I do to return an empty array of users? I tried to do like this: But got an error: Answer With the syntax you tried, the answer is “No”, as ->with() doesn’t perform any kind of join logic; so posts tables is not available there. If you want to filter the User

How to get word after user input in textarea?

I have a text area to user to insert text, but if the user type {{name}}, {{nickname}} and {{email}}. It must show the message with that value. Let me demonstrate: For example: If user type: Hello, {{name}} has {{nickname}} and {{email}} the message must be like this: Hello, user A has nickname A and email@gmail.com. This is my blade view:

Can you delete models referenced in migrations with foreignIdFor()?

I have an old migration where I used the foreignIdFor() method to create a column. I later decided to delete the model which was referenced and now, when I do a migrate:refresh locally, that migration triggers an error saying that the model doesn’t exist, of course. So, should one never delete models referenced with foreignIdFor() and use unsignedBigInteger()instead ? EDIT:

How to merge array with custom value in laravel?

I need help to concatenate 2 arrays with custom values, I’ve used tried array_merge() and array_combine(), the result is always not same with what I want please help me guys Array 1 Array 2 I want the output be like this how to get the result like that Answer There isn’t any function that will automatically give you the result

Same blade component showing correctly in one view and not showing image from public folder in other views

I’m building a website using Laravel 8 where i have one component called app.blade.php. This component is the body of the project and includes the navbar. The problem that i’m facing is that this compenent is correctly showing in every view, while in a view called article.blade.php it is showing but without showing the logo image, only the ALT text.

Query More than one relationship from a model with() in Laravel

I need help to query a model base on its relationship: I have a model called StoreStock, this model is related to a Product model, which has two model relationships, MasterList and Price. I want to get all storeStock with two Product relationships. I know i can do something like With this, i can only pick either price or masterlist

Laravel eloquent update, 500 Internal Server Error

I want to update my database with Laravel eloquent update, but response is always 500 This is my model This is the function This is the route Exception: Thanks before, for helping.. Answer Loking at the exception: Seems like you don’t have updated_at column in your database table. There are two solutions for this: I: Create/update your migration to include

Advertisement