PK

ADDRLIN : /home/questend/public_html/domains/evami.in/app/Http/Controllers/
FLL :
Current File : /home/questend/public_html/domains/evami.in/app/Http/Controllers/GalleryController.php

<?php

namespace App\Http\Controllers;

use App\Gallery;
use Illuminate\Http\Request;
use Carbon\Carbon;
use Validator;
use Response;
use Redirect;
use Session;
use Auth;
use File;
use DB;
//use Purifier;
class GalleryController extends Controller
{   
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth:admin');
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        if(view()->exists('backend.admin.galleries.gallery'))
        {   
            $galleries = Gallery::select('id','gallery_type','gallery_url','gallery_content','created_at')->where('isactive',1)->where('isdelete',1)->orderBy('id','desc')->paginate(13);

            if ($request->has('action') && $request->query('action')==='search') {
                $gallery_content = trim($request->input('gallery_content'));  
                if (!empty($gallery_content)) {
                    $galleries = Gallery::query();
                    $galleries=$galleries->orderBy('id','desc');   
                    
                    $galleries=$galleries->where('gallery_content', 'like', '%' . $gallery_content . '%');
                    
                    $galleries =$galleries->paginate(13);
                }
            }
            $galleries->withPath('gallery');
            //p($galleries); exit;
            return view('backend.admin.galleries.gallery',compact('galleries'));
        }
        return back()->with('error', 'Opps view not found');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        if(view()->exists('backend.admin.galleries.galleryCreate'))
        {   
            $galleryType = arrayToObject(['image','pdf']);
            return view('backend.admin.galleries.galleryCreate',compact('galleryType'));
        }
        return back()->with('error', 'Opps view not found');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        if ($request->_token != Session::token()) {
            return Redirect::back()->with('message', 'Invalid submission !');
        }
        
        $this->validate($request, [
            'gallery_type' => 'required_if:selection,image,pdf,video,other',
            'gallery' => 'required|array|min:1',
            'isactive' => 'required',
        ]);
        $galleryType = $request->gallery_type;
        
        if(!in_array($galleryType,['image','pdf'])){
            return Redirect::back()->with('error', 'Please select valid gallery type !');
        }
        //echo url('/'); exit;
        if ($request->hasfile('gallery')) {
            $galleryImg = $request->file('gallery');            
            $path ="uploads/$galleryType/";
            foreach($galleryImg as $key => $value){
                if ($value->isValid()){
                    $imageName = $value->getClientOriginalName(); // getting image name
                    $extension = $value->getClientOriginalExtension(); // getting image extension	       		
                    $imagefile = $path.'!'.($key+1).'!'.time().'.'.$extension;
                    //makeDir($dirPath,$mode=0755);	
                    if($value->move(public_path().'/'.$path,$imagefile)){
                        $gall = new Gallery; 
                            $gall->gallery_type =$galleryType;
                            $gall->gallery_url =url('/').'/'.$imagefile;
                            $gall->gallery_content =$imageName;
                            $gall->isactive =$request->isactive;
                            //$gall->isdelete ='';
                            $gall->addedby =Auth::user()->id;
                            $gall->created_at =Carbon::now();
                            $gall->visitor =$request->ip();
                        $gall->save();
                    }
                }
            }
            return back()->with('success', 'New gallery Added Successfully !');
        }        
        //p($request->all());
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Gallery  $gallery
     * @return \Illuminate\Http\Response
     */
    public function show(Gallery $gallery)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Gallery  $gallery
     * @return \Illuminate\Http\Response
     */
    public function edit(Gallery $gallery)
    {   
        
        if(view()->exists('backend.admin.galleries.galleryEdit'))
        {   
            $galleryType = arrayToObject(['image','pdf']);
            return view('backend.admin.galleries.galleryEdit',compact('gallery','galleryType'));
            /* $galleries = Gallery::select('id','gallery_type','gallery_url','gallery_content','created_at')->where('isactive',1)->where('isdelete',1)->orderBy('id','desc')->paginate(13);

            if ($request->has('action') && $request->query('action')==='search') {
                $gallery_content = trim($request->input('gallery_content'));  
                if (!empty($gallery_content)) {
                    $galleries = Gallery::query();
                    $galleries=$galleries->orderBy('id','desc');   
                    
                    $galleries=$galleries->where('gallery_content', 'like', '%' . $gallery_content . '%');
                    
                    $galleries =$galleries->paginate(13);
                }
            }
            $galleries->withPath('gallery'); */
            
        }
        return back()->with('error', 'Opps view not found');
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Gallery  $gallery
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Gallery $gallery)
    {
        if ($request->_token != Session::token()) {
            return Redirect::back()->with('message', 'Invalid submission !');
        }
        
        $this->validate($request, [
            'gallery_type' => 'required_if:selection,image,pdf,video,other',
            //'gallery' => 'required',
            'isactive' => 'required',
        ]);

        $galleryType = $request->gallery_type;
        
        if(!in_array($galleryType,['image','pdf'])){
            return Redirect::back()->with('error', 'Please select valid gallery type !');
        }
        
        $gallery->gallery_type =$galleryType;
       

        if ($request->hasfile('gallery')) {
            $oldFileName = $gallery->gallery_url;
            $imageName = $gallery->getClientOriginalName(); // getting image name
            $destinationPath = "uploads/$galleryType/"; // Define destination path
            $extension = $request->file('gallery')->getClientOriginalExtension(); // Get image extension
            $now = new \DateTime(); // Get date and time
            $date = $now->getTimestamp(); // Convert date and time in timestamp
            $fileName =  $destinationPath.'!'.rand(1,99).'!'.time().'.'.$extension; // Give name to image
          
            ##thumb destination path
                //$thumimage_path = $destinationPath . '/thumb/' . $fileName; // thumb image path          
                //resizeImage($image_path, $thumimage_path, $width=150, $height=150);     
            //File::delete(public_path().$oldFileName);	
            if($request->file('gallery')->move(public_path().'/'.$destinationPath,$oldFileName)){
                $gallery->gallery_url = $oldFileName;
                $gallery->gallery_content =$imageName;
            } 
        }
       
        $gallery->isactive =$request->isactive;
        //$gallery->isdelete ='';
        $gallery->addedby =Auth::user()->id;
        $gallery->updated_at =Carbon::now();
        $gallery->visitor =$request->ip();
        if($gallery->save()){
            //return back()->with('success', 'gallery Updated Successfully !');
            return redirect()->route('gallery.edit', $gallery->id)->with('success', 'Gallery updated successfully !');
        }
        return back()->with('error', 'something went wrong try again !');
        //p($request->all());
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Gallery  $gallery
     * @return \Illuminate\Http\Response
     */
    public function destroy(Gallery $gallery)
    {
        //
    }
}


PK 99
E-SHOP || DASHBOARD
404

Page Not Found

It looks like you found a glitch in the matrix...

← Back to Home