Concat two properties #198
Unanswered
codetestmg
asked this question in
Q&A
Replies: 1 comment
-
Hi @codetestmg the package doesn't limit you from doing whatever you want. it is only simple PHP manipulation, for example class SongData extends Spatie\LaravelData\Data
{
public function __construct(
public ?string $firstName,
public string $lastName,
public string $recordCompany,
) {
}
public static function fromArray(array $songData): SongData
{
return new self(
firstName: null,
lastName: $songData['firstName'].'-'.$songData['lastName'],
recordCompany: "company"
);
}
}
$songArr = ['firstName' => 'hello', 'lastName' => 'world'];
SongData::from($songArr)->toArray();
// [ "firstName" => null, "lastName" => "hello-world", "recordCompany" => "company" ] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This library really good but I have a use case where I need to contact property value with other property value .for example
Here i want lastName value to be
firstName."-".lastName;
is this possible using laravel-data
Beta Was this translation helpful? Give feedback.
All reactions