public function insert_posts($post_detail)
 {
     $Evebidpost = new Evebid();
     $date1 = $post_detail['post_time'];
     $date = str_replace('.', '-', $date1);
     $post_id = $Evebidpost->where('post_id', $post_detail['post_id'])->pluck('id');
     if (empty($post_detail)) {
         return false;
     }
     if (!empty($post_id)) {
         echo "<br>";
         $row = $Evebidpost->find($post_id);
         if ($row->lastpost_time == date('Y-m-d H:i:s', strtotime($date))) {
             echo "Already Updated";
             return true;
         }
         return;
     }
     $Evebidpost->threadid = $post_detail['threadid'];
     $Evebidpost->post_id = trim(strip_tags($post_detail['post_id']));
     $Evebidpost->bid_id = trim(strip_tags($post_detail['bid_id']));
     $Evebidpost->char_id = trim(strip_tags($post_detail['char_id']));
     $Evebidpost->post_rank = trim(strip_tags($post_detail['post_rank']));
     $Evebidpost->post_time = trim(strip_tags($post_detail['post_time']));
     $Evebidpost->profile_link = trim(strip_tags($post_detail['profile_link']));
     $Evebidpost->username = trim(strip_tags($post_detail['username']));
     $Evebidpost->wall_post = trim($post_detail['wall_post']);
     $Evebidpost->update_time = date('Y-m-d H:i:s');
     echo "<br>";
     echo "Inserted";
     $save_Eveapi = $Evebidpost->save();
     return $save_Eveapi;
 }
 function bidNow(Request $request)
 {
     if (!Auth::check()) {
         return Redirect::to('/login');
     }
     if ($request->isMethod('post')) {
         $rules = array('bid_am' => 'required|numeric', 'post_message' => 'required');
         $id = Auth::user()->id;
         $characters = Character::join('character_profile', function ($j) {
             $j->on('characters.char_id', '=', 'character_profile.char_id');
             //->where('bid_posts.post_rank',"=",1);
         })->where('characters.uid', "=", $id)->where('characters.status', '=', 1)->orderBy('characters.id', 'asc')->get()->take(1);
         foreach ($characters as $char) {
             $charname = $char['username'];
             $charid = $char['char_id'];
         }
         $post_message = trim($request->get('post_message'));
         $bid_am = trim($request->get('bid_am'));
         $bid_id = trim($request->get('bid_id'));
         $bid_post_detail = Evebid::where('bid_id', $bid_id)->orderBy('post_rank', 'desc')->take(1)->get();
         foreach ($bid_post_detail as $dt) {
             $post_rank = $dt['post_rank'];
         }
         $bid_detail = Eveapi::where('id', $bid_id)->first();
         if (!empty($bid_detail)) {
             $bid_detail->topicreplies = $bid_detail['topicreplies'] + 1;
             $bid_detail->save();
         }
         $post_thread = new Evebid();
         $post_thread->bid_id = $bid_id;
         $post_thread->char_id = $charid;
         $post_thread->post_rank = $post_rank + 1;
         $post_thread->post_time = Carbon::now();
         $post_thread->update_time = Carbon::now();
         $post_thread->wall_post = $post_message;
         $post_thread->profile_link = $charid . "_128.jpg";
         $post_thread->username = $charname;
         $post_thread->bid_amount = $bid_am;
         $post_thread->save();
         return Redirect::to('bazaar/' . $bid_id);
     }
 }