I'd still have an auto increment field in every table, but you can have another field you use as an index.
For example in my users table I have an auto incrementing id field, but I do not use it, I have another index userid.
On a side note, if you have an auto increment primary key field that is named other than id, this line needs to
be placed in model like this:
<?php namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class Powner extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
protected $table = 'powners';
protected $primaryKey = 'ownerid'; //THIS LINE
protected $fillable = [
'ownerid',
'oname',
'ostreet',
'odate',
'ocheck'
];
public $timestamps = [];
}
Something I was taught that it's always a good idea to have such a field in SQL Server and MySQL.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community