Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 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";
     }
 }
Ejemplo n.º 4
0
 /**
  * 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 update($id)
 {
     $data = array('menu' => 'Aksi Sosial', 'title' => 'Aksi Sosial', 'description' => '', 'breadcrumb' => array('Kategori Aksi Social' => route('admin.social-action')));
     if (!Session::has('time') && (!Session::has('validasi') && Session::get('validasi') != 'social_actions')) {
         $time = time();
         Session::put('time', $time);
     }
     $social_action = SocialAction::where('id', $id)->first();
     $data['action'] = 'admin.social-action.update.post';
     $data['social_action'] = $social_action;
     $data['social_target'] = SocialTarget::all();
     $data['social_action_category'] = SocialActionCategory::all();
     $data['user'] = User::all();
     $data['city'] = City::all();
     // 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.create')->with($data);
 }