Skip to content

Commit

Permalink
Utilise new components functionality from page builder.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymeh committed Feb 8, 2024
1 parent ba43816 commit f389b71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"require": {
"php": "^8.1",
"creode/laravel-careers": "^1.2",
"creode/nova-page-builder": "^1.2",
"creode/nova-page-builder": "^1.3",
"creode/nova-publishable": "^1.0",
"illuminate/contracts": "^10.0",
"laravel/nova": "^4.0",
Expand Down
20 changes: 4 additions & 16 deletions src/Models/NovaCareer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,16 @@
namespace Creode\LaravelNovaCareers\Models;

use Creode\LaravelCareers\Models\Career;
use Creode\NovaPageBuilder\Services\BlockRenderer;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Creode\NovaPageBuilder\Traits\HasComponents;
use Whitecube\NovaFlexibleContent\Value\FlexibleCast;

class NovaCareer extends Career
{
use HasComponents;

protected $casts = [
'description' => FlexibleCast::class,
];

/**
* Exposes a set of components from the Page Builder.
*
* @return Attribute
*/
protected function components(): Attribute
{
$blockRendererService = app()->make(BlockRenderer::class);
return Attribute::make(
get: function () use ($blockRendererService) {
return $blockRendererService->render($this->description);
}
);
}
protected $componentField = 'description';
}

0 comments on commit f389b71

Please sign in to comment.