mercredi 3 mai 2017

Error while trying to get max number from sql database using eloquent

hi so ive got a database running with username,password and user_id as primary key and im trying to get the highest number out of the user_id collum using eloquent

this is my current error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.id' in 'where clause' (SQL: select * from users where users.id = 2 limit 1)

this is what my model looks like:

users.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;


use DB;
use Eloquent;

class users extends Eloquent
{
  public static function register()
  {
      $user_id = users::find(DB::table('users')->max('user_id'));


return $user_id;
  }

  }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire