home
/
zktecojo
/
public_html
/
app
/
controllers
/
admin
➕ New
📤 Upload
✎ Editing:
GalleryController.php
← Back
<?php class GalleryController extends BaseController { public function __construct(){ $this->is_admin_login(); parent::__construct(); } public function index(){ $this->data['teamList']= DB::table('team') ->where('home_page_section','=',1) ->orderBy('team_priority','asc') ->get(); // dd($this->data['teamList']); return View::make('admin.team.list',$this->data); } public function image_gallery(){ $this->data['categoryList'] = DB::Table('category_master') ->get(); return View::make('admin.gallery.add',$this->data); } public function video_gallery(){ if(Input::get('createbtnsubmit')){ DB::table('video_gallery')->delete(); $links = Input::get('shows_link'); foreach($links as $url){ if(!empty($url)){ parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars ); if(!empty($my_array_of_vars['v'])){ $insertDatas = array( 'vg_video_link' =>$url, 'vg_youtube_id' =>$my_array_of_vars['v'], 'vg_status' =>2, 'vg_date' =>date('Y-m-d'), 'vg_status' =>1 ); DB::table('video_gallery')->insertGetId($insertDatas); }else{ $this->data['message'] = 'Invalid Youtube URL'; } } } } $this->data['videoList'] = DB::table('video_gallery')->get(); return View::make('admin.gallery.addVideo',$this->data); } public function delete_video_gallery($deleteID){ if(empty($deleteID)) { return Redirect::to('admin/video-gallery');} DB::table('video_gallery')->where('vg_id', '=',$deleteID)->delete(); $this->data['messages'] = $this->custom_message('Deleted Successfully','success'); return Redirect::to('admin/video-gallery')->with('flash_error','deleted'); } public function create_category(){ // echo "DD";exit(); // echo Input::get('category_en');exit(); $validator = Validator::make( array( 'category_en' => Input::get('category_en'), // 'category_ar' => Input::get('category_ar'), ), array( 'category_en' => 'required', )); if($validator->fails()){ return Response::json(array('status'=>false)); } $insertDatas = array( 'category_name'=>Input::get('category_en'), 'category_slug'=>Str::slug(Input::get('category_en')), 'category_name_arabic'=>Input::get('category_ar'), ); $newID = DB::table('category_master')->insertGetId($insertDatas); return Response::json(array('status'=>true,'category_id'=>$newID,'category_name'=>Input::get('category_en'))); } public function get_old_files(){ $categoryID = Input::get('categoryID'); $oldFiles = array(); if(!empty($categoryID)){ // echo json_encode(array('status'=>false,'message'=>'Please select a parent.')); // exit(); $oldFiles = DB::table('gallery_images AS GI ') -> select(DB::raw('GI.*')) ->where('gallery_image_type','=',1) ->orderBy(DB::raw('GI.gallery_cat_id'),'DESC') ->get(); }else{ $oldFiles = DB::table('gallery_images AS GI ') -> select(DB::raw('GI.*')) ->where('gallery_image_type','=',1) ->orderBy(DB::raw('GI.gallery_cat_id'),'DESC') ->get(); } echo json_encode(array('status'=>true, 'gallery'=>$oldFiles)); exit(); } public function file_upload(){ if(Request::hasFile('file')){ // $parentID = $id; //Input::get('parentIDE'); $fileName = $this->resize_and_crop_image('file','assets/uploads/image_gallery/',array(array('width'=> 235,'height'=>156,'folder'=>'thumb'),array('width'=>322,'height'=>242,'folder'=>'small'),array('width'=> 600,'height'=>450,'folder'=>'large')),null); $insertDatas = array( 'gallery_cat_id' =>1, 'gallery_image_name' =>$fileName, 'gallery_image_type' =>1, 'gallery_image_date' =>date('Y-m-d H:i:s'), 'gallery_image_status' =>1 ); $id = DB::table('gallery_images')->insertGetId($insertDatas); $data = DB::table('gallery_images AS GI ') -> select(DB::raw('GI.*')) ->where('gallery_id','=',$id) ->where('gallery_image_type','=',1) ->first(); echo json_encode(array('status'=>true,'fileName'=>$data->gallery_image_name,'id'=>$data->gallery_id,'label'=>$data->gallery_label)); exit(); } } public function delete_gallery_image($id){ $imageDetail = DB::table('gallery_images') ->where('gallery_id','=',$id) ->first(); if(!empty($imageDetail)){ if(!empty($imageDetail->gallery_image_name) && File::exists('assets/uploads/image_gallery/'.$imageDetail->gallery_image_name) ){ File::delete('assets/uploads/image_gallery/'.$imageDetail->gallery_image_name); File::delete('assets/uploads/image_gallery/thumb/'.$imageDetail->gallery_image_name); File::delete('assets/uploads/image_gallery/small/'.$imageDetail->gallery_image_name); File::delete('assets/uploads/image_gallery/large/'.$imageDetail->gallery_image_name); DB::table('gallery_images')->where('gallery_id', '=', $id)->delete(); } } echo json_encode(array('status'=>true,'Message'=>'File Deleted')); } public function save_gallery_name(){ $id=Input::get('galid'); $galname=Input::get('galname'); if(!empty($id)){ DB::table('gallery_images')->where('gallery_id', '=',$id)->update(array('gallery_label'=>$galname)); } echo json_encode(array('status'=>true,'Message'=>'Name Updated')); } public function download_image($imageName){ if(!empty($imageName) && File::exists('assets/uploads/image_gallery/large/'.$imageName) ){ return Response::download('assets/uploads/image_gallery/'.$imageName, $imageName); } return Redirect::to('/admin/image-gallery'); } /************Client**************/ public function client_gallery(){ $this->data['categoryList'] = DB::Table('category_master') ->get(); return View::make('admin.gallery.add_client',$this->data); } public function get_client_old_files(){ $categoryID = Input::get('categoryID'); $oldFiles = array(); if(!empty($categoryID)){ // echo json_encode(array('status'=>false,'message'=>'Please select a parent.')); // exit(); $oldFiles = DB::table('gallery_images AS GI ') -> select(DB::raw('GI.*')) ->where('gallery_image_type','=',2) ->orderBy(DB::raw('GI.gallery_cat_id'),'DESC') ->get(); }else{ $oldFiles = DB::table('gallery_images AS GI ') -> select(DB::raw('GI.*')) ->where('gallery_image_type','=',2) ->orderBy(DB::raw('GI.gallery_cat_id'),'DESC') ->get(); } echo json_encode(array('status'=>true, 'gallery'=>$oldFiles)); exit(); } public function client_file_upload(){ if(Request::hasFile('file')){ // $parentID = $id; //Input::get('parentIDE'); $fileName = $this->resize_and_crop_image('file','assets/uploads/clients/',array(array('width'=> 235,'height'=>156,'folder'=>'thumb'),array('width'=>350,'height'=>263,'folder'=>'small'),array('width'=> 350,'height'=>200,'folder'=>'large')),null); $insertDatas = array( 'gallery_cat_id' =>1, 'gallery_image_name' =>$fileName, 'gallery_image_type' =>2, 'gallery_image_date' =>date('Y-m-d H:i:s'), 'gallery_image_status' =>1 ); $id = DB::table('gallery_images')->insertGetId($insertDatas); $data = DB::table('gallery_images AS GI ') -> select(DB::raw('GI.*')) ->where('gallery_id','=',$id) ->first(); echo json_encode(array('status'=>true,'fileName'=>$data->gallery_image_name,'id'=>$data->gallery_id,'label'=>$data->gallery_label)); exit(); } } public function client_delete_gallery_image($id){ $imageDetail = DB::table('gallery_images') ->where('gallery_id','=',$id) ->first(); if(!empty($imageDetail)){ if(!empty($imageDetail->gallery_image_name) && File::exists('assets/uploads/clients/'.$imageDetail->gallery_image_name) ){ File::delete('assets/uploads/clients/'.$imageDetail->gallery_image_name); File::delete('assets/uploads/clients/thumb/'.$imageDetail->gallery_image_name); File::delete('assets/uploads/clients/small/'.$imageDetail->gallery_image_name); File::delete('assets/uploads/clients/large/'.$imageDetail->gallery_image_name); DB::table('gallery_images')->where('gallery_id', '=', $id)->delete(); } } echo json_encode(array('status'=>true,'Message'=>'File Deleted')); } public function client_save_gallery_name(){ $id=Input::get('galid'); $galname=Input::get('galname'); if(!empty($id)){ DB::table('gallery_images')->where('gallery_id', '=',$id)->update(array('gallery_label'=>$galname)); } echo json_encode(array('status'=>true,'Message'=>'Name Updated')); } }
💾 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