Skip to content

Commit

Permalink
Merge pull request #264 from 0kyn/add-hidden-in-base-files
Browse files Browse the repository at this point in the history
Add hidden property in BaseModels
  • Loading branch information
finiteinfinity committed Dec 4, 2023
2 parents 3e0d2e5 + def4daf commit 8ff9498
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
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

0 comments on commit 8ff9498

Please sign in to comment.