BossBey File Manager
PHP:
8.2.30
OS:
Linux
User:
imagivibe
Root
/
home
/
imagivibe
/
public_html
/
app.imagivibe.com
/
app
/
Models
/
Extensions
📤 Upload
📝 New File
📁 New Folder
Close
Editing: Introduction.php
<?php namespace App\Models\Extensions; use Illuminate\Database\Eloquent\Model; class Introduction extends Model { protected $fillable = [ 'key', 'intro', 'order', 'status', 'title', 'file_url', 'file_type', 'file_path', 'parent_id', ]; protected $casts = [ 'key' => \App\Enums\Introduction::class, ]; public function children() { return $this->hasMany(Introduction::class, 'parent_id'); } public function parent() { return $this->belongsTo(Introduction::class, 'parent_id'); } public static function getFormattedSteps() { return self::query() ->whereNull('parent_id') ->where('status', true) ->orderBy('order') ->with('children') ->get() ->map(function ($item) { $result = [ 'intro' => $item->intro, 'title' => $item->title, 'file_url' => $item->file_url, 'file_type' => $item->file_type, 'element' => '[data-name="' . $item->key->value . '"]', ]; if ($item->key->value === 'initialize' && $item->children->count() > 0) { $result['steps'] = $item->children->map(function ($child) { return [ 'intro' => $child->intro, 'title' => $child->title, 'file_url' => $child->file_url, 'file_type' => $child->file_type, ]; })->toArray(); } return $result; }); } }
Save
Cancel