Generated CRUD operations via Gii, added image upload functionality to the article. After that, for some reason, the removal of articles stopped working.
Here is the removal
public function actionDelete($id) { $this->findModel($id)->delete(); return $this->redirect(['index']); } as far as I could understand, findModel () does not work in the actionDelete method (drove everything into if, redirect did not pass). I could not find out the reason. here is findModel
protected function findModel($id) { if (($model = Article::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException('The requested page does not exist.'); } Here are the logs:
2019-02-06 22:49:04 [127.0.0.1][-][b1h7sqlc3rrjq5on8tokk5iq5g1p629m][error][yii\web\HttpException:404] exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "uploads/c8792d9548210f5455f395cdc73386f3.png".' in D:\ospanel\OSPanel\domains\localhost\footblog\vendor\yiisoft\yii2\base\Module.php:537 Stack trace: #0 D:\ospanel\OSPanel\domains\localhost\footblog\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction('uploads/c8792d9...', Array) #1 D:\ospanel\OSPanel\domains\localhost\footblog\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yi i\web\Request)) #2 D:\ospanel\OSPanel\domains\localhost\footblog\web\index.php(12): yii\base\Application->run() #3 {main} Next exception 'yii\web\NotFoundHttpException' with message 'Page not found.' in D:\ospanel\OSPanel\domains\localhost\footblog\vendor\yiisoft\yii2\web\Application.php:115 Stack trace: #0 D:\ospanel\OSPanel\domains\localhost\footblog\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request)) #1 D:\ospanel\OSPanel\domains\localhost\footblog\web\index.php(12): yii\base\Application->run() #2 {main} 2019-02-06 22:49:04 [127.0.0.1][-][b1h7sqlc3rrjq5on8tokk5iq5g1p629m][info][application] $_GET = [] $_POST = [] $_FILES = [] $_COOKIE = [ 'PHPSESSID' => 'b1h7sqlc3rrjq5on8tokk5iq5g1p629m' '_csrf' => 'a83c3e44210e8a2e85885e631b6a0ac853ccbcaf0b62a4a21160636938f7ebe8a:2:{i:0;s:5:\"_csrf\";i:1;s:32:\"bUvzAuOr6NyocoDZlb2VFCGF07-HT68H\";}' I ask to help with a solution of a problem or to prompt where to look for an error.
upd just in case, add pictures action:
public function actionAddImage($id) { $model = new ImageUpLoad; if(Yii::$app->request->isPost) { $article = $this->findModel($id); $file = UploadedFile::getInstance($model, 'image'); //$model->uploadFile($file); if($article->saveImage($model->uploadFile($file, $article->image))) { return $this->redirect(['view', 'id'=>$article->id]); } } return $this->render('image', ['model'=>$model]); } In the base of the record remain