/** * undocumented function * * @return void * @author **/ public static function isExist($id) { $count = SocialAction::where('social_action_category_id', $id)->count(); if ($count > 0) { return true; } return false; }
/** * undocumented function * * @return void * @author **/ public static function isExist($id) { $count1 = SocialTarget::where('city_id', $id)->count(); $count2 = SocialAction::where('city_id', $id)->count(); $count3 = Events::where('city_id', $id)->count(); $count4 = User::where('city_id', $id)->count(); $count = $count1 + $count2 + $count3 + $count4; if ($count > 0) { return true; } return false; }
public function show($id) { // get social target $social_target = SocialTarget::with(array('city', 'category', 'user'))->find($id); if ($social_target == null) { return App::abort('404'); } // init $data = array('menu' => $this->_menu, 'title' => 'Target Sosial - ' . $social_target->name, 'description' => '', 'breadcrumb' => array('Kategori Target Sosial' => route('admin.social-target'), $social_target->name => route('admin.social-target.show', $social_target->id))); // Get Social Target $data['social_target'] = $social_target; // Get Social Actions that related with this $data['social_actions'] = SocialAction::with(array('city', 'category', 'user'))->where('social_target_id', '=', $social_target->id)->orderBy('id', 'desc')->get(); // Get Donations that related with this $data['donations'] = Donation::with(array('user'))->where('type_name', '=', 'social_targets')->where('type_id', '=', $social_target->id)->orderBy('id', 'desc')->get(); // Get Photos that related with this $data['photos'] = Photo::where('type_name', '=', 'social_targets')->where('type_id', '=', $social_target->id)->orderBy('id', 'desc')->get(); return View::make('admin.pages.social-target.show')->with($data); }
public function getSession($id) { // init $data = array(); $event = Events::where('id', $id)->first(); if ($event == false) { return App::abort('404'); } $data['view'] = $event; // // get photos $data['photos'] = Photo::where('type_name', '=', 'events')->where('type_id', '=', $event->id)->where('status', '=', 1)->get(); $data['social_actions'] = SocialAction::with(array('city', 'category'))->join('social_action_events', 'social_action_events.social_action_id', '=', 'social_actions.id')->where('event_id', '=', $event->id)->where('social_actions.status', '=', 1)->orderBy('social_actions.id', 'desc')->get(); $data['social_target_id'] = SocialTarget::getAll(); $data['social_action_category_id'] = SocialActionCategory::getAll(); $data['city_id'] = City::getAll(); Session::put('type_name', 'Events'); Session::forget('type_id'); Session::put('event_id', $event['id']); return Redirect::route('buat-aksi-sosial'); }
public function index() { // init $data = array('menu' => $this->_menu, 'title' => 'Dashboard', 'description' => '', 'breadcrumb' => array('Dashboard' => '/')); // New payment that need confirmation $data['payments'] = Payment::with(array('user', 'donations'))->where('status', '=', 0)->get(); // New social target that need confirmation $data['social_targets'] = SocialTarget::with(array('city', 'category', 'user'))->where('status', '=', 0)->get(); // New action action that need confirmation $data['social_actions'] = SocialAction::with(array('city', 'category', 'user'))->where('status', '=', 0)->get(); // New event that need confirmation $data['events'] = Events::with(array('city', 'category', 'user'))->where('status', '=', 0)->get(); // New report that need confirmation $reports = Report::with(array('user'))->where('have_responded', '=', 0)->get(); foreach ($reports as $report) { $report->setAppends(array('type')); } $data['reports'] = $reports; // return $data; return View::make('admin.pages.dashboard')->with($data); }
public function show($id) { // get social target $user = User::with('city')->find($id); if ($user == null) { return App::abort('404'); } // init $data = array('menu' => $this->_menu, 'title' => 'Nama pengguna - ' . $user->firstname . ' ' . $user->lastname, 'description' => '', 'breadcrumb' => array('Pengguna Bagikasih' => route('admin.user'), $user->firstname => route('admin.user.show', $user->id))); $data['users'] = $user; $social_target = SocialTarget::with(array('city', 'category', 'user'))->where('user_id', $user->id)->get(); // Get Social Target $data['social_target'] = $social_target; // Get Social Actions that related with this $data['social_actions'] = SocialAction::with(array('city', 'category', 'user'))->where('user_id', '=', $user->id)->orderBy('id', 'desc')->get(); // Get Donations that related with this $data['donations'] = Donation::with(array('user'))->where('type_name', '=', 'users')->where('type_id', '=', $user->id)->orderBy('id', 'desc')->get(); // Get Photos that related with this $data['photos'] = Photo::where('type_name', '=', 'users')->where('type_id', '=', $user->id)->orderBy('id', 'desc')->get(); return View::make('admin.pages.user.show')->with($data); }
public function getSession($id) { // init $data = array(); // get social target data - with slug $social_target = SocialTarget::with(array('city', 'category'))->where('id', '=', $id)->where('status', '=', 1)->first(); if ($social_target == null) { return App::abort('404'); } // get photos $photos = Photo::where('type_name', '=', 'social_targets')->where('type_id', '=', $social_target->id)->where('status', '=', 1)->get(); // get social actions $social_actions = SocialAction::with(array('city', 'category'))->where('social_target_id', '=', $social_target->id)->where('status', '=', 1)->orderBy('id', 'desc')->get(); // set data $data = array('social_target' => $social_target, 'photos' => $photos, 'social_actions' => $social_actions); $data['social_target_id'] = SocialTarget::getAll(); $data['social_action_category_id'] = SocialActionCategory::getAll(); $data['city_id'] = City::getAll(); Session::put('type_name', 'SocialTarget'); Session::put('type_id', $social_target->id); return Redirect::route('buat-aksi-sosial'); }
public function index() { // dd(Session::all()); $data = array(); $SocialAction = SocialAction::getSocialActionFront(); // 10 Data Aksi Sosial $SocialTarget = SocialTarget::getSocialTargetFront(); // 5 Data Target Sosial $data['service'] = array(); $i = 0; if ($SocialAction != false && $SocialTarget != false) { foreach ($SocialAction as $key) { $data['service'][$i] = $key; $data['service'][$i]['loop'] = 'Social Action'; $i++; } foreach ($SocialTarget as $key) { $data['service'][$i] = $key; $data['service'][$i]['loop'] = 'Social Target'; $i++; } } return View::make('bagikasih.home.index', $data); }
/** * undocumented function * * @return void * @author **/ public static function listId($type_name) { $data = []; switch ($type_name) { case 'social_targets': # code... $data = SocialTarget::lists('name', 'id'); break; case 'social_actions': # code... $data = SocialAction::lists('name', 'id'); break; case 'events': # code... $data = Events::lists('name', 'id'); break; default: $data = ['empty' => 'No Data']; break; } return $data; }
public static function UpdateSocialAction($input) { $rules = array('name' => 'required', 'description' => 'required|min:5', 'stewardship' => 'required|min:5', 'bank_account_description' => 'required|min:5', 'currency' => 'required', 'total_donation_target' => 'required', 'expired_at' => 'required'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return $validator->errors()->all(); } else { $id = $input['id']; unset($input['id']); if (!empty($input['expired_at'])) { $started_at = preg_split("/([\\/: ])/", $input['expired_at']); $input['expired_at'] = mktime((int) $started_at[3], (int) $started_at[4], 0, (int) $started_at[0], (int) $started_at[1], (int) $started_at[2]); } else { $input['expired_at'] = ''; } $getSlug = SocialAction::where('id', $id)->first(); $slug = Str::slug($input['name']); // jika input tidak sama dengan slug di database if (strcmp($input['name'], $getSlug['name']) != 0) { $checkSlug = SocialAction::where('slug', $slug)->where('id', '!=', $id)->count(); if ($checkSlug > 0) { $input['slug'] = $slug . "-" . $id; } else { $input['slug'] = $slug; } } $photo = Photo::updateAvatar($getSlug['cover_photo_id'], 'social_actions', $getSlug->id); $input['cover_photo_id'] = $photo['cover_photo_id']; $SocialAction = SocialAction::find($id); $SocialAction->fill($input); $SocialAction->save(); return "ok"; } }
public static function approve($id) { $payment = Payment::with(array('user', 'donations'))->find($id); if ($payment == null) { return array('success' => false, 'errors' => array('Pembayaran tidak ditemukan.')); } if ($payment->status != 0) { return array('success' => false, 'errors' => array('Pembayaran sudah pernah direspon oleh admin sebelumnya.')); } // approve $payment->status = 1; $payment->save(); // update donation Donation::where('payment_id', '=', $payment->id)->update(array('status' => 1)); // get all donations $donations = Donation::with(array('user'))->where('payment_id', '=', $payment->id)->get(); foreach ($donations as $donation) { // update donation $donation->status = 1; $donation->save(); // get social target / social action $donation->setAppends(array('type')); // update total donation in social target / social action if (isset($donation->type->social_action_category_id)) { $social_action = SocialAction::find($donation->type->id); $social_action->total_donation = $social_action->total_donation + $donation->total; $social_action->save(); } else { if (isset($donation->type->social_target_category_id)) { $social_target = SocialTarget::find($donation->type->id); $social_target->total_donation = $social_target->total_donation + $donation->total; $social_target->save(); } } // send email to social creator / social action creator Newsletter::addDonationNewsletter($donation); } // set type for each donation foreach ($payment->donations as $donation) { $donation->setAppends(array('type')); } // send email to donor Newsletter::addPaymentNewsletter($payment); return array('success' => true, 'data' => $payment); }
/** * undocumented function * * @return void * @author **/ public function deleteDo() { $id = Input::get('id'); $photo = Photo::remove($id); // Mengupdate semua fitur yang menggunakan foto menjadi 0 Events::where('default_photo_id', $id)->update(['default_photo_id' => 0]); Events::where('cover_photo_id', $id)->update(['cover_photo_id' => 0]); SocialAction::where('default_photo_id', $id)->update(['default_photo_id' => 0]); SocialAction::where('cover_photo_id', $id)->update(['cover_photo_id' => 0]); SocialTarget::where('default_photo_id', $id)->update(['default_photo_id' => 0]); SocialTarget::where('cover_photo_id', $id)->update(['cover_photo_id' => 0]); if ($photo) { $lokasi = public_path() . '/photos/'; if (unlink($lokasi . $id . '.jpg') && unlink($lokasi . 'thumb_' . $id . '.jpg')) { return Redirect::route('admin.photo')->withStatuses(['delete' => 'Hapus Sukses']); } return Redirect::route('admin.photo')->withErrors(['delete' => 'Delete File Gagal']); } return Redirect::route('admin.photo')->withErrors(['delete' => 'Delete File Gagal']); }
public function delete($id) { $SocialAction = SocialAction::find($id); $SocialAction->delete(); Session::flash('sukses', 'Data berhasil dihapus'); return Redirect::route('admin.social-action'); }
public function create() { $data['social_action'] = array(); $data['social_target'] = SocialTarget::all(); $data['social_action_category'] = SocialActionCategory::all(); $data['user'] = User::all(); $data['city'] = City::all(); $data['action'] = 'buat-aksi-sosial.post'; if (Request::isMethod('post')) { $input = Input::all(); $postSocialAction = SocialAction::StoreSocialActionFront($input); if ($postSocialAction != 'ok') { Session::flash('validasi', $postSocialAction); return Redirect::route('buat-aksi-sosial'); } else { Session::flash('sukses', 'Proses pendaftaran aksi sosial berhasil dilakukan. Data Anda telah masuk ke dalam database kami. Selanjutnya admin dari BagiKasih akan melakukan verifikasi data Anda. Terima kasih.'); return Redirect::route('temukan-aksi-sosial'); } } return View::make('bagikasih.social-action.create')->with($data); }