Kanchan186
2 weeks ago

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_PARSE) syntax error, unexpected '$subcategory' (T_VARIABLE)

Posted 2 weeks ago by Kanchan186
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\product;
use App\category;
use App\subcategory;
use File;

class SubcategoryController extends CategoryController
{
     public function addstg()
        {
        $product=product::get();
        $category=category::get();
        $subcategory=subcategory::get();

        return view('addstg',compact('product','category','subcategory'));
        }


 public function store2(Request $request)
      {
         //dd('hi');
       // dd(request('image'));
        //dd($request->all());

           if($request->hasFile('s_image'))
           {
           // dd('hi');

            $file = $request->file('s_image');

            $destinationPath =public_path()."/sub_img";

            $filename = $file->getClientOriginalName();

            if(!File::exists($destinationPath))
             {
                File::makeDirectory($destinationPath, $mode = 0777, true);
                $file->move($destinationPath, $filename);
             }
            else
              {
                $file->move($destinationPath, $filename);
                }
            

           // echo  $filename;exit;
            }         

subcategory::create([

  'p_id' =>request('p_id'),
  'c_id' =>request('c_id'),
's_name' =>request('s_name'),
's_image' =>$filename 
]);

  $product=product::get();
  $category=category::get();
  $subcategory=subcategory::get();

return redirect('viewsub');

}     




public function show2()
                 {

                  $product=product::get();
                  $category=category::get();
                  $subcategory=subcategory::get();

                  //dd($result->all())

                 

                  $subcategory=subcategory::join('products','subcategories.p_id','=','products.p_id')
                  ->join('categories','subcategories.c_id','=','categories.c_id')->get();
                    

                  return view('subview',compact('category','product','subcategory'));

                    return redirect('subview');
                  } 




}

Please sign in or create an account to participate in this conversation.