| 1 | <?php |
||
| 12 | class DashboardController extends Controller |
||
| 13 | { |
||
| 14 | |||
| 15 | use Helpers; |
||
| 16 | |||
| 17 | 3 | public function __construct() { |
|
| 20 | |||
| 21 | /** |
||
| 22 | * Display a listing of all authorized devices |
||
| 23 | * |
||
| 24 | * @return \Illuminate\Http\Response |
||
| 25 | */ |
||
| 26 | 3 | public function index(Request $request) |
|
| 31 | |||
| 32 | /** |
||
| 33 | * Show the form for creating a new resource. |
||
| 34 | * |
||
| 35 | * @return \Illuminate\Http\Response |
||
| 36 | */ |
||
| 37 | public function create(Request $request) |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Store a newly created resource in storage. |
||
| 44 | * |
||
| 45 | * @param \Illuminate\Http\Request $request |
||
| 46 | * @return \Illuminate\Http\Response |
||
| 47 | */ |
||
| 48 | 1 | public function store(Request $request) |
|
| 49 | { |
||
| 50 | 1 | $validation = Validator::make($request->all(), [ |
|
| 51 | 1 | 'name' => 'required|max:255', |
|
| 52 | 1 | 'access' => 'required', |
|
| 53 | 1 | ]); |
|
| 54 | 1 | if($validation->passes()) |
|
| 55 | 1 | { |
|
| 56 | 1 | $dashboard = new Dashboard; |
|
| 57 | 1 | $dashboard->dashboard_name = $request->name; |
|
|
1 ignored issue
–
show
|
|||
| 58 | 1 | $dashboard->access = $request->access; |
|
|
1 ignored issue
–
show
|
|||
| 59 | 1 | if ($request->user()->dashboards()->save($dashboard)) |
|
| 60 | 1 | { |
|
| 61 | 1 | if (is_numeric($request->copy_from)) |
|
| 62 | 1 | { |
|
| 63 | $duplicate_widgets = Dashboard::find($request->copy_from)->widgets()->get(); |
||
| 64 | foreach ($duplicate_widgets as $tmp_widget) |
||
| 65 | { |
||
| 66 | /** @var UsersWidgets $tmp_widget */ |
||
| 67 | $new_widget = $tmp_widget->replicate(); |
||
| 68 | $new_widget->user_id = $request->user()->user_id; |
||
| 69 | $new_widget->dashboard_id = $dashboard->dashboard_id; |
||
| 70 | unset($new_widget->user_widget_id); |
||
| 71 | $new_widget->save(); |
||
| 72 | } |
||
| 73 | } |
||
| 74 | 1 | return $this->response->array(array('statusText' => 'OK', 'dashboard_id' => $dashboard->dashboard_id)); |
|
| 75 | } |
||
| 76 | else { |
||
| 77 | return $this->response->errorInternal(); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | else { |
||
| 81 | $errors = $validation->errors(); |
||
| 82 | return response()->json($errors,422); |
||
| 83 | } |
||
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Display the specified resource. |
||
| 88 | * |
||
| 89 | * @param int $id |
||
| 90 | * @return \Illuminate\Http\Response |
||
| 91 | */ |
||
| 92 | 2 | public function show(Request $request, $id) |
|
| 102 | |||
| 103 | /** |
||
| 104 | * Show the form for editing the specified resource. |
||
| 105 | * |
||
| 106 | * @param int $id |
||
| 107 | * @return \Illuminate\Http\Response |
||
| 108 | */ |
||
| 109 | public function edit($id) |
||
| 113 | |||
| 114 | /** |
||
| 115 | * Update the specified resource in storage. |
||
| 116 | * |
||
| 117 | * @param \Illuminate\Http\Request $request |
||
| 118 | * @param int $id |
||
| 119 | * @return \Illuminate\Http\Response |
||
| 120 | */ |
||
| 121 | public function update(Request $request, $id) |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Remove the specified resource from storage. |
||
| 148 | * |
||
| 149 | * @param int $id |
||
| 150 | * @return \Illuminate\Http\Response |
||
| 151 | */ |
||
| 152 | public function destroy(Request $request, $id) |
||
| 168 | |||
| 169 | public function clear($id) |
||
| 179 | |||
| 180 | } |
||
| 181 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: