action_takeaway('new-new'); } public function action_takeaway($url) { // Include the AreYouAHoman library require_once path('app').'libraries/ayah.php'; $ayah = new AYAH(); // Get the ID from the URL and the takeaway object $segments = explode('-', $url); $id = end($segments); if ($id != 'new') { $takeaway = Takeaway::find($id); // 404 if it doesnt exist if (!$takeaway) return Response::error(404); if ($takeaway->status == 'Claimed') { if ($takeaway->allow_public_edit == 0 && !Auth::check() || Auth::user()->id != $takeaway->user_id) { return View::make('edit.locked')->with(array('takeaway' => $takeaway)); } } } else { $takeaway = new Takeaway(); } $errors = array(); $notices = array(); $successes = array(); if (Request::method() == 'POST') { // Check the captcha if (!Auth::check() && !$ayah->scoreResult()) { $errors[] = 'Sorry, you must complete the Are You A Human game to prove your not a spammy robot.'; } else { // Make a copy that we can go back to, if it isn't a new takeaway if ($takeaway->exists) $takeaway->save_revision(); $takeaway->takeaway = Input::get('is_takeaway') ? 1 : 0; $takeaway->takeout = Input::get('is_takeout') ? 1 : 0; $takeaway->restaurant = Input::get('is_restaurant') ? 1 : 0; $takeaway->coffee = Input::get('is_coffee') ? 1 : 0; $takeaway->name = strip_tags(Input::get('name')); $takeaway->urlname = Str::slug(strip_tags(Input::get('name'))); $takeaway->description = strip_tags(Input::get('description')); $takeaway->address1 = strip_tags(Input::get('address1')); $takeaway->address2 = strip_tags(Input::get('address2')); $takeaway->postcode = strip_tags(Input::get('postcode', Input::get('zip_code'))); // Only update delivery and hours if they weren't the defaults if (Input::get('delivery') != 'No delivery information available.') $takeaway->delivery = strip_tags(Input::get('delivery', '')); if (Input::get('opening_hours') != 'No opening hours available.') $takeaway->opening_hours = strip_tags(Input::get('opening_hours', '')); if ($takeaway->save()) { $successes[] = 'Your changes have been saved.'; } else { $errors[] = 'There was an error saving your changes.'; } $new_town = Town::find(Input::get('town')); if ($new_town) { $takeaway->town_name = $new_town->name; $takeaway->Towns()->delete(); $takeaway->Towns()->attach($new_town->id); } else { $errors[] = "The town was not found."; } // Loop through each submitted number $submitted_numbers = Input::get('phone_numbers'); if (is_array($submitted_numbers)) { $submitted_cleaned = array(); foreach ($submitted_numbers as $sn) { // Don't bother if its an empty string or something if (!$sn || strlen($sn) < 5) continue; $csn = PhoneNumber::clean($sn); // See if the number exists already $number = PhoneNumber::where('number', '=', $csn)->first(); if (!$number) { // Not found, add new nuber $number = new PhoneNumber(); $number->number = $csn; $takeaway->PhoneNumbers()->insert($number); } else if ($number->takeaway_id != $takeaway->id) { $notices[] = "The phone number '{$csn}' is in use by a different ".CONTENT_NAME.", please check you aren't adding a duplicate."; } else if ($number) { $number->deleted = 0; $number->save(); } // Cleaned array for deleting... $submitted_cleaned[] = $csn; } // Remove any numbers that have been removed $numbers = $takeaway->PhoneNumbers(); if (count($submitted_cleaned) > 0) $numbers->where_not_in('number', $submitted_cleaned); $numbers->update(array('deleted' => 1)); } // Same again for URLs $submitted_urls = Input::get('urls'); if (is_array($submitted_urls)) { foreach ($submitted_urls as $su) { // Dont bother with empty or short ones if (!$su || strlen($su) < 5) continue; // Try not to add duplicate URLs (same URL for different takes is OK) $url = TakeawayUrl::where('url', '=', $su)->where('takeaway_id', '=', $takeaway->id)->first(); if ($url) { $url->deleted = 0; $url->save(); } else { $url = new TakeawayUrl(); $url->url = $su; $url->title = $su; $takeaway->Urls()->insert($url); } } $urls = $takeaway->Urls(); if (count($submitted_urls) > 0) $urls->where_not_in('url', $submitted_urls); $urls->update(array('deleted' => 1)); } $category_ids = json_decode(Input::get('category_ids')); $takeaway->Categories()->delete(); if (is_array($category_ids) && count($category_ids) > 0) { $new_categories = Category::where_in('id', $category_ids)->get(); foreach ($new_categories as $nc) $takeaway->Categories()->attach($nc->id); } else { $takeaway->Categories()->attach(4); } $takeaway->action('edit'); if ($takeaway->user_id && $takeaway->email_edit == 1) { $user = User::find($takeaway->user_id); if ($user) $user->email('edit', array('takeaway' => $takeaway)); } $takeaway->geocode(); $takeaway->flush_cache(true); } // If not spam } // Include some related stuff $town = $takeaway->Towns()->first(); $categories = $takeaway->categories()->get(); $in_categories = array(); foreach ($categories as $cat) $in_categories[] = $cat->id; // Make sure all these are defined, the needed ones will be replaced $towns = false; $counties = false; $regions = false; $country_id = false; $region_id = false; $county_id = false; $town_id = false; $state_id = false; $states = false; if ($town) { $towns = Town::where('county_id', '=', $town->county_id)->order_by('name', 'asc')->get(); $town_id = $town->id; $county_id = $town->county_id; $county = County::find($town->county_id); if ($county->region_id) { // UK, regions $counties = County::where('region_id', '=', $county->region_id)->order_by('name', 'asc')->get(); $region_id = $county->region_id; // Loop just once, to get the first one foreach ($counties as $county) { $regions = Region::where('country_id', '=', $county->country_id)->order_by('name', 'asc')->get(); $country_id = $county->country_id; break; } } else if ($county->state_id) { // US, states $counties = County::where('state_id', '=', $county->state_id)->order_by('name', 'asc')->get(); $state_id = $county->state_id; } } if (COUNTRY == 'US') { $states = State::order_by('name', 'asc')->get(); } // Pass stuff to the view and return it return View::make('edit.takeaway')->with(array( 'takeaway' => $takeaway, 'in_categories' => $in_categories, 'all_categories' => Category::order_by('name', 'asc')->get(), 'phone_numbers' => $takeaway->Phonenumbers()->where('deleted', '!=', 1)->get(), 'urls' => $takeaway->Urls()->where('deleted', '!=', 1)->get(), 'town' => isset($new_town) ? $new_town : $town, 'states' => $states, 'state_id' => $state_id, 'regions' => $regions, 'counties' => $counties, 'towns' => $towns, 'country_id' => $country_id, 'region_id' => $region_id, 'county_id' => $county_id, 'town_id' => $town_id, 'errors' => $errors, 'notices' => $notices, 'successes' => $successes, 'ayah' => $ayah->getPublisherHTML() )); } public function action_revisions($url) { // Get the ID from the URL and the takeaway object $segments = explode('-', $url); $id = end($segments); $takeaway = Takeaway::find($id); // 404 if it doesnt exist if (!$takeaway) return Response::error(404); $town = $takeaway->Towns()->first(); $errors = array(); $notices = array(); $successes = array(); $revisions = $takeaway->Revisions()->order_by('created_at', 'desc')->get(); return View::make('edit.revisions')->with(array( 'takeaway' => $takeaway, 'revisions' => $revisions, 'town' => $town, 'errors' => $errors, 'notices' => $notices, 'successes' => $successes )); } public function action_revert_to_revision() { $takeaway_id = Input::get('takeaway_id'); $revision_id = Input::get('revision_id'); $takeaway = Takeaway::find($takeaway_id); if (!$takeaway) return Response::error(404); $revision = Revision::find($revision_id); if (!$revision) return Response::error(404); if ($revision->takeaway_id !== $takeaway->id) return Response::error(404); if ($takeaway->revert_to_revision($revision)) { $takeaway->action('revision'); $takeaway->flush_cache(true); return Response::make('success'); } else { return Response::make('error'); } } public function action_menu($url) { // Get the ID from the URL and the takeaway object $segments = explode('-', $url); $id = end($segments); $takeaway = Takeaway::find($id); // 404 if it doesnt exist if (!$takeaway) return Response::error(404); $town = $takeaway->Towns()->first(); // Get menu categories, leave the dishes for the view, naughty $menu_categories = $takeaway->MenuCategories()->order_by('id', 'asc')->get(); return View::make('edit.menu')->with(array( 'takeaway' => $takeaway, 'town' => $town, 'menu_categories' => $menu_categories )); } public function action_delete($url) { // Get the ID from the URL and the takeaway object $segments = explode('-', $url); $id = end($segments); $takeaway = Takeaway::find($id); // 404 if it doesnt exist if (!$takeaway) return Response::error(404); $errors = array(); $notices = array(); $successes = array(); $town = $takeaway->Towns()->first(); if (Request::method() == 'POST') { // If the email address hidden field has been filled out, deny as spam if (Input::get('email_address') !== '') Response::error('403'); if (in_array(Input::get('reason'), array('active', 'duplicate', 'closed', 'wrong_number', 'rubbish'))) { $takeaway->status = Input::get('reason'); $takeaway->save(); $successes[] = 'Your change has been saved.'; } else if (Input::get('reason') == 'none') { $errors[] = 'Please select a reason.'; } $takeaway->action('delete'); $takeaway->flush_cache(true); } return View::make('edit.delete')->with(array( 'takeaway' => $takeaway, 'town' => $town, 'errors' => $errors, 'notices' => $notices, 'successes' => $successes )); } /* ajax methods */ public function action_regions($id) { $regions = Region::where('country_id', '=', $id)->order_by('name', 'asc')->get(); $html = ''; foreach ($regions as $region) { $html .= ''; } return $html; } public function action_counties($regionId = false, $stateId = false) { if (is_numeric($regionId)) { $counties = County::where('region_id', '=', $regionId)->order_by('name', 'asc')->get(); } else if ($stateId) { $counties = County::where('state_id', '=', $stateId)->order_by('name', 'asc')->get(); } else { $counties = (object)array('id' => null, 'name' => 'Error'); } $html = ''; foreach ($counties as $county) { $html .= ''; } return $html; } public function action_towns($id) { $towns = Town::where('county_id', '=', $id)->order_by('name', 'asc')->get(); $html = ''; foreach ($towns as $town) { $html .= ''; } return $html; } /* Menu methods */ public function action_save_dish( $takeaway_id = false, $dish_id = false ) { $takeaway = Takeaway::find($takeaway_id); if (!$takeaway) return json_encode(array('error' => 'Takeaway not found')); $category = false; if ($category_id = Input::get('category_id')) { $category = MenuCategory::find($category_id); if (!$category || $category->takeaway_id != $takeaway->id) { return json_encode(array('error' => 'Specified category is not related to takeaway.')); } } $dish = new Dish(); if ($dish_id) { $dish = Dish::find($dish_id); if (!$dish || $dish->takeaway_id != $takeaway->id) { return json_encode(array('error' => 'Specified dish is not related to takeaway.')); } } $dish->name = Input::get('name', ''); $dish->description = Input::get('description', ''); $dish->price_1 = Input::get('price_1', ''); $dish->price_2 = Input::get('price_2', ''); $dish->price_3 = Input::get('price_3', ''); $dish->price_4 = Input::get('price_4', ''); $dish->price_5 = Input::get('price_5', ''); if ($category) $dish->menu_category_id = $category->id; $dish->takeaway_id = $takeaway->id; if ($dish->save()) { $takeaway->check_has_menu(); $takeaway->save(); $return = array( 'id' => $dish->id, 'name' => htmlspecialchars($dish->name), 'price_1' => $dish->price_1, 'price_2' => $dish->price_2, 'price_3' => $dish->price_3, 'price_4' => $dish->price_4, 'price_5' => $dish->price_5, 'description' => $dish->description ); $takeaway->flush_cache(true); $takeaway->action('menu'); return json_encode($return); } else { return json_encode(array('error' => 'Error saving dish.')); } } public function action_save_category( $takeaway_id = false, $category_id = false ) { $takeaway = Takeaway::find($takeaway_id); if (!$takeaway) { return json_encode(array('error' => 'Takeaway not found')); } $category = new MenuCategory(); if ($category_id) { $category = MenuCategory::find($category_id); if ($category->takeaway_id != $takeaway->id) { return json_encode(array('error' => 'Specified category is not related to takeaway.')); } } $category->name = Input::get('name', ''); $category->description = Input::get('description', ''); $category->price_name_1 = Input::get('price_name_1', ''); $category->price_name_2 = Input::get('price_name_2', ''); $category->price_name_3 = Input::get('price_name_3', ''); $category->price_name_4 = Input::get('price_name_4', ''); $category->price_name_5 = Input::get('price_name_5', ''); $category->takeaway_id = $takeaway->id; $category->save(); $return = array( 'id' => $category->id, 'name' => htmlspecialchars($category->name), 'price_name_1' => htmlspecialchars($category->price_name_1), 'price_name_2' => htmlspecialchars($category->price_name_2), 'price_name_3' => htmlspecialchars($category->price_name_3), 'price_name_4' => htmlspecialchars($category->price_name_4), 'price_name_5' => htmlspecialchars($category->price_name_5), 'description' => htmlspecialchars($category->description) ); $takeaway->flush_cache(true); $takeaway->action('menu'); return json_encode($return); } public function action_delete_dish( $takeaway_id = false, $dish_id = false ) { $takeaway = Takeaway::find($takeaway_id); if (!$takeaway) { return json_encode(array('error' => 'Takeaway not found')); } $dish = new Dish(); if ($dish_id) { $dish = Dish::find($dish_id); if ($dish->takeaway_id != $takeaway->id) { return json_encode(array('error' => 'Specified dish is not related to takeaway.')); } } $dish->delete(); $takeaway->check_has_menu(); $takeaway->save(); $takeaway->flush_cache(true); $takeaway->action('menu'); return json_encode(array('status' => 'success', 'takeaway_id' => $takeaway_id, 'dish_id' => $dish_id)); } public function action_delete_category( $takeaway_id = false, $category_id = false ) { $takeaway = Takeaway::find($takeaway_id); if (!$takeaway) { return json_encode(array('error' => 'Takeaway not found')); } $category = new MenuCategory(); if ($category_id) { $category = MenuCategory::find($category_id); if ($category->takeaway_id != $takeaway->id) { return json_encode(array('error' => 'Specified category is not related to takeaway.')); } } if (Dish::where('menu_category_id', '=', $category->id)->count() > 0) { return json_encode(array('error' => 'Pleaes remove all dishes from the category before deleting it.')); } $category->delete(); $takeaway->flush_cache(true); $takeaway->action('menu'); return json_encode(array('id' => $category_id, 'status' => 'success')); } }

Unhandled Exception

Message:

Class 'Edit_Controller' not found

Location:

/home/forge/takeaway-finder.co.uk/laravel/routing/controller.php on line 226

Stack Trace:

#0 /home/forge/takeaway-finder.co.uk/laravel/routing/controller.php(145): Laravel\Routing\Controller::resolve('application', 'Edit_Controller')
#1 /home/forge/takeaway-finder.co.uk/laravel/routing/route.php(153): Laravel\Routing\Controller::call('edit@new', Array)
#2 /home/forge/takeaway-finder.co.uk/laravel/routing/route.php(124): Laravel\Routing\Route->response()
#3 /home/forge/takeaway-finder.co.uk/laravel/laravel.php(125): Laravel\Routing\Route->call()
#4 /home/forge/takeaway-finder.co.uk/public_html/index.php(34): require('/home/forge/tak...')
#5 {main}