@@ 124-136 (lines=13) @@ | ||
121 | * @return Post the loaded model |
|
122 | * @throws NotFoundHttpException if the model cannot be found |
|
123 | */ |
|
124 | protected function findModel($id) |
|
125 | { |
|
126 | $model = Post::find() |
|
127 | ->andWhere(['id' => $id, 'status' => 'publish']) |
|
128 | ->andWhere(['<=', 'date', date('Y-m-d H:i:s')]) |
|
129 | ->one(); |
|
130 | ||
131 | if ($model) { |
|
132 | return $model; |
|
133 | } |
|
134 | ||
135 | throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.')); |
|
136 | } |
|
137 | ||
138 | ||
139 | /** |
|
@@ 147-159 (lines=13) @@ | ||
144 | * @return Post the loaded model |
|
145 | * @throws NotFoundHttpException if the model cannot be found |
|
146 | */ |
|
147 | protected function findModelBySlug($slug) |
|
148 | { |
|
149 | $model = Post::find() |
|
150 | ->andWhere(['slug' => $slug, 'status' => 'publish']) |
|
151 | ->andWhere(['<=', 'date', date('Y-m-d H:i:s')]) |
|
152 | ->one(); |
|
153 | ||
154 | if ($model) { |
|
155 | return $model; |
|
156 | } |
|
157 | ||
158 | throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.')); |
|
159 | } |
|
160 | ||
161 | /** |
|
162 | * Finds the Post model based on its primary key value. |