Skip to content

[BUG] 3 errors in model file generation #1055

@Mosaab-Emam

Description

@Mosaab-Emam
Contributor

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;

Activity

changed the title [-][Bug] 3 errors in model file generation[/-] [+][BUG] 3 errors in model file generation[/+] on Dec 21, 2022
linked a pull request that will close this issue on Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Mosaab-Emam

      Issue actions

        [BUG] 3 errors in model file generation · Issue #1055 · InfyOmLabs/laravel-generator