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.
 
 
 
 
 

32 lines
573 B

<?php
namespace app\controllers;
use Yii;
use app\models\Post;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
class PostController extends Controller{
public function actionView($id){
$model = Post::findOne($id);
if( $model === null){
throw new NotFoundHttpException;
}
return $this->render('view', [
'model' => $model,
]);
}
public function actionCreate(){
$model = new Post;
if($model->load(Yii::$app->request->post())&& $model->save()){
}
}
}
?>