【发布时间】:2019-10-13 21:22:44
【问题描述】:
所以基本上错误表明我没有名为 updated_at 的列,但我知道我没有它,我不想拥有它。我的数据库表只有以下列:requester、user_requested、id、status。
这是我的模特
class Friendships extends Model
{
protected $fillable = ['requester', 'user_requested', 'status'];
}
这是我的配置文件控制器
public function sendRequest($id){
return Auth::user()->addFriend($id);
}
这是我的friendable.php
namespace App\Traits;
use App\Friendships;
trait Friendable{
public function test(){
return 'hi' ;
}
public function addFriend($id){
$Friendship = Friendships::create([
'requester' => $this->id,
'user_requested' => $id
]);
if($Friendship){
return $Friendship;
}
return 'failed';
}
}
它说方法 addFriend 没有找到,并且 create 显然不起作用,因为没有找到 id。
【问题讨论】:
-
在模型中尝试
public $timestamps = false;并检查