Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hidden property in BaseModels #264

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/models.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,17 @@
'override_pluralize_for' => [

],

/*
|--------------------------------------------------------------------------
| Move $hidden property to base files
|--------------------------------------------------------------------------
| When base_files is true you can set hidden_in_base_files to true
| if you want the $hidden to be generated in base files
|
*/
'hidden_in_base_files' => false,

/*
|--------------------------------------------------------------------------
| Move $fillable property to base files
Expand Down
4 changes: 2 additions & 2 deletions src/Coders/Model/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ protected function body(Model $model)
$body .= $this->class->field('casts', $model->getCasts(), ['before' => "\n"]);
}

if ($model->hasHidden() && $model->doesNotUseBaseFiles()) {
if ($model->hasHidden() && ($model->doesNotUseBaseFiles() || $model->hiddenInBaseFiles())) {
$body .= $this->class->field('hidden', $model->getHidden(), ['before' => "\n"]);
}

Expand Down Expand Up @@ -575,7 +575,7 @@ protected function userFileBody(Model $model)
{
$body = '';

if ($model->hasHidden()) {
if ($model->hasHidden() && !$model->hiddenInBaseFiles()) {
$body .= $this->class->field('hidden', $model->getHidden());
}

Expand Down
8 changes: 8 additions & 0 deletions src/Coders/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,14 @@ public function fillableInBaseFiles(): bool
return $this->config('fillable_in_base_files', false);
}

/**
* @return bool
*/
public function hiddenInBaseFiles(): bool
{
return $this->config('hidden_in_base_files', false);
}

/**
* @return bool
*/
Expand Down