| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 25 | public function index(Request $request) |
||
| 26 | { |
||
| 27 | $cacheExpireTime = 900; // expressed in seconds (15 min) |
||
| 28 | |||
| 29 | $backgroundImages = BackgroundImage::all(); |
||
| 30 | |||
| 31 | $eventCategories = Cache::remember('categories', $cacheExpireTime, function () { |
||
| 32 | return EventCategory::orderBy('name')->pluck('name', 'id'); |
||
| 33 | }); |
||
| 34 | |||
| 35 | // Get the countries with active events |
||
| 36 | $activeEvents = Event::getActiveEvents(); |
||
| 37 | $countries = $activeEvents->unique('country_name')->sortBy('country_name')->pluck('country_name', 'country_id'); |
||
| 38 | //$cities = $activeEvents->unique('city')->toArray(); |
||
| 39 | $activeContinentsCountries = ContinentResource::collection(Continent::all()); |
||
| 40 | |||
| 41 | $continents = Cache::rememberForever('continents', function () { |
||
| 42 | return Continent::orderBy('name')->pluck('name', 'id'); |
||
| 43 | }); |
||
| 44 | |||
| 45 | $venues = Cache::remember('venues', $cacheExpireTime, function () { |
||
| 46 | return EventVenue::pluck('name', 'id'); |
||
| 47 | }); |
||
| 48 | |||
| 49 | $teachers = Cache::remember('teachers', $cacheExpireTime, function () { |
||
| 50 | return Teacher::orderBy('name')->pluck('name', 'id'); |
||
| 51 | }); |
||
| 52 | |||
| 53 | $filters = []; |
||
| 54 | $filters['keywords'] = $request->input('keywords'); |
||
| 55 | $filters['category'] = $request->input('category_id'); |
||
| 56 | $filters['country'] = $request->input('country_id'); |
||
| 57 | $filters['city'] = $request->input('city_name'); |
||
| 58 | $filters['continent'] = $request->input('continent_id'); |
||
| 59 | $filters['teacher'] = $request->input('teacher_id'); |
||
| 60 | $filters['venue'] = $request->input('venue_name'); |
||
| 61 | $filters['startDate'] = Event::prepareStartDate($request->input('startDate')); |
||
| 62 | $filters['endDate'] = Event::prepareEndDate($request->input('endDate')); |
||
| 63 | |||
| 64 | $events = Event::getEvents($filters, 20); |
||
| 65 | |||
| 66 | return view('eventSearch.index', compact('events')) |
||
| 67 | ->with('i', (request()->input('page', 1) - 1) * 20) |
||
| 68 | ->with('eventCategories', $eventCategories) |
||
| 69 | ->with('continents', $continents) |
||
| 70 | ->with('countries', $countries) |
||
| 71 | ->with('venues', $venues) |
||
| 72 | ->with('teachers', $teachers) |
||
| 73 | ->with('searchKeywords', $filters['keywords']) |
||
| 74 | ->with('searchCategory', $filters['category']) |
||
| 75 | ->with('searchCountry', $filters['country']) |
||
| 76 | ->with('searchContinent', $filters['continent']) |
||
| 77 | ->with('searchCity', $filters['city']) |
||
| 78 | ->with('searchTeacher', $filters['teacher']) |
||
| 79 | ->with('searchVenue', $filters['venue']) |
||
| 80 | ->with('searchStartDate', $request->input('startDate')) |
||
| 81 | ->with('searchEndDate', $request->input('endDate')) |
||
| 82 | ->with('backgroundImages', $backgroundImages) |
||
| 83 | ->with('activeContinentsCountries', $activeContinentsCountries); |
||
| 84 | } |
||
| 130 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths