You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
573 B

8 months ago
  1. <?php
  2. namespace app\controllers;
  3. use Yii;
  4. use app\models\Post;
  5. use yii\web\Controller;
  6. use yii\web\NotFoundHttpException;
  7. class PostController extends Controller{
  8. public function actionView($id){
  9. $model = Post::findOne($id);
  10. if( $model === null){
  11. throw new NotFoundHttpException;
  12. }
  13. return $this->render('view', [
  14. 'model' => $model,
  15. ]);
  16. }
  17. public function actionCreate(){
  18. $model = new Post;
  19. if($model->load(Yii::$app->request->post())&& $model->save()){
  20. }
  21. }
  22. }
  23. ?>