Skip to content

Tag: laravel

How can I find the mix of 2 fields with a like in SQL/Laravel?

I have a table posts which contains posts (id field, candidate_id field and text field). I also have a candidate table (id, first_name, last_name). Now, I want to implement a method that would let me put some text, for example: “Mike Doe” and it would give me all the posts that contain “Mike…

How to create table with Foreign Keys in Laravel?

I have a users table and a roles table Now I want to create a user_role table which have two foreign keys But I’m getting an error: IlluminateDatabaseQueryException SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your Mar…

Files are repeated when uploading pictures to Laravel

I want to do bulk image upload on my blog that I write in Laravel. Wrote the code for loading images. Everything works, but the images are repeated After loading 6 images, I get this array of 21 elements. What’s wrong? Answer You’re appending $images to $urls on each image. Do it like this instead…