InfyOmLabs/laravel-generator

[BUG] 3 errors in model file generation

Mosaab-Emam opened this issue · 0 comments

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;