Skip to content

PHP Merge two array with duplicates

I have two array. My Result; I would like to merge it with duplicates ids. Answer If your arrays are indeed this small, array_shift is a good tool. You can copy your array, pop an item off it continuously, and then re-copy the array as needed. The performance of array_shift gets worse as arrays grow large (as…

Eloquent Sort By depend on the field

I have a query like this: I want to sort the result but i have problem. if the result of withMin if null i want to sort it by another field (lets say ‘product.sale_price’). Or how can i make a new field, lets say ‘final_price’, if promotion_price is null use sale_price. What i already …

I can’t execute SQL sentence twice

I can’t execute SQL twice somehow. In the case of below code, 1st SQL sentence【SELECT h.title, h.place, h.introduction ~】works. And 2nd one【SELECT name ~】 doesn’t work. If I change 1st SQL sentence to comment out, 2nd SQL work correctly. Do you notice how to work both of SQL. As you can see, there…

Laravel – Use a column from a model relation

in my livewire view i get all the credits from their respective owners through the model relationship between clients and credits Model: Client Model: Credit in my livewire view I have a foreach that gets me all the clients, inside a switch that counts the credits of the clients Livewire: Show-client So far e…

can not hide X-Powered-By with expose_php

I want to hide my php version in response headers and for that I changed expose_php to off but it does not work and I added Header unset X-Powered-By to my htaccess file but in did not work either can you guide me for that? Answer and I added Header unset X-Powered-By to my htaccess file but in did not