@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Display a listing of the resource. |
| 17 | 17 | * |
| 18 | - * @return \Illuminate\Http\Response |
|
| 18 | + * @return \Illuminate\Http\JsonResponse |
|
| 19 | 19 | */ |
| 20 | 20 | public function index() { |
| 21 | 21 | //return Tag::all(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Display the specified resource. |
| 53 | 53 | * |
| 54 | 54 | * @param int $id |
| 55 | - * @return \Illuminate\Http\Response |
|
| 55 | + * @return \Illuminate\Http\JsonResponse |
|
| 56 | 56 | */ |
| 57 | 57 | public function show($id) { |
| 58 | 58 | //return $tag = Tag::findOrFail($id); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @param \Illuminate\Http\Request $request |
| 91 | 91 | * @param int $id |
| 92 | - * @return \Illuminate\Http\Response |
|
| 92 | + * @return \Illuminate\Http\JsonResponse|null |
|
| 93 | 93 | */ |
| 94 | 94 | public function update(Request $request, $id) { |
| 95 | 95 | //$tag = Tag::findOrFail($id); |
@@ -122,6 +122,9 @@ discard block |
||
| 122 | 122 | Tag::destroy($id); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | + /** |
|
| 126 | + * @param \Illuminate\Database\Eloquent\Collection $tag |
|
| 127 | + */ |
|
| 125 | 128 | public function transformCollection($tag) { |
| 126 | 129 | return array_map([$this, 'transform'], $tag->toArray()); |
| 127 | 130 | } |
@@ -134,7 +137,7 @@ discard block |
||
| 134 | 137 | |
| 135 | 138 | /** |
| 136 | 139 | * @param Request $request |
| 137 | - * @param $tag |
|
| 140 | + * @param Tag $tag |
|
| 138 | 141 | */ |
| 139 | 142 | public function saveTag(Request $request, $tag) { |
| 140 | 143 | $tag->name = $request->name; |
@@ -3,10 +3,7 @@ |
||
| 3 | 3 | namespace App\Http\Controllers; |
| 4 | 4 | |
| 5 | 5 | use App\Tag; |
| 6 | -use App\Transformers\TagTransformer; |
|
| 7 | 6 | use Illuminate\Http\Request; |
| 8 | - |
|
| 9 | -use App\Http\Requests; |
|
| 10 | 7 | use App\Http\Controllers\Controller; |
| 11 | 8 | use Response; |
| 12 | 9 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | return Response::json([ |
| 26 | 26 | 'data' => $this->transformCollection($tag) |
| 27 | - ],200); |
|
| 27 | + ], 200); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | return Response::json([ |
| 73 | 73 | 'data' => $this->transform($tag->toArray()) |
| 74 | - ],200); |
|
| 74 | + ], 200); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | return Response::json([ |
| 109 | 109 | 'data' => $tag->toArray() |
| 110 | - ],200); |
|
| 110 | + ], 200); |
|
| 111 | 111 | |
| 112 | 112 | $this->saveTag($request, $tag); |
| 113 | 113 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | return array_map([$this, 'transform'], $tag->toArray()); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - private function transform($tag){ |
|
| 129 | + private function transform($tag) { |
|
| 130 | 130 | return [ |
| 131 | 131 | 'name' => $tag['name'] |
| 132 | 132 | ]; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * Display a listing of the resource. |
| 15 | 15 | * |
| 16 | - * @return \Illuminate\Http\Response |
|
| 16 | + * @return \Illuminate\Http\JsonResponse |
|
| 17 | 17 | */ |
| 18 | 18 | public function index() { |
| 19 | 19 | // 1. No es retorna: paginacion |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Display the specified resource. |
| 53 | 53 | * |
| 54 | 54 | * @param int $id |
| 55 | - * @return \Illuminate\Http\Response |
|
| 55 | + * @return \Illuminate\Http\JsonResponse |
|
| 56 | 56 | */ |
| 57 | 57 | public function show($id) { |
| 58 | 58 | //return $tag = Task::findOrFail($id); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @param \Illuminate\Http\Request $request |
| 91 | 91 | * @param int $id |
| 92 | - * @return \Illuminate\Http\Response |
|
| 92 | + * @return \Illuminate\Http\JsonResponse|null |
|
| 93 | 93 | */ |
| 94 | 94 | public function update(Request $request, $id) { |
| 95 | 95 | //$task = Task::findOrFail($id); |
@@ -122,6 +122,9 @@ discard block |
||
| 122 | 122 | Task::destroy($id); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | + /** |
|
| 126 | + * @param \Illuminate\Database\Eloquent\Collection $task |
|
| 127 | + */ |
|
| 125 | 128 | public function transformCollection($task) { |
| 126 | 129 | return array_map([$this, 'transform'], $task->toArray()); |
| 127 | 130 | } |
@@ -137,6 +140,7 @@ discard block |
||
| 137 | 140 | /** |
| 138 | 141 | * @param Request $request |
| 139 | 142 | * @param $tag |
| 143 | + * @param Task $task |
|
| 140 | 144 | */ |
| 141 | 145 | public function saveTask(Request $request, $task) { |
| 142 | 146 | $task->name = $request->name; |
@@ -4,8 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use App\Task; |
| 6 | 6 | use Illuminate\Http\Request; |
| 7 | - |
|
| 8 | -use App\Http\Requests; |
|
| 9 | 7 | use App\Http\Controllers\Controller; |
| 10 | 8 | use Response; |
| 11 | 9 | |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | 'error' => [ |
| 65 | 65 | 'message' => 'Task does not exist', |
| 66 | 66 | 'code' => 195 |
| 67 | - ] |
|
| 67 | + ] |
|
| 68 | 68 | ], 404); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | return Response::json([ |
| 25 | 25 | 'data' => $this->transformCollection($task) |
| 26 | 26 | //'data' => $task->toArray() |
| 27 | - ],200); |
|
| 27 | + ], 200); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | return Response::json([ |
| 72 | 72 | 'data' => $this->transform($task->toArray()) |
| 73 | 73 | //'data' => $task->toArray() |
| 74 | - ],200); |
|
| 74 | + ], 200); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | return Response::json([ |
| 109 | 109 | 'data' => $task->toArray() |
| 110 | - ],200); |
|
| 110 | + ], 200); |
|
| 111 | 111 | |
| 112 | 112 | $this->saveTask($request, $task); |
| 113 | 113 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | return array_map([$this, 'transform'], $task->toArray()); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - private function transform($task){ |
|
| 129 | + private function transform($task) { |
|
| 130 | 130 | return [ |
| 131 | 131 | 'name' => $task['name'], |
| 132 | 132 | 'priority' => (boolean) $task['priority'], |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | protected function schedule(Schedule $schedule) |
| 26 | 26 | { |
| 27 | 27 | $schedule->command('inspire') |
| 28 | - ->hourly(); |
|
| 28 | + ->hourly(); |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | public function map(Router $router) |
| 39 | 39 | { |
| 40 | - $router->group(['namespace' => $this->namespace], function ($router) { |
|
| 40 | + $router->group(['namespace' => $this->namespace], function($router) { |
|
| 41 | 41 | require app_path('Http/routes.php'); |
| 42 | 42 | }); |
| 43 | 43 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -Route::get('/', function () { |
|
| 14 | +Route::get('/', function() { |
|
| 15 | 15 | return view('welcome'); |
| 16 | 16 | }); |
| 17 | 17 | |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | |
| 12 | 12 | class TagTransformer extends Transformer { |
| 13 | - public function transform($item){ |
|
| 13 | + public function transform($item) { |
|
| 14 | 14 | return [ |
| 15 | 15 | 'name' => $item['name'], |
| 16 | 16 | 'tran' => (boolean) $item['tran'] |