Skip to content

Commit

Permalink
code spacing and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gcavanunez committed Nov 9, 2023
1 parent 65e3a52 commit 0142405
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/HasParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,20 @@ protected function getParentClass(): string


/**
* Merge the fillable attributes for the model with Parent Class
* Merge the fillable attributes for the model with those of its Parent Class
*
* @return array<string>
*/
public function getFillable()
{

$parentClass = $this->getParentClass();

if ((new ReflectionClass($parentClass))->isAbstract()) {

return $this->fillable;
}
$parentFillable = (new $parentClass)->getFillable();

return array_unique(array_merge($parentFillable, $this->fillable));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ function child_fillables_are_merged_with_parent_fillables()
'industry' => 'Technology',
'skill_level' => 'Advanced',
]);

$event = Event::first();

$this->assertEquals($event->name, $workshop->name);
}
}
1 change: 1 addition & 0 deletions tests/Models/Conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
class Conference extends Event
{
use HasParent;

protected $fillable = ['industry'];
}
4 changes: 1 addition & 3 deletions tests/Models/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@

class Event extends Model
{
protected $fillable = [
'name', 'type'
];
protected $fillable = ['name', 'type'];
}
1 change: 1 addition & 0 deletions tests/Models/Workshop.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
class Workshop extends Event
{
use HasParent;

protected $fillable = ['industry', 'skill_level'];
}

0 comments on commit 0142405

Please sign in to comment.