Nested Eloquent casting with default values? #604
Answered
by
francoism90
francoism90
asked this question in
Q&A
-
I'm following this example: https://stefanzweifel.dev/posts/2023/10/29/spatielaravel-data-is-probably-the-best-way-to-store-settings-in-your-laravel-app However this results in:
This is what I'm using to get the default settings:
What I'm I doing wrong here? Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
francoism90
Nov 15, 2023
Replies: 2 comments
-
Hmm, adding |
Beta Was this translation helpful? Give feedback.
0 replies
-
Solution: <?php
namespace App\Data;
use App\Domain\Support\Enums\ThemeApperance;
use Spatie\LaravelData\Data;
class UserSettings extends Data
{
public UserGeneralSettings $general;
public UserNotificationSettings $notification;
public UserApperanceSettings $apperance;
public function __construct(
//
) {
$this->general = new UserGeneralSettings();
$this->notification = new UserNotificationSettings();
$this->apperance = new UserApperanceSettings();
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
francoism90
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution: