mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
parent
ed9d03d0b8
commit
56638b26e8
28 changed files with 1067 additions and 346 deletions
|
|
@ -4,6 +4,7 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
|
@ -65,4 +66,38 @@ class Plugin extends Model
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the plugin's markup
|
||||
*/
|
||||
public function render(string $size = 'full', bool $standalone = true): string
|
||||
{
|
||||
if ($this->render_markup) {
|
||||
if ($standalone) {
|
||||
return view('trmnl-layouts.single', [
|
||||
'slot' => Blade::render($this->render_markup, ['size' => $size, 'data' => $this->data_payload]),
|
||||
])->render();
|
||||
}
|
||||
|
||||
return Blade::render($this->render_markup, ['size' => $size, 'data' => $this->data_payload]);
|
||||
}
|
||||
|
||||
if ($this->render_markup_view) {
|
||||
if ($standalone) {
|
||||
return view('trmnl-layouts.single', [
|
||||
'slot' => view($this->render_markup_view, [
|
||||
'size' => $size,
|
||||
'data' => $this->data_payload,
|
||||
])->render(),
|
||||
])->render();
|
||||
} else {
|
||||
return view($this->render_markup_view, [
|
||||
'size' => $size,
|
||||
'data' => $this->data_payload,
|
||||
])->render();
|
||||
}
|
||||
}
|
||||
|
||||
return '<p>No render markup yet defined for this plugin.</p>';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue