I have a task in which i need to select all drivers from database in Laravel and highlight in green those ones which are available. This is the error i get:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'user_id' in field list is ambiguous (SQL: SELECT first_name,user_id FROM users as u inner join users_vehicles group by u.users_id)
Database table structure:
Here is my code so far:
UserModel.php
<?php
namespace App\Models;
use DB;
use Illuminate\Database\Eloquent\Model;
class UserModel extends Model
{
//
public function svivozaci(){
$query=DB::SELECT("SELECT first_name,user_id FROM users as u inner join users_vehicles group by u.first_name");
return $query;
}
}
admin.blade.php
@extends('layout')
@section('content')
<h1>Admin page </h1>
@foreach($data as $d)
{{$d->first_name}} <br>
@endforeach
@endsection