Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.

Feature/andre floquet #37

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

andrefloquet
Copy link

Create Post

andrefloquet added 3 commits September 2, 2022 22:05
Post model, migration and User Relationship
Seeding database with default user
Create Post
Copy link
Member

@stevethomas stevethomas left a comment

Choose a reason for hiding this comment

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

Overall a pretty clean PR 👍🏻

Comment on lines 47 to 49
if(isset($post)) {
session()->flash('success', "The post '{$post->name}' has been created!");
}
Copy link
Member

Choose a reason for hiding this comment

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

If the Post::create() operation failed an exception would be thrown, so this if condition is unnecessary.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I agree. Would be better in a try catch block

Copy link
Author

Choose a reason for hiding this comment

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

changed for try catch block returning friendly user message

{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
Copy link
Member

Choose a reason for hiding this comment

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

I think this means if the post is deleted, the user is also deleted? 😱

Copy link
Member

Choose a reason for hiding this comment

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

actually no, this looks correct.

Copy link
Author

@andrefloquet andrefloquet Sep 4, 2022

Choose a reason for hiding this comment

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

yeah, the opposite. If the user is deleted, the posts from the user are deleted too

<div>
<x-label for="image" :value="__('Upload Image')" />

<x-input-file id="image" class="block mt-1 w-full" type="file" name="image" />
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably move type="file" to the file component given it is specifically a file component.

Copy link
Author

Choose a reason for hiding this comment

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

Indeed. I saw the input component and I copied from that as I have no much experience working with blade components, but the input can be of many types, the file input type is just file input type. You are right.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

fix on input-file component and post.store. Add images .gitignore
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants