Skip to content

fix: model-generation fix 3 errors#1058

Open
Mosaab-Emam wants to merge 1 commit into
InfyOmLabs:developfrom
Mosaab-Emam:fix-model-file-1055
Open

fix: model-generation fix 3 errors#1058
Mosaab-Emam wants to merge 1 commit into
InfyOmLabs:developfrom
Mosaab-Emam:fix-model-file-1055

Conversation

@Mosaab-Emam

Copy link
Copy Markdown
Contributor

Closes #1055

@Mosaab-Emam Mosaab-Emam left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Explaining my changes

Comment on lines +8 to +10
@if($config->options->softDelete)
{{ 'use Illuminate\Database\Eloquent\SoftDeletes;' }}
@endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. Remove space right before {{ which manifests in an out-of-place space in the generated file.
  2. Expand statement to 3 lines instead of 1 to prevent error of showing 2 statements in 1 line in the generated file.

Comment on lines +11 to +13
@if($config->options->tests or $config->options->factory)
{{ 'use Illuminate\Database\Eloquent\Factories\HasFactory;' }}
@endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. Remove space right before {{ which manifests in an out-of-place space in the generated file.
  2. Expand statement to 3 lines instead of 1 to prevent error of showing 2 statements in 1 line in the generated file.

Comment on lines +14 to +15
@if(isset($swaggerDocs))
{!! $swaggerDocs !!}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ensure the presence of a new line between docs start and the last statement above.

@endif
@if(isset($swaggerDocs))
{!! $swaggerDocs !!}
@else@nls(2)@endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ensure separation between class declaration and above use statements when there is no swagger docs.

@if($config->options->softDelete) {{ infy_tab().'use SoftDeletes;' }}@endif
@if($config->options->tests or $config->options->factory){{ infy_tab().'use HasFactory;' }}@endif
public $table = '{{ $config->tableName }}';
@if($config->options->softDelete && ($config->options->tests or $config->options->factory))@tab()use SoftDeletes, HasFactory;@nls(2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Combine SoftDeletes and HasFactory in a single use statements if there are both set to true in config. and replace incorrect space with a regular tab.

Comment on lines +20 to +21
@elseif($config->options->softDelete)@tab()use SoftDeletes;@nls(2)
@elseif($config->options->tests or $config->options->factory)@tab()use HasFactory;@nls(2)@endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Replace white space with a regular tab when inserting SoftDeletes or HasFactory traits.

@if($config->options->softDelete && ($config->options->tests or $config->options->factory))@tab()use SoftDeletes, HasFactory;@nls(2)
@elseif($config->options->softDelete)@tab()use SoftDeletes;@nls(2)
@elseif($config->options->tests or $config->options->factory)@tab()use HasFactory;@nls(2)@endif
@tab()public $table = '{{ $config->tableName }}';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Use @tab() instead of editor specific tab.

@if($config->options->softDelete && ($config->options->tests or $config->options->factory))@tab()use SoftDeletes, HasFactory;@nls(2)
@elseif($config->options->softDelete)@tab()use SoftDeletes;@nls(2)
@elseif($config->options->tests or $config->options->factory)@tab()use HasFactory;@nls(2)@endif
@tab()public $table = '{{ $config->tableName }}';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Use @tab() instead of editor specific tab.

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.

[BUG] 3 errors in model file generation

1 participant