Kanchan186's avatar

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_PARSE) syntax error, unexpected 'return' (T_RETURN)

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\prod_cat;
use App\product;
use App\category;
use DB;

class ProdCatController extends Controller
{
     public function store2(Request $request)
    {
        //dd($request->all());
        foreach(request('cat') as $cat_id) 
         {
            prod_cat::create([
            'p_id'=> request('p_id'),
              //'p_name'=>request('p_name'),
            'c_id'=> $cat_id,
             // 'c_name'=>request('c_name'),
            ]);
        }
    
         $product=product::get();
       $category=category::get();
      $prod_cat=prod_cat::get();

        array($request->get('c_id'));

    return view('pcview',compact('product','category','prod_cat'));
    }



public function show2()
                 {
                  $product=product::get();
                  $category=category::get();
                   $prod_cat= prod_cat::get();
              
               $result=DB::table('products')
         ->join('categories','categories.c_id','=','products.p_id')
         ->join('prod_cats','prod_cats.pc_id','=','products.p_id')
         ->select('prod_cats.pc_id','products.p_id','products.p_name','categories.c_id','categories.c_name') 
                   
     

                return view('pcview',compact('result'));

                   // return redirect('pcview');
                  } 

}

pcview.blade.php


 <body>
        <div class="flex-center position-ref full-height">
            

            <div class="content">
                
                   
                  <br><br><br><br><br><br>
                    <table  class="table table-striped">
                        
                        <tr>
                            <th>Product category ID</th>
                            <th>Product ID</th>
                            <th>Product Name</th>
                            <th>Category ID</th>
                            <th>Category Name</th>
                            
                        </tr>


            @foreach($result as $row)
            <tr>
            <td>{{$row->pc_id}}</td>    
            <td>{{$row->p_id}}</td>
            <td>{{$row->p_name}}</td>
            <td>{{$row->c_id}}</td>
            <td>{{$row->c_name}}</td>
        
      <!--      <td><a href="{{url('/')}}/edit/{{$pc->pc_id}}"  class="btn btn-success">Edit</a></td>
            <td><a href="{{url('/')}}/delete/{{$pc->c_id}}" class="btn btn-danger">Delete</a></td> -->
            </tr>
             @endforeach
            
                    </table>

                    <br><hr>


                   
                 </div>
      
                
            </div>


       
    </body>

0 likes
2 replies
Sti3bas's avatar
Sti3bas
Best Answer
Level 53

Semicolon (;) is missing after select('prod_cats.pc_id','products.p_id','products.p_name','categories.c_id','categories.c_name').

1 like

Please or to participate in this conversation.