/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $financing = Financing::find($id); if (!is_null($financing)) { if ($financing->delete()) { return Redirect::route('admin.financings.index')->withErrors(array('mainSuccess' => 'Финансирането е успешно изтрит.')); } else { return Redirect::route('admin.financings.index')->withErrors(array('mainError' => 'Грешка с базата данни.')); } } else { return Redirect::route('admin.financings.index')->withErrors(array('mainError' => 'Финансирането не е намерен.')); } }
public static function listFilters() { $filters_data['all'] = array(array('name' => 'Вид', 'list' => Type::select('id', 'name')->get()->toArray()), array('name' => 'Финансиране', 'list' => Financing::select('id', 'name')->get()->toArray()), array('name' => 'Специалности', 'list' => Specialty::select('id', 'name')->get()->toArray())); if (Input::has('district') == false && Input::has('municipality') == false && Input::has('city') == false) { $filters_data['all'][] = array('name' => 'Област', 'list' => District::select('id', 'name')->get()->toArray()); } if (Input::has('district') == true && Input::has('municipality') == false && Input::has('city') == false) { $district = Input::get('district'); if (is_array(Input::get('district'))) { $district = end($district); } $filters_data['all'][] = array('name' => 'Община', 'previous' => 'Област', 'list' => Municipality::select('id', 'name')->where('district_id', '=', $district)->get()->toArray()); $filters_data['previous_location'] = URL::route('schools.index', Input::except('district', 'municipality', 'city')); } if (Input::has('district') == true && Input::has('municipality') == true || Input::has('municipality') == true || Input::has('city') == true) { $municipality = Input::get('municipality'); if (is_array(Input::get('municipality'))) { $municipality = end($municipality); } $filters_data['all'][] = array('name' => 'Град/село', 'previous' => 'Община', 'list' => City::select('id', 'name')->where('municipality_id', '=', $municipality)->get()->toArray()); $filters_data['previous_location'] = URL::route('schools.index', Input::except('municipality', 'city')); } $input_filter = array_filter(Input::only('city', 'district', 'financing', 'municipality', 'specialty', 'type')); if (!empty($input_filter)) { $filters_data['clean_all_filters'] = URL::route('schools.index', array_filter(Input::only('search'))); } return $filters_data; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $school = School::find($id); if (is_null($school)) { return Redirect::route('admin.schools.index')->withErrors(array('mainError' => 'Учебното заведение не е намерено.')); } else { if ($school->canUserEdit() == false) { return Redirect::route('admin.schools.index')->withErrors(array('mainError' => 'Нямате право да редактирате учебното заведение.')); } $types_data = Type::lists("name", "id"); $financings_data = Financing::lists("name", "id"); $specialties_data = Specialty::lists("name", "id"); return View::make('admin.school.edit')->with('school', $school)->with('types_data', $types_data)->with('specialties_data', $specialties_data)->with('financings_data', $financings_data); } }