1 | <?php |
||
8 | class ArticlePresenter extends Presenter |
||
9 | { |
||
10 | /** |
||
11 | * Edit link of the article. |
||
12 | * |
||
13 | * @return string |
||
14 | */ |
||
15 | public function editLink() |
||
19 | |||
20 | /** |
||
21 | * Date created. |
||
22 | * |
||
23 | * @return string |
||
24 | */ |
||
25 | public function dateCreated() |
||
29 | |||
30 | /** |
||
31 | * Date published. |
||
32 | * |
||
33 | * @return mixed |
||
34 | */ |
||
35 | public function datePublished() |
||
36 | { |
||
37 | return $this->entity->created_at->diffForHumans(); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Date modified. |
||
42 | * |
||
43 | * @return mixed |
||
44 | */ |
||
45 | public function dateModified() |
||
46 | { |
||
47 | return $this->entity->updated_at->format('d M Y'); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Publication state. |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | public function published() |
||
62 | |||
63 | /** |
||
64 | * Get article's author name. |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function author() |
||
74 | |||
75 | /** |
||
76 | * Get the article's content. |
||
77 | * |
||
78 | * @return string |
||
79 | * @throws \Exception |
||
80 | * @throws \Throwable |
||
81 | */ |
||
82 | public function content() |
||
88 | |||
89 | /** |
||
90 | * Get the article's title. |
||
91 | * |
||
92 | * @return mixed |
||
93 | */ |
||
94 | public function title() |
||
95 | { |
||
96 | $heading = null; |
||
97 | if (session()->has('active_menu')) { |
||
98 | $heading = session('active_menu')->param('page_heading'); |
||
99 | } |
||
100 | |||
101 | return $heading ? $heading : $this->entity->title; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Get article's slug. |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | public function slug() |
||
113 | } |
||
114 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: