update deploy
This commit is contained in:
92
app/DTOs/CourseData.php
Normal file
92
app/DTOs/CourseData.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
class CourseData
|
||||
{
|
||||
/**
|
||||
* @param list<string>|null $includes
|
||||
* @param list<string>|null $requirements
|
||||
* @param list<string>|null $scope
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly int $categoryId,
|
||||
public readonly string $slug,
|
||||
public readonly string $title,
|
||||
public readonly string $desc,
|
||||
public readonly string $longDesc,
|
||||
public readonly string $duration,
|
||||
public readonly ?string $sub = null,
|
||||
public readonly int $students = 0,
|
||||
public readonly float $rating = 5.0,
|
||||
public readonly ?string $badge = null,
|
||||
public readonly ?string $image = null,
|
||||
public readonly ?string $price = null,
|
||||
public readonly ?array $includes = null,
|
||||
public readonly ?array $requirements = null,
|
||||
public readonly ?string $metaTitle = null,
|
||||
public readonly ?string $metaDescription = null,
|
||||
public readonly ?array $scope = null,
|
||||
public readonly ?string $standard = null,
|
||||
public readonly ?string $language = null,
|
||||
public readonly ?string $location = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
return new self(
|
||||
categoryId: $data['category_id'],
|
||||
slug: $data['slug'],
|
||||
title: $data['title'],
|
||||
desc: $data['desc'],
|
||||
longDesc: $data['long_desc'],
|
||||
duration: $data['duration'],
|
||||
sub: $data['sub'] ?? null,
|
||||
students: $data['students'] ?? 0,
|
||||
rating: $data['rating'] ?? 5.0,
|
||||
badge: $data['badge'] ?? null,
|
||||
image: $data['image'] ?? null,
|
||||
price: $data['price'] ?? null,
|
||||
includes: $data['includes'] ?? null,
|
||||
requirements: $data['requirements'] ?? null,
|
||||
metaTitle: $data['meta_title'] ?? null,
|
||||
metaDescription: $data['meta_description'] ?? null,
|
||||
scope: $data['scope'] ?? null,
|
||||
standard: $data['standard'] ?? null,
|
||||
language: $data['language'] ?? null,
|
||||
location: $data['location'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'category_id' => $this->categoryId,
|
||||
'slug' => $this->slug,
|
||||
'title' => $this->title,
|
||||
'sub' => $this->sub,
|
||||
'desc' => $this->desc,
|
||||
'long_desc' => $this->longDesc,
|
||||
'duration' => $this->duration,
|
||||
'students' => $this->students,
|
||||
'rating' => $this->rating,
|
||||
'badge' => $this->badge,
|
||||
'image' => $this->image,
|
||||
'price' => $this->price,
|
||||
'includes' => $this->includes,
|
||||
'requirements' => $this->requirements,
|
||||
'meta_title' => $this->metaTitle,
|
||||
'meta_description' => $this->metaDescription,
|
||||
'scope' => $this->scope,
|
||||
'standard' => $this->standard,
|
||||
'language' => $this->language,
|
||||
'location' => $this->location,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user