Skip to content

Commit

Permalink
content creation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Raza9798 committed Sep 27, 2024
1 parent d6ea000 commit 53fbfce
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 53fbfce

Please sign in to comment.