Skip to content

Commit

Permalink
Merge pull request #302 from nexco-lk/main
Browse files Browse the repository at this point in the history
content creation fix
  • Loading branch information
curtisdelicata authored Sep 27, 2024
2 parents 2951ec6 + 53fbfce commit b7958aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 10 additions & 3 deletions app/Models/GuestLayoutManagment.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,29 @@ protected static function boot()
parent::boot();

static::creating(function ($model) {
self::makeComponent($model->content, $model->name);
$name = \Str::replace(' ', '_', $model->name);
self::makeComponent($model->content, $name);
});

static::updating(function ($model) {
self::makeComponent($model->content, $model->name);
$name = \Str::replace(' ', '_', $model->name);
self::makeComponent($model->content, $name);
});
}

public static function makeComponent($component, $name)
{
file_put_contents(
resource_path('views/partials/elements' . $name . '.blade.php'),
resource_path('views/partials/elements/' . $name . '.blade.php'),
$component
);
}

public function setNameAttribute($value)
{
$this->attributes['name'] = \Str::replace(' ', '_', $value);
}

public function scopeActive()
{
return $this->where('is_active', true);
Expand Down
Loading

0 comments on commit b7958aa

Please sign in to comment.