我正在建立一个拼车应用程序,其目的是当用户注册时他们能够填写他们有车但是这辆车独自在一张桌子里。
当我尝试使用字段checkt
创建它时,我收到此错误:
传递给Illuminate \ Auth \ Guard :: login()的参数1必须是Illuminate \ Contracts \ Auth \ Authenticatable的实例,App / Cars的实例,在/ home / vagrant / Code / carpool-app-中调用在2078行上进行了你的方式/ www / vendor / compiled.php并定义了
关于如何修复它的任何想法?
这是我的代码:
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'];
}
任何想法如何解决这个问题?
提前致谢
编辑:突然之间似乎没有错误地运行。我不明白。
答案 0 :(得分:1)
你应该扩展Illuminate \ Foundation \ Auth \ User 喜欢
use Illuminate\Foundation\Auth\User as AuthUser;
class Member extends AuthUser
{
public $table='members';
protected $fillable = ['name', 'password','qq','phone'];
}
答案 1 :(得分:0)
您正通过App\Cars
方法将create()
的实例传递给注册商。从注册器中删除所有非登录逻辑,仅在认证逻辑实际完成后执行所述逻辑。
答案 2 :(得分:0)
您在create()
方法中返回了两种不同的对象类型。如果请求具有名为ihaveacar
的参数,则返回Car
实例,否则返回User
实例。您需要了解create()
方法应该实际返回的内容。