AdminLogController.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace backend\controllers;
  3. use common\models\AdminLog;
  4. use yii\data\ActiveDataProvider;
  5. use yii\filters\VerbFilter;
  6. use yii\web\Controller;
  7. use yii\web\NotFoundHttpException;
  8. /**
  9. * AdminLogController implements the CRUD actions for AdminLog model.
  10. */
  11. class AdminLogController extends Controller
  12. {
  13. public function behaviors()
  14. {
  15. return [
  16. 'verbs' => [
  17. 'class' => VerbFilter::className(),
  18. 'actions' => [
  19. 'delete' => ['post'],
  20. ],
  21. ],
  22. ];
  23. }
  24. /**
  25. * Lists all AdminLog models.
  26. * @return mixed
  27. */
  28. public function actionIndex()
  29. {
  30. $dataProvider = new ActiveDataProvider([
  31. 'query' => AdminLog::find(),
  32. 'sort' => [
  33. 'defaultOrder' => [
  34. 'id' => SORT_DESC
  35. ]
  36. ]
  37. ]);
  38. return $this->render('index', [
  39. 'dataProvider' => $dataProvider,
  40. ]);
  41. }
  42. /**
  43. * Displays a single AdminLog model.
  44. * @param integer $id
  45. * @return mixed
  46. */
  47. public function actionView($id)
  48. {
  49. return $this->render('view', [
  50. 'model' => $this->findModel($id),
  51. ]);
  52. }
  53. /**
  54. * Finds the AdminLog model based on its primary key value.
  55. * If the model is not found, a 404 HTTP exception will be thrown.
  56. * @param integer $id
  57. * @return AdminLog the loaded model
  58. * @throws NotFoundHttpException if the model cannot be found
  59. */
  60. protected function findModel($id)
  61. {
  62. if (($model = AdminLog::findOne($id)) !== null) {
  63. return $model;
  64. } else {
  65. throw new NotFoundHttpException('The requested page does not exist.');
  66. }
  67. }
  68. }