Blame view

app/Queries/Article/Article.php 1.99 KB
e77200db5   nologostudio.ru   Initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  <?php
  
  namespace FootyRoom\Queries\Article;
  
  use Illuminate\Support\Facades\URL;
  use Illuminate\Support\Str;
  
  class Article
  {
      /** @var string */
      protected $id;
  
      /** @var string */
      protected $url;
  
      /** @var string */
      protected $thumbnailUrl;
  
      /** @var string */
      protected $title;
  
      /** @var string */
      protected $publisher;
  
      /** @var string */
      protected $content;
  
      /** @var string */
      protected $html;
  
      /** @var string Can be either 'published' or 'draft'. */
      protected $status;
  
      /** @var bool */
      protected $isFeatured;
  
      public function getId(): string
      {
          return $this->id;
      }
  
      public function getUrl(): string
      {
          return $this->url ?? URL::route('showArticle', [
              'id' => $this->getId(),
              'slug' => $this->getSlug(),
          ]);
      }
  
      public function getSlug(): string
      {
          return Str::slug($this->getTitle());
      }
  
      public function getThumbnailUrl(): string
      {
          return $this->thumbnailUrl;
      }
  
      public function getTitle(): string
      {
          return $this->title;
      }
  
      public function getContent(): ?string
      {
          return $this->content;
      }
  
      public function getHtml(): ?string
      {
          return $this->html;
      }
  
      public function getPublisher(): ?string
      {
          return $this->publisher;
      }
  
      public function getStatus(): string
      {
          return $this->status;
      }
  
      public function getIsFeatured(): bool
      {
          return $this->isFeatured;
      }
  
      public function toArray(): array
      {
          return [
              'id' => $this->getId(),
              'title' => $this->getTitle(),
              'content' => $this->getContent(),
              'html' => $this->getHtml(),
              'thumbnailUrl' => $this->getThumbnailUrl(),
              'url' => $this->getUrl(),
              'publisher' => $this->getPublisher(),
              'status' => $this->getStatus(),
              'isFeatured' => $this->getIsFeatured(),
          ];
      }
  }