Convert a MySql query into Laravel

142
July 02, 2018, at 6:10 PM

My SQL query is:

SELECT* FROM cubes LEFT JOIN xkvs ON cubes.id=xkvs.cube_id WHERE xkvs.cube_id IS NULL

I tried the method from the laravel documentation but always get an error, that xkvs.cubes_id is an unknown column.

How do I write this correctly?

This is my try:

$cubes=DB::table('cubes')
        ->leftjoin('xkvs', function ($join) {
            $join->on('cubes.id', '=', 'xkvs.cubes_id')
                 ->where('xkvs.cubes_id', '=', null);
        })
        ->get();
Answer 1
DB::table('cubes')
    ->select('cubes.*')
    ->leftjoin('xkvs', 'cubes.id', '=', 'xkvs.cubes_id')
    ->whereNull('xkvs.cube_id')
    ->get();
READ ALSO
WordPress: Child theme works on localhost but not work on server [on hold]

WordPress: Child theme works on localhost but not work on server [on hold]

I did a simple child theme to remove some default sort selections in WooCommerce such as "sort by price", following the instruction of https://githubcom/woocommerce/theme-customization

39
Parse FormTextData & FormCheckBoxData from DOCX using PHP

Parse FormTextData & FormCheckBoxData from DOCX using PHP

I have searched a lot of options to parse docx file and get the textinput id and its value also the checkbox id and its value , I'm working on a project and it will be written on php , I tried xml option but there is no value tag in the xml found

50
How to combine the data for the same post together?

How to combine the data for the same post together?

I'm getting some posts data from 2 websites, One website has the title, the date, the description and the link, While the other has the title and the image

70
Confirm email button throws 'unexpected T_OBJECT_OPERATOR'

Confirm email button throws 'unexpected T_OBJECT_OPERATOR'

Im trying to fix an error whereby once an email is sent out to confirm the users email a button 'confirm email' (once clicked) throws the error:

72