samedi 25 mai 2019

Laratable ambiguous colums on search

I'm using Laravel 5's laratables. and in my PartnersVehicles model i have this function

    public static function laratablesQueryConditions($query)
    {
        $uid = Auth::id(); //user ID
        $pid = Partners::where('uid', $uid)->first(); //get partner ID

        return $query->select('partners_vehicles.id', 'partners_vehicles.year', 'vehicle_makes.make', 'partners_vehicles.model', 'vehicle_colors.color', 'partners_vehicles.created_at')
        ->join('vehicle_makes', 'vehicle_makes.id', '=', 'partners_vehicles.make')
        ->join('vehicle_colors', 'vehicle_colors.id', '=', 'partners_vehicles.color')
        ->where('partners_vehicles.partner_id', $pid->id);

    } 

the table loads fine, but when I try and do an ajax search in the search box, i get this error below

Integrity constraint violation: 1052 Column 'make' in where clause is ambiguous (SQL: select count(*) as aggregate from partners_vehicles inner join vehicle_makes on vehicle_makes.id = partners_vehicles.make inner join vehicle_colors on vehicle_colors.id = partners_vehicles.color where partners_vehicles.partner_id = 7 and (year like %2% or make like %2% or model like %2% or color like %2%))

any idea how to fix this? what am i missing? Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2K5CErE
via IFTTT

Aucun commentaire:

Enregistrer un commentaire