Skip to content

[BUG] 3 errors in model file generation #1055

Open
@Mosaab-Emam

Description

@Mosaab-Emam

Looking at what gets generated in the Model file, I noticed 3 errors.

1. Double semi-colon

Here are the first 6 lines from Model file

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\SoftDeletes;; use Illuminate\Database\Eloquent\Factories\HasFactory;;

The 2nd and 3rd imports have repeated semi-colons at the end.

2. Incorrect spacing and new lines in top section

In the code block above we can also see some white space added before the keyword use, which should not be there.

We also see that two use statements are in the same line, which is incorrect and inconsistent with every other generated file, the white space before the second use should be replaced with \n.

Another \n should be added right after the second use statement, there is no new line between it and the line below (not an import).

3. Incorrect use of tabs inside model class

Here are the first few lines in the generated model class

 */class User extends Model
{
     use SoftDeletes;    use HasFactory;    public $table = 'users';

    public $fillable = [

Firstly, we can see there should be a \n before the class keyword, which is not present.

Secondly: the first 3 statements in the class are present on the same line, with tabs in place of new lines.

Thirdly: the aforementioned statements have white space before them that should not be present, clearly visible on use SoftDeletes;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions