Exemplo n.º 1
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.º 2
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.º 4
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.º 5
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');
 }