| 1 | <?php |
||
| 2 | |||
| 3 | namespace Furic\HouseAds\Http\Controllers; |
||
| 4 | |||
| 5 | use Furic\HouseAds\Models\HouseAd; |
||
| 6 | use App\Http\Controllers\Controller; |
||
|
0 ignored issues
–
show
|
|||
| 7 | use Illuminate\Http\Request; |
||
| 8 | use Validator; |
||
| 9 | |||
| 10 | class HouseAdController extends Controller |
||
| 11 | { |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Display a listing of the house ad resource. |
||
| 15 | * |
||
| 16 | * @return \Illuminate\Http\Response |
||
| 17 | */ |
||
| 18 | public function index() |
||
| 19 | { |
||
| 20 | return response(HouseAd::whereDate('start_at', '<=', date('Y-m-d'))->whereDate('end_at', '>=', date('Y-m-d'))->orderBy('priority', 'desc')->get(), 200); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Display the specified house ad resource. |
||
| 25 | * |
||
| 26 | * @param int $id |
||
| 27 | * @return \Illuminate\Http\Response |
||
| 28 | */ |
||
| 29 | public function show($id) |
||
| 30 | { |
||
| 31 | try { |
||
| 32 | return response(HouseAd::findOrFail($id), 200); |
||
| 33 | } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { |
||
| 34 | return response([ |
||
| 35 | 'error' => 'No house ad found.' |
||
| 36 | ], 400); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Update the specified house ad resource in storage. |
||
| 42 | * |
||
| 43 | * @param Request $request |
||
| 44 | * @param int $id |
||
| 45 | * @return \Illuminate\Http\Response |
||
| 46 | */ |
||
| 47 | public function update(Request $request, $id) |
||
| 48 | { |
||
| 49 | $validator = Validator::make($request->all(), [ |
||
| 50 | 'confirmed' => 'sometimes|required|numeric', |
||
| 51 | 'shown' => 'sometimes|required|numeric', |
||
| 52 | ]); |
||
| 53 | if ($validator->fails()) { |
||
| 54 | return response([ |
||
| 55 | 'error' => 'Key "confirmed" required.' |
||
| 56 | ], 400); |
||
| 57 | } |
||
| 58 | |||
| 59 | try { |
||
| 60 | $houseAd = HouseAd::findOrFail($id); |
||
| 61 | if ($request->has('confirmed')) { |
||
| 62 | if ($request->confirmed == '1') { |
||
| 63 | $houseAd->confirmed_count++; |
||
| 64 | } else { |
||
| 65 | $houseAd->cancelled_count++; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | if ($request->has('shown')) { |
||
| 69 | $houseAd->shown_count++; |
||
| 70 | } |
||
| 71 | $houseAd->save(); |
||
| 72 | return response($houseAd, 200); |
||
| 73 | } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { |
||
| 74 | return response([ |
||
| 75 | 'error' => 'No house ad found.' |
||
| 76 | ], 400); |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | } |
||
| 81 |
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