public function giveCookie(Request $request, $cookieID)
 {
     $cookieObj = ChCookie::find($cookieID);
     $infoArr = ["cookie_id" => $cookieObj->id, "first_login_ip" => $request->ip(), "last_login_ip" => $request->ip(), "ban_level" => 0, "admin_flag" => 0];
     User::create($infoArr);
     $cookieObj->state = 1;
     $cookieObj->save();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $charTblStr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
     $charTbl = [];
     for ($i = 0; $i < 10; $i++) {
         for ($len = 0; $len < strlen($charTblStr); $len++) {
             array_push($charTbl, $charTblStr[$len]);
         }
         $shortCookie = "";
         for ($j = 0; $j < 8; $j++) {
             shuffle($charTbl);
             $shortCookie = $shortCookie . $charTbl[0];
         }
         var_dump($shortCookie);
         $longCookie = md5($shortCookie . time());
         var_dump($longCookie);
         ChCookie::create(["cookie" => $longCookie, "short_cookie" => $shortCookie, "state" => 0]);
     }
     echo "Seeded 10 more cookies into the database\n";
     Model::reguard();
 }
 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);
 }