Skip to content

Conversation

@luigieli
Copy link
Contributor

This PR intend to:

  • Add Store and Update requests to ProfessorController.
  • Add DB transaction to destroy method on ProfessorController.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the ProfessorController by adding validation request classes for store and update operations, and wraps the destroy method in a database transaction for data integrity.

Key Changes:

  • Added StoreProfessorRequest and UpdateProfessorRequest classes for input validation
  • Wrapped the destroy method in a DB transaction to ensure atomic deletion of professor and user records

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
StoreProfessorRequest.php New validation request class defining required fields for creating professors
UpdateProfessorRequest.php New validation request class defining optional fields for updating professors
ProfessorController.php Updated store/update methods to use request classes and added transaction handling to destroy method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{
return [
'name' => [ 'required', 'string', 'max:255', ],
'email' => [ 'required', 'string','email', 'max:255', Rule::unique('users', 'email'), ],
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Missing import for Rule class. Add use Illuminate\Validation\Rule; at the top of the file.

Copilot uses AI. Check for mistakes.

return [
'name' => [ 'sometimes', 'string', 'max:255', ],
'email' => [ 'sometimes', 'string','email', 'max:255', Rule::unique('users', 'email')->ignore($professorId), ],
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Missing import for Rule class. Add use Illuminate\Validation\Rule; at the top of the file.

Copilot uses AI. Check for mistakes.

DB::commit();

retrun response()->json(null, 204);
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'retrun' to 'return'.

Suggested change
retrun response()->json(null, 204);
return response()->json(null, 204);

Copilot uses AI. Check for mistakes.
DB::commit();

retrun response()->json(null, 204);
} catch (\Throwable e) {
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Missing $ before variable name. Should be catch (\Throwable $e).

Suggested change
} catch (\Throwable e) {
} catch (\Throwable $e) {

Copilot uses AI. Check for mistakes.
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.

1 participant