public function postStore(Request $request) { $existSite = Site::whereUser_id(Auth::id())->whereUrl($request->url); // 若站点已存在则更新站点 if ($existSite->count()) { return self::postUpdate($request, $existSite->first()->id); } // 若站点不存在则存储站点 $site = $request->all(); $site['user_id'] = Auth::id(); $tag = TagController::getCreate($request->tag); $site['tag_id'] = $tag->id; if (Site::create($site)) { return redirect('site/tag/' . $tag->name); } exit('书签保存失败'); }