public function createPost() { if (Request::isMethod('post')) { $input = Input::all(); $postEvent = SocialTarget::StoreSocialTarget($input); if (array_key_exists('msg', $postEvent) && $postEvent['msg'] == 'ok') { // check if any mutliple upload photo $CountPhoto = Photo::where('tmp', Session::get('time'))->count(); if ($CountPhoto > 0) { Photo::updatePhotos('social_targets', $postEvent['id']); Photo::roolback(); // set default photo $setPhoto = Photo::where('user_id', Auth::user()->id)->where('type_name', 'social_targets')->where('type_id', $postEvent['id'])->first(); $setPhotoRow = array('default_photo_id' => $setPhoto->id); Events::where('id', $postEvent['id'])->update($setPhotoRow); } Session::flash('sukses', 'Target Sosial Berhasil di Rekap'); return Redirect::route('admin.social-target')->withInput(); } else { // get session validation Session::put('validasi', 'social_targets'); Session::flash('validasi', $postEvent); return Redirect::route('admin.social-target.create')->withInput(Input::except('social_target_category_id', 'user_id', 'city_id')); } } }