bantenprov /
dashboard-apel
| 1 | <?php namespace Bantenprov\DashboardApel\Http\Controllers; |
||
| 2 | |||
| 3 | /* require */ |
||
| 4 | use App\Http\Controllers\Controller; |
||
|
0 ignored issues
–
show
|
|||
| 5 | use Illuminate\Http\Request; |
||
| 6 | use Bantenprov\DashboardApel\Facades\DashboardApel; |
||
| 7 | |||
| 8 | /* Models */ |
||
| 9 | use Bantenprov\DashboardApel\Models\Bantenprov\DashboardApel\DashboardApel as PdrbModel; |
||
| 10 | use Bantenprov\DashboardApel\Models\Bantenprov\DashboardApel\Province; |
||
| 11 | use Bantenprov\DashboardApel\Models\Bantenprov\DashboardApel\Regency; |
||
| 12 | |||
| 13 | /* etc */ |
||
| 14 | use Validator; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * The DashboardApelController class. |
||
| 18 | * |
||
| 19 | * @package Bantenprov\DashboardApel |
||
| 20 | * @author bantenprov <[email protected]> |
||
| 21 | */ |
||
| 22 | class DashboardApelController extends Controller |
||
| 23 | { |
||
| 24 | |||
| 25 | protected $province; |
||
| 26 | |||
| 27 | protected $regency; |
||
| 28 | |||
| 29 | protected $dashboard_apel; |
||
| 30 | |||
| 31 | public function __construct(Regency $regency, Province $province, PdrbModel $dashboard_apel) |
||
| 32 | { |
||
| 33 | $this->regency = $regency; |
||
| 34 | $this->province = $province; |
||
| 35 | $this->dashboard_apel = $dashboard_apel; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function index(Request $request) |
||
| 39 | { |
||
| 40 | /* todo : return json */ |
||
| 41 | |||
| 42 | return 'index'; |
||
| 43 | |||
| 44 | } |
||
| 45 | |||
| 46 | public function create() |
||
| 47 | { |
||
| 48 | |||
| 49 | return response()->json([ |
||
| 50 | 'provinces' => $this->province->all(), |
||
| 51 | 'regencies' => $this->regency->all() |
||
| 52 | ]); |
||
| 53 | } |
||
| 54 | |||
| 55 | public function show($id) |
||
| 56 | { |
||
| 57 | |||
| 58 | $dashboard_apel = $this->dashboard_apel->find($id); |
||
| 59 | |||
| 60 | return response()->json([ |
||
| 61 | 'negara' => $dashboard_apel->negara, |
||
| 62 | 'province' => $dashboard_apel->getProvince->name, |
||
| 63 | 'regencies' => $dashboard_apel->getRegency->name, |
||
| 64 | 'tahun' => $dashboard_apel->tahun, |
||
| 65 | 'data' => $dashboard_apel->data |
||
| 66 | ]); |
||
| 67 | } |
||
| 68 | |||
| 69 | public function store(Request $request) |
||
| 70 | { |
||
| 71 | |||
| 72 | $validator = Validator::make($request->all(),[ |
||
| 73 | 'negara' => 'required', |
||
| 74 | 'province_id' => 'required', |
||
| 75 | 'regency_id' => 'required', |
||
| 76 | 'kab_kota' => 'required', |
||
| 77 | 'tahun' => 'required|integer', |
||
| 78 | 'data' => 'required|integer', |
||
| 79 | ]); |
||
| 80 | |||
| 81 | if($validator->fails()) |
||
| 82 | { |
||
| 83 | return response()->json([ |
||
| 84 | 'title' => 'error', |
||
| 85 | 'message' => 'add failed', |
||
| 86 | 'type' => 'failed', |
||
| 87 | 'errors' => $validator->errors() |
||
| 88 | ]); |
||
| 89 | } |
||
| 90 | |||
| 91 | $check = $this->dashboard_apel->where('regency_id',$request->regency_id)->where('tahun',$request->tahun)->count(); |
||
| 92 | |||
| 93 | if($check > 0) |
||
| 94 | { |
||
| 95 | return response()->json([ |
||
| 96 | 'title' => 'error', |
||
| 97 | 'message' => 'Data allready exist', |
||
| 98 | 'type' => 'failed', |
||
| 99 | ]); |
||
| 100 | |||
| 101 | }else{ |
||
| 102 | $data = $this->dashboard_apel->create($request->all()); |
||
| 103 | |||
| 104 | return response()->json([ |
||
| 105 | 'type' => 'success', |
||
| 106 | 'title' => 'success', |
||
| 107 | 'id' => $data->id, |
||
| 108 | 'message' => 'PDRB '. $this->regency->find($request->regency_id)->name .' tahun '. $request->tahun .' successfully created', |
||
| 109 | ]); |
||
| 110 | } |
||
| 111 | |||
| 112 | } |
||
| 113 | |||
| 114 | public function update(Request $request, $id) |
||
| 115 | { |
||
| 116 | /* todo : return json */ |
||
| 117 | return ''; |
||
| 118 | |||
| 119 | } |
||
| 120 | |||
| 121 | public function destroy($id) |
||
| 122 | { |
||
| 123 | /* todo : return json */ |
||
| 124 | return ''; |
||
| 125 | |||
| 126 | } |
||
| 127 | } |
||
| 128 | |||
| 129 |
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