Exemplo n.º 1
0
 protected function findBerita($id)
 {
     if (($model = Berita::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Berita::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id_berita' => $this->id_berita, 'tgl_input' => $this->tgl_input]);
     $query->andFilterWhere(['like', 'judul', $this->judul])->andFilterWhere(['like', 'isi_berita', $this->isi_berita])->andFilterWhere(['like', 'nip', $this->nip]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 public function berita($id)
 {
     $this->data['title'] = 'Berita';
     $this->data['beritalist'] = Models\Berita::find($id);
     return view('front.berita', $this->data);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // File Delete By Agus Cahyono
     $file_lama = DB::table('tbl_berita')->select('gambar')->where('id_berita', $id)->first();
     File::delete('upload/berita/' . $file_lama->gambar);
     $data = Berita::find($id);
     if ($data->delete()) {
         return response()->json(array('success' => TRUE, 'msg' => 'Data Berhasil Dihapus'));
     }
 }
Exemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getNip0()
 {
     return $this->hasOne(Berita::className(), ['nip' => 'nip']);
 }
Exemplo n.º 6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $data = Berita::find($id);
     if ($data->delete()) {
         return response()->json(array('success' => TRUE, 'msg' => 'Data Berhasil Dihapus'));
     }
 }
Exemplo n.º 7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $berita = Berita::find($id);
     if ($berita->feature_image) {
         $fotolama = $berita->foto;
         $filepath = public_path() . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $berita->feature_image;
         try {
             File::delete($filepath);
         } catch (FileNotFoundException $e) {
         }
     }
     $berita->delete();
     return Redirect::to('admin/berita');
 }
Exemplo n.º 8
0
 public function berita($slug)
 {
     $berita_detail = Models\Berita::where('slug_berita', $slug)->first();
     $this->data['title'] = $berita_detail->judul_berita;
     $this->data['beritalist'] = $berita_detail;
     $this->data['desc'] = substr($berita_detail->isi, 0, 200) . '...';
     $this->data['key'] = $berita_detail->judul_berita;
     return view('bappeda.berita_detail', $this->data);
 }