Skip to content

Commit d9c683a

Browse files
committed
Added View By ID
1 parent e60dc4b commit d9c683a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/Http/Controllers/Api/TodoController.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,20 @@ public function store(Request $request)
5454
* @param int $id
5555
* @return \Illuminate\Http\Response
5656
*/
57-
public function show($id)
57+
public function show(Todo $todo)
5858
{
59-
//
59+
try {
60+
61+
if(Auth::user()->id !== $todo->user_id)
62+
{
63+
return $this->error('','dont have access to other post');
64+
}
65+
66+
return new TodoResource($todo);
67+
68+
} catch (\Throwable $e) {
69+
return $this->internalError($e->getMessage());
70+
}
6071
}
6172

6273
/**

0 commit comments

Comments
 (0)