home
/
zktecojo
/
public_html
/
app
/
controllers
/
admin
➕ New
📤 Upload
✎ Editing:
NewsController.php
← Back
<?php class NewsController extends BaseController { public function __construct(){ $this->is_admin_login(); parent::__construct(); } public function index(){ if(Input::get('btnsubmitpriority')==true){ if(@$_POST['prd_priority']==true){ foreach(@$_POST['prd_priority'] as $getid=>$value){ $this->dataupdate['news_priority']=$value; DB::table('news')->where('news_id', '=',$getid)->update($this->dataupdate); $this->data['messages'] =$this->custom_message('news priority updated successfully','success'); } $priority_update=1; } } $this->data['newsList']= DB::table('news') ->where('news_type','=',1) ->orderBy('news_priority','asc') ->get(); // dd($this->data['newsList']); return View::make('admin.news.list',$this->data); } public function create(){ $this->data['messages']=''; if(Input::get('createbtnsubmit')){ $maxpriority=DB::table('news')->max('news_priority'); // $this->data = Input::get(); // echo "DD";exit(); // $filename = $this->resize_and_crop_image('news_image_name','assets/uploads/news',array(array('width'=>555,'height'=>303,'folder'=>'large'),array('width'=>263,'height'=>301,'folder'=>'small')),null); $insertDatas = array( 'news_title' =>Input::get('news_title'), 'news_title_arabic' =>Input::get('news_title_ar'), 'news_short_content' =>Input::get('news_short_content'), 'news_short_content_arabic' =>Input::get('news_short_content_ar'), 'news_content' =>Input::get('news_content'), 'news_content_arabic' =>Input::get('news_content_ar'), 'news_datetime' =>date('Y-m-d'), 'news_alias' =>Str::slug(Input::get('news_title'))."-".date('Y-m-d'), 'news_status' =>Input::get('news_status'), 'news_priority' =>$maxpriority+1, 'news_publish_date' =>date('Y-m-d',strtotime(Input::get('news_publish_date'))), 'news_type' =>1, ); $file = Input::file('news_image_name'); if($file){ $filename = $this->resize_and_crop_image('news_image_name','assets/uploads/news',array(array('width'=>450,'height'=>310,'folder'=>'recomended'),array('width'=>180,'height'=>191,'folder'=>'small')),null); $insertDatas['news_image_name'] = $filename; } // end file DB::table('news')->insert($insertDatas); $this->data['messages'] =$this->custom_message('News Added Successfully','success'); } // $this->data['newsMenuList'] = DB::table('menus')->where('menu_status','=',1)->get(); return View::make('admin.news.add',$this->data); } public function edit($editID){ if(empty($editID)) { return Redirect::to('admin/news');} $this->data['messages'] =''; if(Input::get('updatebtnsubmit')){ $datasupdate = array( 'news_title' =>Input::get('news_title'), 'news_title_arabic' =>Input::get('news_title_ar'), 'news_short_content' =>Input::get('news_short_content'), 'news_short_content_arabic' =>Input::get('news_short_content_ar'), 'news_content' =>Input::get('news_content'), 'news_content_arabic' =>Input::get('news_content_ar'), 'news_status' =>Input::get('news_status'), 'news_alias' =>Str::slug(Input::get('news_title'))."-".date('Y-m-d'), //'news_priority' =>Input::get('news_priority'), 'news_publish_date' =>date('Y-m-d',strtotime(Input::get('news_publish_date'))), 'news_type' =>1, ); $file = Input::file('news_image_name'); if($file){ $filename = $this->resize_and_crop_image('news_image_name','assets/uploads/news',array(array('width'=>450,'height'=>310,'folder'=>'recomended'),array('width'=>180,'height'=>191,'folder'=>'small')),Input::get('news_image_old_name')); $datasupdate['news_image_name'] = $filename; } // end file DB::table('news')->where('news_id', '=',$editID)->update($datasupdate); $this->data['messages'] = $this->custom_message('News updated successfully','success'); } $this->data['rsnews'] = DB::table('news')->where('news_id','=',$editID)->first(); return View::make('admin.news.edit',$this->data); } public function changestatus($statusID,$currentStatus){ $currentStatus = ($currentStatus==0)?1:0; $currentStatusdatas = array("news_status"=>$currentStatus); DB::table('news')->where('news_id', '=',$statusID)->update($currentStatusdatas); return Redirect::to('admin/news')->with('flash_error','deleted'); } public function delete($deleteID){ if(empty($deleteID)) { return Redirect::to('admin/news');} $newsList = DB::table('news')->where('news_id','=',$deleteID)->get(); /* foreach($newsList as $news){ if(File::exists('assets/uploads/news/'.$news->news_image_name)){ File::delete('assets/uploads/news/'.$news->news_image_name); File::delete('assets/uploads/news/small/'.$news->news_image_name); File::delete('assets/uploads/news/large/'.$news->news_image_name); } } */ DB::table('news')->where('news_id', '=',$deleteID)->delete(); $this->data['messages'] = $this->custom_message('Deleted Successfully','success'); return Redirect::to('admin/news')->with('flash_error','deleted'); } //LIFE AT FNG public function news_letter_index(){ if(Input::get('btnsubmitpriority')==true){ if(@$_POST['prd_priority']==true){ foreach(@$_POST['prd_priority'] as $getid=>$value){ $this->dataupdate['nl_priority']=$value; DB::table('news_letter')->where('nl_id', '=',$getid)->update($this->dataupdate); $this->data['messages'] =$this->custom_message('news letter priority updated successfully','success'); } $priority_update=1; } } $this->data['newsList']= DB::table('news_letter') ->orderBy('nl_priority','asc') ->get(); // dd($this->data['newsList']); return View::make('admin.newsletter.list',$this->data); } public function news_letter_create(){ $this->data['messages']=''; if(Input::get('createbtnsubmit')){ // $this->data = Input::get(); // echo "DD";exit(); // $filename = $this->resize_and_crop_image('news_image_name','assets/uploads/news',array(array('width'=>555,'height'=>303,'folder'=>'large'),array('width'=>263,'height'=>301,'folder'=>'small')),null); $maxpriority=DB::table('news_letter')->max('nl_priority'); $insertDatas = array( 'nl_name' =>Input::get('nl_title'), 'nl_name_arabic' =>Input::get('nl_title_ar'), 'nl_link' =>Input::get('nl_link'), 'nl_status' =>Input::get('nl_status'), 'nl_priority' =>$maxpriority+1, 'nl_publish_date' =>date('Y-m-d',strtotime(Input::get('nl_publish_date'))), ); $file = Input::file('nl_image'); $pdfFile = Input::file('nl_pdf'); if($file){ $filename = $this->resize_and_crop_image('nl_image','assets/uploads/newsletter',array(array('width'=>376,'height'=>300,'folder'=>'recomended'),array('width'=>73,'height'=>45,'folder'=>'small')),null); $insertDatas['nl_image'] = $filename; } // end file if($pdfFile){ $filepdf = $this->pdf_upload($pdfFile,'assets/uploads/newsletter/pdf',Input::get('nl_pdf')); $insertDatas['nl_pdf'] = $filepdf; } // end file DB::table('news_letter')->insert($insertDatas); $this->data['messages'] =$this->custom_message('News letter Added Successfully','success'); } // $this->data['newsMenuList'] = DB::table('menus')->where('menu_status','=',1)->get(); return View::make('admin.newsletter.add',$this->data); } public function news_letter_edit($editID){ if(empty($editID)) { return Redirect::to('admin/news-letter');} $this->data['messages'] =''; if(Input::get('updatebtnsubmit')){ $datasupdate = array( 'nl_name' =>Input::get('nl_title'), 'nl_name_arabic' =>Input::get('nl_title_ar'), 'nl_link' =>Input::get('nl_link'), 'nl_status' =>Input::get('nl_status'), //'nl_priority' =>Input::get('nl_priority'), 'nl_publish_date' =>date('Y-m-d',strtotime(Input::get('nl_publish_date'))), ); $file = Input::file('nl_image'); if($file){ $filename = $this->resize_and_crop_image('nl_image','assets/uploads/newsletter',array(array('width'=>376,'height'=>300,'folder'=>'recomended'),array('width'=>73,'height'=>45,'folder'=>'small')),Input::get('nl_image_old_name')); $datasupdate['nl_image'] = $filename; } // end file DB::table('news_letter')->where('nl_id', '=',$editID)->update($datasupdate); $this->data['messages'] = $this->custom_message('News letter updated successfully','success'); } $this->data['rsnewsletter'] = DB::table('news_letter')->where('nl_id','=',$editID)->first(); return View::make('admin.newsletter.edit',$this->data); } public function news_letter_changestatus($statusID,$currentStatus){ $currentStatus = ($currentStatus==0)?1:0; $currentStatusdatas = array("nl_status"=>$currentStatus); DB::table('news_letter')->where('nl_id', '=',$statusID)->update($currentStatusdatas); return Redirect::to('admin/news-letter')->with('flash_error','deleted'); } public function news_letter_delete($deleteID){ if(empty($deleteID)) { return Redirect::to('admin/nl_letter_at_fng');} $newsList = DB::table('news_letter')->where('nl_id','=',$deleteID)->get(); /* foreach($newsList as $news){ if(File::exists('assets/uploads/news/'.$news->nl_image_name)){ File::delete('assets/uploads/news/'.$news->nl_image_name); File::delete('assets/uploads/news/small/'.$news->nl_image_name); File::delete('assets/uploads/news/large/'.$news->nl_image_name); } } */ DB::table('news_letter')->where('nl_id', '=',$deleteID)->delete(); $this->data['messages'] = $this->custom_message('Deleted Successfully','success'); return Redirect::to('admin/news-letter')->with('flash_error','deleted'); } }
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel