I’m building a carpool app where its the intention that when a user registers they’re able to fill in they have a car however this car is in a table on its own.
When I try to create it with the field checkt
I get this error:
Argument 1 passed to Illuminate\Auth\Guard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\Cars given, called in /home/vagrant/Code/carpool-app-going-your-way/www/vendor/compiled.php on line 2078 and defined
Any ideas on how to fix it?
Here is my code:
registrar.php
public function create(array $data)
{
if (isset($_POST["ihaveacar"])){
return Cars::create([
'seats'=>$data['seats'],
'seats_taken'=>'0',
]);
}
return User::create([
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'screen_name' => $data['screen_name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'route' => $data['route'],
'state' => $data['state'],
'description' => $data['description'],
'license_since' => $data['license_since'],
]);
}
User.php
<?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;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends model implements AuthenticatableContract, CanResetPasswordContract{
use Authenticatable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['first_name', 'last_name', 'screen_name', 'email', 'password', 'birthday', 'license_since', 'kilometers', 'state', 'route','image','description','soft_delete', 'is_admin'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
use SoftDeletes;
protected $dates = ['deletec_at', 'created_at', 'updated_at'];
}
Any ideas how to fix this?
Thanks in advance
Edit: all of a sudden it seems to be running without errors. I don’t get it.
You're passing an instance of
App\Cars
to the registrar via thecreate()
method. Remove all non-login logic from the registrar and only perform said logic after the authentication logic is actually complete.