pwweb /
localisation
| 1 | <?php |
||
| 2 | |||
| 3 | namespace PWWEB\Localisation\Controllers; |
||
| 4 | |||
| 5 | use App\Http\Controllers\Controller; |
||
| 6 | use Flash; |
||
|
0 ignored issues
–
show
|
|||
| 7 | use Illuminate\Http\Request; |
||
| 8 | use PWWEB\Localisation\Repositories\CountryRepository; |
||
| 9 | use PWWEB\Localisation\Requests\CreateCountryRequest; |
||
| 10 | use PWWEB\Localisation\Requests\UpdateCountryRequest; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * PWWEB\Localisation\Controllers\CountryController CountryController. |
||
| 14 | * |
||
| 15 | * The CRUD controller for Country |
||
| 16 | * Class CountryController |
||
| 17 | * |
||
| 18 | * @author Frank Pillukeit <[email protected]> |
||
| 19 | * @author Richard Browne <[email protected] |
||
| 20 | * @copyright 2020 pw-websolutions.com |
||
| 21 | * @license http://www.opensource.org/licenses/mit-license.html MIT License |
||
| 22 | */ |
||
| 23 | class CountryController extends Controller |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * Repository of Countries to be used throughout the controller. |
||
| 27 | * |
||
| 28 | * @var CountryRepository |
||
| 29 | */ |
||
| 30 | private $countryRepository; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Constructor for the Country controller. |
||
| 34 | * |
||
| 35 | * @param CountryRepository $countryRepo Repository of Countries. |
||
| 36 | */ |
||
| 37 | public function __construct(CountryRepository $countryRepo) |
||
| 38 | { |
||
| 39 | $this->countryRepository = $countryRepo; |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Display a listing of Countries. |
||
| 44 | * |
||
| 45 | * @param Request $request Request containing the information for filtering. |
||
| 46 | * |
||
| 47 | * @return \Illuminate\View\View |
||
| 48 | */ |
||
| 49 | public function index(Request $request) |
||
| 50 | { |
||
| 51 | $countries = $this->countryRepository->all(); |
||
| 52 | |||
| 53 | return view('localisation::countries.index') |
||
| 54 | ->with('countries', $countries); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Show the form for creating a new Country. |
||
| 59 | * |
||
| 60 | * @return \Illuminate\View\View |
||
| 61 | */ |
||
| 62 | public function create() |
||
| 63 | { |
||
| 64 | return view('localisation::countries.create'); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Store a newly created Country in storage. |
||
| 69 | * |
||
| 70 | * @param CreateCountryRequest $request Request containing the information to be stored. |
||
| 71 | * |
||
| 72 | * @return \Illuminate\Http\RedirectResponse |
||
| 73 | */ |
||
| 74 | public function store(CreateCountryRequest $request) |
||
| 75 | { |
||
| 76 | $input = $request->all(); |
||
| 77 | |||
| 78 | $country = $this->countryRepository->create($input); |
||
|
0 ignored issues
–
show
|
|||
| 79 | |||
| 80 | Flash::success('Country saved successfully.'); |
||
| 81 | |||
| 82 | return redirect(route('localisation.countries.index')); |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Display the specified Country. |
||
| 87 | * |
||
| 88 | * @param int $id ID of the Country to be displayed. Used for retrieving currently held data. |
||
| 89 | * |
||
| 90 | * @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse |
||
| 91 | */ |
||
| 92 | public function show($id) |
||
| 93 | { |
||
| 94 | $country = $this->countryRepository->find($id); |
||
| 95 | |||
| 96 | if (true === empty($country)) { |
||
| 97 | Flash::error('Country not found'); |
||
| 98 | |||
| 99 | return redirect(route('localisation.countries.index')); |
||
| 100 | } |
||
| 101 | |||
| 102 | return view('localisation::countries.show')->with('country', $country); |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Show the form for editing the specified Country. |
||
| 107 | * |
||
| 108 | * @param int $id ID of the Country to be edited. Used for retrieving currently held data. |
||
| 109 | * |
||
| 110 | * @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse |
||
| 111 | */ |
||
| 112 | public function edit($id) |
||
| 113 | { |
||
| 114 | $country = $this->countryRepository->find($id); |
||
| 115 | |||
| 116 | if (true === empty($country)) { |
||
| 117 | Flash::error('Country not found'); |
||
| 118 | |||
| 119 | return redirect(route('localisation.countries.index')); |
||
| 120 | } |
||
| 121 | |||
| 122 | return view('localisation::countries.edit')->with('country', $country); |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Update the specified Country in storage. |
||
| 127 | * |
||
| 128 | * @param int $id ID of the Country to be updated. |
||
| 129 | * @param UpdateCountryRequest $request Request containing the information to be updated. |
||
| 130 | * |
||
| 131 | * @return \Illuminate\Http\RedirectResponse |
||
| 132 | */ |
||
| 133 | public function update($id, UpdateCountryRequest $request) |
||
| 134 | { |
||
| 135 | $country = $this->countryRepository->find($id); |
||
| 136 | |||
| 137 | if (true === empty($country)) { |
||
| 138 | Flash::error('Country not found'); |
||
| 139 | |||
| 140 | return redirect(route('localisation.countries.index')); |
||
| 141 | } |
||
| 142 | |||
| 143 | $country = $this->countryRepository->update($request->all(), $id); |
||
|
0 ignored issues
–
show
|
|||
| 144 | |||
| 145 | Flash::success('Country updated successfully.'); |
||
| 146 | |||
| 147 | return redirect(route('localisation.countries.index')); |
||
| 148 | } |
||
| 149 | |||
| 150 | /** |
||
| 151 | * Remove the specified Country from storage. |
||
| 152 | * |
||
| 153 | * @param int $id ID of the Country to be destroyed. |
||
| 154 | * |
||
| 155 | * @throws \Exception |
||
| 156 | * |
||
| 157 | * @return \Illuminate\Http\RedirectResponse |
||
| 158 | */ |
||
| 159 | public function destroy($id) |
||
| 160 | { |
||
| 161 | $country = $this->countryRepository->find($id); |
||
| 162 | |||
| 163 | if (true === empty($country)) { |
||
| 164 | Flash::error('Country not found'); |
||
| 165 | |||
| 166 | return redirect(route('localisation.countries.index')); |
||
| 167 | } |
||
| 168 | |||
| 169 | $this->countryRepository->delete($id); |
||
| 170 | |||
| 171 | Flash::success('Country deleted successfully.'); |
||
| 172 | |||
| 173 | return redirect(route('localisation.countries.index')); |
||
| 174 | } |
||
| 175 | } |
||
| 176 |
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