Add the Entity trait to the channel.
This commit is contained in:
parent
5a86bb3579
commit
8d7bcd0c2a
@ -2,10 +2,13 @@
|
||||
|
||||
namespace Slovocast\Domain\Entity;
|
||||
|
||||
use Slovocast\Domain\Entity;
|
||||
|
||||
class Channel
|
||||
{
|
||||
use Entity;
|
||||
|
||||
public function __construct(
|
||||
private readonly ?int $id,
|
||||
private string $name,
|
||||
private ?string $description = '',
|
||||
private ?string $link = '',
|
||||
@ -45,8 +48,7 @@ class Channel
|
||||
*/
|
||||
public static function fromArray(array $props): Channel
|
||||
{
|
||||
return self(
|
||||
$props['id'] ?? null,
|
||||
$channel = new self(
|
||||
$props['name'],
|
||||
$props['description'] ?? '',
|
||||
$props['link'] ?? '',
|
||||
@ -54,5 +56,19 @@ class Channel
|
||||
$props['copyright'] ?? '',
|
||||
$props['explicit'] ?? false
|
||||
);
|
||||
|
||||
if ($props['id']) {
|
||||
$channel->setId($props['id']);
|
||||
}
|
||||
|
||||
if ($props['createdAt']) {
|
||||
$channel->setCreatedAt($props['createdAt']);
|
||||
}
|
||||
|
||||
if ($props['updatedAt']) {
|
||||
$channel->setUpdatedAt($props['updatedAt']);
|
||||
}
|
||||
|
||||
return $channel;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user