public function postSubject(Request $request, $cat_id) { $data = $request->all(); $vdtor = Validator::make($data, ['content' => 'required|min:15', 'file' => 'image|max:4096']); if ($vdtor->fails()) { return Redirect::to("/cat/{$cat_id}")->withErrors($vdtor); } $tmpCookie = $request->cookie('neupchan'); $data['cookie'] = $request->cookie('neupchan'); $cookieObj = ChCookie::where('cookie', $tmpCookie->cookie)->first(); $userObj = User::where('cookie_id', $cookieObj->id)->first(); $contentObj = new Contents(); $contentObj->content = nl2br($data['content']); $contentObj->po_id = $userObj->id; $uploadFile = $request->file('file'); if ($uploadFile) { if (!$uploadFile->isValid()) { return Redirect::to("/cat/{$cat_id}")->withErrors($uploadFile->getErrorMessage()); } var_dump($uploadFile); $fileName = $uploadFile->getRealPath() . $request->cookie('neupchan')->cookie . time(); $fileName = md5($fileName) . "." . $uploadFile->guessExtension(); echo $fileName; $contentObj->image = $fileName; Storage::put('images/' . $fileName, file_get_contents($uploadFile->getRealPath())); } $contentObj->save(); //var_dump($contentObj); Contents::find($contentObj->content_id)->update(['subject_id' => $contentObj->content_id]); $subjectObj = new Subjects(); $subjectObj->subject_id = $contentObj->id; $subjectObj->cat_id = $cat_id; $subjectObj->last_reply_time = time(); $subjectObj->po_id = $userObj->id; $subjectObj->save(); //var_dump($subjectObj); return Redirect::to("/cat/{$cat_id}")->with('post', 1); }