| @@ 26-35 (lines=10) @@ | ||
| 23 | * |
|
| 24 | * @return bool |
|
| 25 | */ |
|
| 26 | public static function create(array $data): bool |
|
| 27 | { |
|
| 28 | $article = new Article; |
|
| 29 | $article->title = $data['title']; |
|
| 30 | $article->category_id = $data['category_id']; |
|
| 31 | $article->is_display = isset($data['is_display']) ? true : false; |
|
| 32 | $article->content = $data['content']; |
|
| 33 | ||
| 34 | return $article->save(); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Update the article data and save it. |
|
| @@ 44-52 (lines=9) @@ | ||
| 41 | * |
|
| 42 | * @return bool |
|
| 43 | */ |
|
| 44 | public static function update(array $data, Article $article): bool |
|
| 45 | { |
|
| 46 | $article->title = $data['title']; |
|
| 47 | $article->category_id = $data['category_id']; |
|
| 48 | $article->is_display = isset($data['is_display']) ? true : false; |
|
| 49 | $article->content = $data['content']; |
|
| 50 | ||
| 51 | return $article->save(); |
|
| 52 | } |
|
| 53 | } |
|
| 54 | ||