提交故事后获得积分
get point after submit Story
提交后如何加分post?
这是我的控制器:
public function store(PostRequest $request)
{
$story = Auth::user()->post()->create($request->all());
$image = $request->File('image');
if ($image) {
$image_name = time().'.'.$image->getClientOriginalExtension();
$destinationPath = public_path('upload');
$image->move($destinationPath, $image_name);
$story->image = $image_name;
}
$story->update();
if ($story) {
flash()->success('Your Story Has Been successfully added');
}
return redirect()->back();
}
这是我的 table 用户:
protected $fillable = [
'name', 'email', 'password', 'point'
];
这是我的 table post 故事 :
protected $fillable = [
'user_id','title','description','image'
];
由您来实现何时递增点字段的逻辑,但您可以按照以下方式实现。
$story->increment('point');
或者
$story->point++;
当然还有$story->save();
提交后如何加分post?
这是我的控制器:
public function store(PostRequest $request)
{
$story = Auth::user()->post()->create($request->all());
$image = $request->File('image');
if ($image) {
$image_name = time().'.'.$image->getClientOriginalExtension();
$destinationPath = public_path('upload');
$image->move($destinationPath, $image_name);
$story->image = $image_name;
}
$story->update();
if ($story) {
flash()->success('Your Story Has Been successfully added');
}
return redirect()->back();
}
这是我的 table 用户:
protected $fillable = [
'name', 'email', 'password', 'point'
];
这是我的 table post 故事 :
protected $fillable = [
'user_id','title','description','image'
];
由您来实现何时递增点字段的逻辑,但您可以按照以下方式实现。
$story->increment('point');
或者
$story->point++;
当然还有$story->save();