Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task 1: Code Review #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AnjaBasara
Copy link
Owner

No description provided.

Comment on lines +47 to +48
'writer_id' => 'nullable|exists:writers,id',
'writer_name' => 'nullable|string|max:255',
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With both writer_id and writer_name being nullable, the user could try creating a Book without a writer. Please add additional validation that at least one field needs to be present.

@@ -34,7 +35,7 @@ public function create()
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
public function store(Request $request, BookRepository $repository)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Dependency Injection for BookRepository

Comment on lines +49 to +50
'publisher_id' => 'nullable|exists:publishers,id',
'publisher_name' => 'nullable|string|max:255',
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the publisher, users could try creating a Book without a publisher

Comment on lines +48 to +50
return Writer::create([
'name' => $requestData['writer_name'],
]);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that the acceptance criteria states "if the writer doesn't exist, create a new one", with the current implementation users could enter the same author multiple times since they only enter the writer_name.

writer

If the acceptance criteria states to enable adding a new Writer through the Create Book form, all the fields from the Create Writer form should be present and those fields should be used in checking if the Writer already exists in the database:

create writer

Comment on lines +66 to +69
return Publisher::create([
'name' => $requestData['publisher_name'],
'location' => $requestData['publisher_location'],
]);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the Publisher, here all the fields are included but possibly the Publisher already exists in the database and is listed in the dropdown.

@@ -0,0 +1,71 @@
<?php

namespace App;
Copy link
Owner Author

@AnjaBasara AnjaBasara Jun 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place this file inside App\Repositories folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants