Skip to content

Tag: laravel

Array push and merge in php

How to merge one array with multple elements but the same index into on array with all index in PHP. I have one array look like this and i want to merge into one array. and my expected result i want like this Anyone can help in PHP please. Answer Since you want to change a multi-dimensional array to single

Order By based on number of LIKE occurences Laravel Php

Currently I have a simple search engine on my site I’m trying to match the keyword in all fields. Here’s the simplified working codes What I’m trying to do is to match all keyword, count all matched keyword (for every occurences) and do Order By Desc from highest occurences to lowest. If I e…

Laravel create if statement when img missing in array in blade

How to create if statement in laravel blade when my email with image missing in array ? When email is not defined in array, laravel show error. My goal is when email with image are defined in array show the image, if email isnt defined show custom jpg. my array blade Answer You could use the null coalesce ope…

Laravel – Error when calling my logout route

I did the installation of laravel as sent by the basic authentication guide with auth, my login works and returns me a token, but when I try to log out it returns me the following error: this error in my middlaware where it was for him to do the control with the token, but I think I’m doing something wr…

Laravel withPivot is not returning pivot extra fields

I have Two models called Product and Store In Store model i have this codes: In Product model i have this code: And i have a resource for Product with this code: So when i use $store = AppModelsStore::find($store_id); it should return a pivot in my store relation but it is not doing this. Please help me to so…

Call to a member function notify() on null in Laravel 8

I want to send an SMS to a mobile phone (if he had already turned on the two-factor authentication system). So at LoginController I added this method: And this loggendin method is inside of a trait called TwoFactorAuthentication, which goes like this: Now the problem is when I want to log in, this message app…

How to carousel in loop?

I am trying to loop carousels with class “active” first item here is my code I trying to put active item in the loop too. Answer You can use $loop->iteration==1 as said in laravel blade doc inside the foreach: