We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php namespace Backpack\CRUD\app\Http\Controllers; |
||
18 | class CrudController extends BaseController { |
||
19 | |||
20 | use DispatchesJobs, ValidatesRequests; |
||
21 | |||
22 | public $data = []; |
||
23 | public $crud; |
||
24 | |||
25 | public function __construct() |
||
29 | |||
30 | /** |
||
31 | * Display all rows in the database for this entity. |
||
32 | * |
||
33 | * @return Response |
||
34 | */ |
||
35 | public function index() |
||
46 | |||
47 | |||
48 | /** |
||
49 | * Show the form for creating inserting a new row. |
||
50 | * |
||
51 | * @return Response |
||
52 | */ |
||
53 | View Code Duplication | public function create() |
|
65 | |||
66 | |||
67 | /** |
||
68 | * Store a newly created resource in the database. |
||
69 | * |
||
70 | * @param StoreRequest $request - type injection used for validation using Requests |
||
71 | * @return \Illuminate\Http\RedirectResponse |
||
72 | */ |
||
73 | public function storeCrud(StoreRequest $request = null) |
||
94 | |||
95 | |||
96 | /** |
||
97 | * Show the form for editing the specified resource. |
||
98 | * |
||
99 | * @param int $id |
||
100 | * @return Response |
||
101 | */ |
||
102 | public function edit($id) |
||
117 | |||
118 | |||
119 | /** |
||
120 | * Update the specified resource in the database. |
||
121 | * |
||
122 | * @param UpdateRequest $request - type injection used for validation using Requests |
||
123 | * @return \Illuminate\Http\RedirectResponse |
||
124 | */ |
||
125 | public function updateCrud(UpdateRequest $request = null) |
||
138 | |||
139 | |||
140 | /** |
||
141 | * Display the specified resource. |
||
142 | * |
||
143 | * @param int $id |
||
144 | * @return Response |
||
145 | */ |
||
146 | View Code Duplication | public function show($id) |
|
158 | |||
159 | |||
160 | /** |
||
161 | * Remove the specified resource from storage. |
||
162 | * |
||
163 | * @param int $id |
||
164 | * @return string |
||
165 | */ |
||
166 | public function destroy($id) |
||
171 | |||
172 | |||
173 | /** |
||
174 | * Reorder the items in the database using the Nested Set pattern. |
||
175 | * |
||
176 | * Database columns needed: id, parent_id, lft, rgt, depth, name/title |
||
177 | * |
||
178 | * @return Response |
||
179 | */ |
||
180 | public function reorder($lang = false) |
||
201 | |||
202 | |||
203 | /** |
||
204 | * Save the new order, using the Nested Set pattern. |
||
205 | * |
||
206 | * Database columns needed: id, parent_id, lft, rgt, depth, name/title |
||
207 | * |
||
208 | * @return |
||
209 | */ |
||
210 | public function saveReorder() |
||
225 | |||
226 | |||
227 | /** |
||
228 | * Used with AJAX in the list view (datatables) to show extra information about that row that didn't fit in the table. |
||
229 | * It defaults to showing some dummy text. |
||
230 | * |
||
231 | * It's enabled by: |
||
232 | * - setting: $crud->details_row = true; |
||
233 | * - adding the details route for the entity; ex: Route::get('page/{id}/details', 'PageCrudController@showDetailsRow'); |
||
234 | * - adding a view with the following name to change what the row actually contains: app/resources/views/vendor/backpack/crud/details_row.blade.php |
||
235 | */ |
||
236 | public function showDetailsRow($id) |
||
246 | |||
247 | |||
248 | |||
249 | } |
||
250 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.