public function show($donation_code) { // init $data = array(); // get donation id $donation_id = Donation::getDonationId($donation_code); // get Donation data $donation = Donation::with(array('user'))->where('id', '=', $donation_id)->where('status', '!=', 3)->first(); if ($donation == null) { return App::abort('404'); } // get type $donation->setAppends(array('type')); // set data $data = array('donation' => $donation); return View::make('bagikasih.donation.detail', $data); }
public function show($id) { // get social target $social_action = SocialAction::with(array('city', 'category', 'user'))->where('id', '=', $id)->orderBy('id', 'desc')->first(); if ($social_action == null) { return App::abort('404'); } // init $data = array('menu' => $this->_menu, 'title' => 'Target Sosial - ' . $social_action->name, 'description' => '', 'breadcrumb' => array('Kategori Aksi Social' => route('admin.social-action'), $social_action->name => route('admin.social-action.show', $social_action->id))); // Get category $data['social_actions'] = $social_action; // Get Donations that related with this $data['donations'] = Donation::with(array('user'))->where('type_name', '=', 'social_actions')->where('type_id', '=', $social_action->id)->orderBy('id', 'desc')->get(); // Get Photos that related with this $data['photos'] = Photo::where('type_name', '=', 'social_actions')->where('type_id', '=', $social_action->id)->orderBy('id', 'desc')->get(); return View::make('admin.pages.social-action.show')->with($data); }
public function getSession($id) { $data = array(); $social_actions = SocialAction::with('socialTarget', 'user')->where('id', $id)->first(); if ($social_actions == false) { return App::abort('404'); } $photos = Photo::where('type_name', '=', 'social_actions')->where('type_id', '=', $social_actions->id)->where('status', '=', 1)->get(); $donations = Donation::with(array('user'))->where('type_name', '=', 'social_actions')->where('type_id', '=', $social_actions->id)->where('status', '=', 1)->orderBy('id', 'desc')->get(); $user = User::getUserId($social_actions->user_id); $social_target_id = SocialTarget::getAll(); $social_action_category_id = SocialActionCategory::getAll(); $city_id = City::getAll(); $data = array('social_action' => $social_actions, 'photos' => $photos, 'donations' => $donations, 'user' => $user, 'social_target_id' => $social_target_id, 'social_action_category_id' => $social_action_category_id, 'city_id' => $city_id); Session::put('type_name', 'SocialAction'); Session::put('type_id', $social_actions->social_target_id); return Redirect::route('buat-aksi-sosial'); }
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 show($id) { // get donation $donation = Donation::with(array('user'))->find($id); if ($donation == null) { return App::abort('404'); } // init $data = array('menu' => $this->_menu, 'title' => 'Donasi & Pembayaran - ' . $donation->id, 'description' => '', 'breadcrumb' => array('Donasi & Pembayaran' => route('admin.donation'), $donation->id => route('admin.donation.show', $donation->id))); // Get Donation $donation->setAppends(array('type')); $data['donation'] = $donation; // Get Payment that related with this if ($donation->payment_id != NULL) { $payment = Payment::with(array('user', 'donations'))->find($donation->payment_id); foreach ($payment->donations as $i => $donation) { $donation->setAppends(array('type')); } $data['payment'] = $payment; } return View::make('admin.pages.donation.show')->with($data); }
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); }