我正在尝试将故障单表上的状态更新为值:2。 一旦我可以创建评论...(正在工作.. :)),我想将状态更改为2。
这是我的票证模型和以下功能:
import pandas as pd
import numpy as np
df = pd.read_csv('C:/Dataset.csv')
df['split'] = np.random.randn(df.shape[0], 1)
split = np.random.rand(len(df)) <= 0.75
training_set = df[split]
testing_set = df[~split]
答案 0 :(得分:2)
您需要先获取对象,然后才能更新它:
public function addComment($id,$body,$solved)
{
$ticket = $this->find($id);
$ticket->status = 2;
$ticket->save();
$ticket->comments()->create([
'ticket_id' => $id,
'body' => $body,
'user_id' => auth()->id()
]);
}
答案 1 :(得分:1)
尝试像这样更改代码。也许这可以解决您遇到的问题:
public function addComment($id,$body,$solved)
{
$ticket = Ticket::find($id);
$ticket->status = 2;
$ticket->save();
$ticket->comments()->create([
'ticket_id' => $id,
'body' => $body,
'user_id' => auth()->id()
]);
}