/** * undocumented function * * @return void * @author **/ public static function isExist($id) { $count = SocialTarget::where('social_target_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 delete($id) { $SocialAction = SocialTarget::where('id', $id); $SocialAction->delete(); Session::flash('sukses', 'Data berhasil dihapus'); return Redirect::route('admin.social-target'); }
public static function UpdateSocialTarget($input) { $id = $input['id']; $rules = array('name' => 'required', 'stewardship' => 'required|min:5', 'description' => 'required|min:5', 'address' => 'required', 'phone_number' => 'required'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return $validator->errors()->all(); } else { $getSlug = SocialTarget::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 = SocialTarget::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_targets', $getSlug->id); $input['cover_photo_id'] = $photo['cover_photo_id']; $SocialTarget = SocialTarget::find($id); $SocialTarget->fill($input); $SocialTarget->save(); return "ok"; } }
/** * 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']); }