View difference between Paste ID: dhE19xg9 and dNbEfVCG
SHOW: | | - or go back to the newest paste.
1
<?php
2
3
namespace backend\controllers;
4
5
use Yii;
6
use backend\models\Jurusan;
7
use yii\data\ActiveDataProvider;
8
use yii\web\Controller;
9
use yii\web\NotFoundHttpException;
10
use yii\filters\VerbFilter;
11
12
/**
13
 * JurusanController implements the CRUD actions for Jurusan model.
14
 */
15
class JurusanController extends Controller
16
{
17
    public function behaviors()
18
    {
19
        return [
20
            'verbs' => [
21
                'class' => VerbFilter::className(),
22
                'actions' => [
23
                    'delete' => ['post'],
24
                ],
25
            ],
26
        ];
27
    }
28
29
    /**
30
     * Lists all Jurusan models.
31
     * @return mixed
32
     */
33
    public function actionIndex()
34
    {
35
		// mengambil data di database (model)
36
        $dataProvider = new ActiveDataProvider([
37
            'query' => Jurusan::find(),
38
        ]);
39
40
		// mengirim data ke views index.php
41
        return $this->render('index', [
42
            'dataProvider' => $dataProvider,
43
        ]);
44
    }
45
46
    /**
47
     * Displays a single Jurusan model.
48
     * @param integer $id
49
     * @return mixed
50
     */
51
    public function actionView($id)
52
    {
53
        return $this->render('view', [
54
            'model' => $this->findModel($id),
55
        ]);
56
    }
57
58
    /**
59
     * Creates a new Jurusan model.
60
     * If creation is successful, the browser will be redirected to the 'view' page.
61
     * @return mixed
62
     */
63
    public function actionCreate()
64
    {
65
        $model = new Jurusan();
66
67
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
68
            return $this->redirect(['view', 'id' => $model->kode_jurusan]);
69
        } else {
70
            return $this->render('create', [
71
                'model' => $model,
72
            ]);
73
        }
74
    }
75
76
    /**
77
     * Updates an existing Jurusan model.
78
     * If update is successful, the browser will be redirected to the 'view' page.
79
     * @param integer $id
80
     * @return mixed
81
     */
82
    public function actionUpdate($id)
83
    {
84
        $model = $this->findModel($id);
85
86
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
87
            return $this->redirect(['view', 'id' => $model->kode_jurusan]);
88
        } else {
89
            return $this->render('update', [
90
                'model' => $model,
91
            ]);
92
        }
93
    }
94
95
    /**
96
     * Deletes an existing Jurusan model.
97
     * If deletion is successful, the browser will be redirected to the 'index' page.
98
     * @param integer $id
99
     * @return mixed
100
     */
101
    public function actionDelete($id)
102
    {
103
        $this->findModel($id)->delete();
104
105
        return $this->redirect(['index']);
106
    }
107
108
    /**
109
     * Finds the Jurusan model based on its primary key value.
110
     * If the model is not found, a 404 HTTP exception will be thrown.
111
     * @param integer $id
112
     * @return Jurusan the loaded model
113
     * @throws NotFoundHttpException if the model cannot be found
114
     */
115
    protected function findModel($id)
116
    {
117
        if (($model = Jurusan::findOne($id)) !== null) {
118
            return $model;
119
        } else {
120
            throw new NotFoundHttpException('The requested page does not exist.');
121
        }
122
    }
123
    
124-
    // aksi yang dibuat
124+
    // aksi yang ditambahkan
125
    public function actionUcapsalam()
126
    {
127-
      $ucapan = "Hallo Dunia";
127+
	$ucapan = "Hallo Dunia";
128
129-
      echo $ucapan;
129+
	return $this->render('salam',[
130
		'ucapanSalam' => $ucapan
131
	]);
132
    }
133
}