<?php
namespace common\modules\blog\controllers;

use common\models\Media;
use common\modules\blog\models\Article;
use yii\web\Controller;
use yii\web\UploadedFile;

class MediaController extends Controller
{
    public function actionIndex()
    {
        $model = new Media();
        if(\Yii::$app->request->isPost) {
            $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
            if($model->upload()) {
                return true;
            } else {
                return false;
            }
        }
        return $this->render('index', ['model' => $model]);
    }

    public function actionCreate()
    {

    }

    public function actionUpdate($id)
    {

    }

    public function actionDelete($id)
    {
        $model = Media::findOne($id);
        return $model->delete();
    }

    protected function findModel($id)
    {

    }
}
