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