Skip to content

Tag: php

Trying to do basic subtraction from a database table

I’m trying to subtract data based on user input, for example: UPDATE table SET quantity=quantity – * some input value* This is easy if I’m subtracting field by field, where id=1…2…3, but I want to subtract values automatically when I input quantity, so if input is 60, and there i…

Left Join – In Eloquent

I would like to connect user table and like table based on the user_id So I have this Model user.php like.php and my query I would like to return the ‘likes’ table inside the ‘user’ but it doesnt work. I would like to left join it. What am I doing wrong? Answer Well, you need to use on…

Occurrence of a string inside another string

I was wondering if there is an easy way to look for a occurrence of a string inside another string. I’m using this query: $checkfileName[0] will be set in a if-statement, where it’s set to GiM1_0. My problem is that the column doesn’t contain that specific string, only a part of it. Image of…

Queries in Laravel – Equivalent to left join

Currently this is my laravel query But unfortunately, I would also like to get the connected data between the company and the user table, user_id for company and id for user this is the table company table: and the user table How to I connect the user under the company array? Answer You need to make a relatio…