Skip to content

Model branch#37

Open
alamriku wants to merge 47 commits intodatabase_migration_seedfrom
modelBranch
Open

Model branch#37
alamriku wants to merge 47 commits intodatabase_migration_seedfrom
modelBranch

Conversation

@alamriku
Copy link
Copy Markdown
Owner

@alamriku alamriku commented Nov 7, 2020

No description provided.

Comment thread app/Models/Author.php Outdated

class Author extends Model
{
use HasFactory;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add SoftDeletes trait.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fix in other places too.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

done

Comment thread app/Models/Author.php Outdated

public function books()
{
return $this->belongsToMany('App\Models\Book')->using('App\Models\AuthorBook');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use like this:

return $this->belongsToMany(Book::class)->using(AuthorBook::class);

It'll be easier for the IDE to reference.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fix in other places too.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

done

Comment thread app/Models/AuthorBook.php
class AuthorBook extends Pivot
{
public $incrementing = true;
use HasFactory;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Trait statement should be the first line inside the Class.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

done

Comment thread app/Models/Book.php Outdated
{
use HasFactory;

public function authors(){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

{ should be placed in the next line.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

done

Comment thread app/Models/Book.php
public function bookOfCopies(){
return $this->hasMany('App\Models\BookCopy');
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove unnecessary empty lines.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

done

Comment thread app/Models/BookUser.php Outdated
{
use HasFactory;

public function userHaveCopy(){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The naming doesn't seem right. Please check. Think about the naming from the usage. For example, in your case it would be:

$bookUser = new BookUser();
$bookUser->userHaveCopy;

$bookUser->userHaveCopy it doesn't sound good.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same is for the below method bookOfUser.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

done

Comment thread app/Models/Genre.php Outdated
{
use HasFactory;

public function GenreBooks(){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fix the naming and put the { on the next line.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fix in other places too.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

done

$table->string('name');
$table->string('image');
$table->string('image')->nullable();
$table->text('description');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should be nullable.

$table->string('name');
$table->string('logo');
$table->string('logo')->nullable();
$table->text('description');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should be nullable.

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddDropForeignOnAuthorBookTable extends Migration
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why creating separate migration for 'foreign keys'? It would be hard to maintain.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

could't write the drop code on down method. I have take this step.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Done. foreign key drop added on there specific table migration file.

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