1 | <?php |
||
10 | class LaravelPages |
||
11 | { |
||
12 | /** |
||
13 | * Checks if a page exists in the database. |
||
14 | * |
||
15 | * @param string $slug The slug to search for in the database. |
||
16 | * @return bool Returns true if the page exists, false otherwise. |
||
17 | **/ |
||
18 | public function pageExists($slug) |
||
28 | |||
29 | /** |
||
30 | * Gets all the data of the page from the database, based on the slug. |
||
31 | * |
||
32 | * @param string $slug The slug to search for in the database. |
||
33 | * @param bool $trashed Include trashed (soft deleted) pages? |
||
34 | * @return array The data such as title, content and publishing date in an array. |
||
35 | **/ |
||
36 | public function getPage($slug, $trashed = false) |
||
37 | { |
||
38 | if ($trashed) { |
||
39 | return Page::withTrashed()->where('page_slug', '=', $slug)->first(); |
||
40 | } |
||
41 | |||
42 | return Page::where('page_slug', '=', $slug)->first(); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Gets all the data of the page from the database, based on the ID. |
||
47 | * |
||
48 | * @param string $id The id to search for in the database. |
||
49 | * @param bool $trashed Include trashed (soft deleted) pages? |
||
50 | * @return array The data such as title, content and publishing date in an array. |
||
51 | **/ |
||
52 | public function getPageById($id, $trashed = false) |
||
60 | |||
61 | /** |
||
62 | * Gets only the id of the page that belongs to the given slug. |
||
63 | * |
||
64 | * @param string $slug The slug to search for in the database. |
||
65 | * @return int The id of the page. |
||
66 | **/ |
||
67 | public function getPageId($slug) |
||
73 | |||
74 | /** |
||
75 | * Creates a slug. |
||
76 | * |
||
77 | * @param string $slugify_this The piece of text to transform into a slug. |
||
78 | * @return string A safe slug. |
||
79 | **/ |
||
80 | public function createSlug($slugify_this) |
||
84 | |||
85 | /** |
||
86 | * Adds a page to the database. |
||
87 | * |
||
88 | * @param string $page_title The title of the page. |
||
89 | * @param text $page_content The content of the page. |
||
90 | * @param string|null $custom_slug A custom slug, if not provided the page title is slugified. |
||
91 | * @return void The page is saved. |
||
92 | **/ |
||
93 | public function addPage($page_title, $page_content, $custom_slug = null) |
||
106 | |||
107 | /** |
||
108 | * Updates an existing page. |
||
109 | * |
||
110 | * @param int $page_id The id of the existing page. |
||
111 | * @param string $page_title The (changed) title of the page. |
||
112 | * @param text $page_content The (changed) content of the page. |
||
113 | * @param string $page_slug The (changed) slug of the page. |
||
114 | * @return void The page is saved. |
||
115 | **/ |
||
116 | public function updatePage($page_id, $page_title, $page_content, $page_slug) |
||
126 | |||
127 | /** |
||
128 | * Deletes a page, possibly even with force. |
||
129 | * |
||
130 | * If $forceDelete is set to true, the page will be removed from the database (for ever). |
||
131 | * If kept at false, the page will get a 'deleted_at' value and does not show until restored. |
||
132 | * |
||
133 | * @param int $page_id The id of the page. |
||
134 | * @param bool $forceDelete Whether to really remove the page from the database or not. |
||
135 | * @return void The page is deleted. |
||
136 | **/ |
||
137 | public function deletePage($page_id, $forceDelete = false) |
||
147 | |||
148 | /** |
||
149 | * Restores a previously soft-deleted page. |
||
150 | * |
||
151 | * The id of the page can be retrieved with the getPageId() function. |
||
152 | * |
||
153 | * @param int $page_id The id of the page. |
||
154 | * @return void The page is back! |
||
155 | **/ |
||
156 | public function restorePage($page_id) |
||
162 | } |
||
163 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.