Kanchan186

Kanchan186

Member Since 1 Month Ago

Experience Points 2,530
Experience Level 1

2,470 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 4
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

11 Sep
4 days ago

Kanchan186 started a new conversation Facade\Ignition\Exceptions\ViewException Undefined Property: StdClass::$u_id (View: C:\xampp\htdocs\join\resources\views\join.blade.php)

join.blade.php

<body>

      <table border="1" class="table table-bordered table-striped">
        <thead>
        <tr>
            <th>Name</th>
            <th>Phone</th>
            <th>Email</th>
            <th>Age</th>
            <th>order_no</th>
            <th>Item_name</th>
            <th colspan="2">Action</th>
        </tr>  
        </thead>

        <tbody>
        @foreach($data as $user)
        <tr>
            <td>{{$user->u_name}}</td>
            <td>{{$user->phone}}</td>
            <td>{{$user->email}}</td>
            <td>{{$user->age}}</td>
            <td>{{$user->o_id}}</td>
            <td>{{$user->item_name}}</td>

             <td><a href="{{url('/')}}/edit/{{$user->u_id}}"  class="btn btn-default">Edit</a></td>
            <td><a href="{{url('/')}}/delete/{{$user->u_id}}" class="btn btn-default">Delete</a></td> 
         </tr>    
        @endforeach
        </tbody>
      </table>

    </body>

TestController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;

class TestController extends Controller
{
    function add()
      {
        $data=DB::table('user')
      ->join('user_details','user_details.user_id','=','user.u_id')
      ->join('order','order.user_id','=', 'user.u_id')
      ->select('user.u_name','user.phone','user_details.email','user_details.age','order.o_id','order.item_name')
      ->get();

      return view('join',compact('data'));

       echo"<pre>";
       print_r($data);


      }

/*
 public function edit(product $p_id)
    {
      //dd($prod_id);
      return view('editProd',compact('p_id'));
    }


    public function update(Request $req, product $p_id)
    {
      $p_id->update($req->all());
      return redirect('viewprod');
    }  
       */


    public function destroy(user $u_id)
    {
      
      
       $u_id->delete();
       
     return view('join',compact('user'));
    }

  }  

web.php

<?php

Route::get('/','[email protected]');

Route::get('join','[email protected]');

//Route::get('edit/{id}','[email protected]');
//Route::post('update/{id}','[email protected]');
Route::get('delete/{id}','[email protected]');
09 Sep
6 days ago

Kanchan186 started a new conversation Didn't Getting Error But Not Fetch Data From Tables And Join Query Not Works Please Give Me Some Suggestions Where I Going Wrong

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>

controller

<?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 redirect('viewpc');
   // return view('pcview',compact('product','category','prod_cat'));
    }



public function show2(Request $request)
                 {

dd($request->all());

                 // $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') 
         ->get();  

         */


    $result=DB::table('prod_cats')
          ->join('products','products.p_id','=','prod_cats.pc_id')  
          ->join('categories','categories.c_id','=','prod_cats.pc_id') 
          ->select('prod_cats.pc_id','products.p_id','products.p_name','categories.c_id','categories.c_name')->get();      
     


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


     //  echo"<pre>";
     // print_r($result);

                   //return redirect('pcview');
                  } 
}

Kanchan186 left a reply on ErrorException (E_ERROR) Undefined Variable: Result (View: C:\xampp\htdocs\check1\resources\views\pcview.blade.php)

thanks.. error solved but i getting null output. join query not working properly data is not fetched from tables

please give me some suggestions where i going wrong

Kanchan186 started a new conversation ErrorException (E_ERROR) Undefined Variable: Result (View: C:\xampp\htdocs\check1\resources\views\pcview.blade.php)

<?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') 
         ->get();

                
     

                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>

Kanchan186 started a new conversation 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>

04 Sep
1 week ago

Kanchan186 started a new conversation Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_PARSE) Syntax Error, Unexpected '$prod_cat' (T_VARIABLE)

<?php

namespace App\Http\Controllers;

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

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();

                   dd($result->all())
                            
       $prod_cat=prod_cat::join('categories', 'categories.c_id','=','prod_cats.c_id')
                            ->join('products','products.p_id','=','categories.p_id')
                            ->select('products.p_id','products.p_name','categories.*','categories.c_id','categories.c_name','prod_cats.*')->get();
                            //->orderBy('p_name','ASC')
                            //->orderBy('c_name','ASC')
                            //->get();

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

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

                    return redirect('pcview');
                  } 
}
03 Sep
1 week ago

Kanchan186 left a reply on Illuminate \ Database \ QueryException (HY000) SQLSTATE[HY000]: General Error: 1364 Field 'p_id' Doesn't Have A Default Value (SQL: Insert Into `prod_cats` (`updated_at`, `created_at`) Values (2019-09-03 05:18:24, 2019-09-03 05:18:24))

i make above changes still getting same error

Illuminate \ Database \ QueryException (23000)
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'c_id' cannot be null (SQL: insert into `prod_cats` (`p_id`, `c_id`, `updated_at`, `created_at`) values (1, ?, 2019-09-03 06:19:25, 2019-09-03 06:19:25))

Kanchan186 left a reply on Illuminate \ Database \ QueryException (HY000) SQLSTATE[HY000]: General Error: 1364 Field 'p_id' Doesn't Have A Default Value (SQL: Insert Into `prod_cats` (`updated_at`, `created_at`) Values (2019-09-03 05:18:24, 2019-09-03 05:18:24))

hello sir, when i make changes i got again an error

Illuminate \ Database \ QueryException (23000)
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'c_id' cannot be null (SQL: insert into `prod_cats` (`p_id`, `c_id`, `updated_at`, `created_at`) values (1, ?, 2019-09-03 06:04:28, 2019-09-03 06:04:28))

Kanchan186 started a new conversation Illuminate \ Database \ QueryException (HY000) SQLSTATE[HY000]: General Error: 1364 Field 'p_id' Doesn't Have A Default Value (SQL: Insert Into `prod_cats` (`updated_at`, `created_at`) Values (2019-09-03 05:18:24, 2019-09-03 05:18:24))

ProdCatController.php

<?php

namespace App\Http\Controllers;

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



class ProdCatController extends ProductController
{
   public function store1(Request $req)
    {
        //dd($req->all());
        prod_cat::create([
                    'p_id'=>request('p_id'),
                    'c_id'=>request('c_id'),

                    

                   ]);

    
         $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 show1()
                 {

                    

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


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

                    //return redirect('prodview');
                  } 



}

prodview.blade.php

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

            <div class="content">
               
                <form method="post" action="{{url('/')}}/store1" enctype="multipart/form-data">
                        {{csrf_field()}}
                <input type="hidden" name="MAX_FILE_SIZE" value="10485760">


                     <table  class="table table-striped">
                        
                   
                        <tr> <td><select name="p_id" class="form-control">
                             @foreach($product as $prod)
                             <option value ="{{$prod->p_id}}">{{$prod->p_name}}</option>
                             @endforeach
                             </select></td> 
                        </tr>

                        <tr><td>
                            @foreach($category as $cat)
                            <input type="checkbox" name="cat[{{$cat->c_id}}]"  value ="{{$cat->c_id}}">{{$cat->c_name}}<br>
                            @endforeach</td>

                        <tr><td><input type="submit" name=""></td></tr>


                       </table> </form><br><hr>
               
            </div>
        </body>

prod_cat.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class prod_cat extends Model
{
   protected $guarded = ['pc_name','p_id','c_id'];
    protected  $primaryKey = 'pc_id';
}
30 Aug
2 weeks ago

Kanchan186 left a reply on How To Save Multiple Checkbox Values In Database In Laravel

sir can you pleasee send the short code or sample code to understand the concept

Kanchan186 started a new conversation How To Save Multiple Checkbox Values In Database In Laravel

prodview.php

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

            <div class="content">
               
                <form method="post" action="{{url('/')}}/store1" enctype="multipart/form-data">
                        {{csrf_field()}}
                <input type="hidden" name="MAX_FILE_SIZE" value="10485760">


                     <table  class="table table-striped">
                        
                   
                        <tr> <td><select name="p_id" class="form-control">
                             @foreach($product as $prod)
                             <option value ="{{$prod->p_id}}">{{$prod->p_name}}</option>
                             @endforeach
                             </select></td> 
                        </tr>

                        <tr><td>
                            @foreach($category as $cat)
                            <input type="checkbox" name="c_id"  value ="{{$cat->c_id}}">{{$cat->c_name}}<br>
                            @endforeach</td>

                        <tr><td><input type="submit" name=""></td></tr>


                       </table> </form><br><hr>
               
            </div>
        </body>

prodCatController.php

<?php

namespace App\Http\Controllers;

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



class ProdCatController extends ProductController
{
   public function store1(Request $req)
    {
        //dd($req->all());
        prod_cat::create([
                    'p_id'=>request('p_id'),
                    'c_id'=>request('c_id'),
                   ]);
        
         $product=product::get();
         $category=category::get();
         $prod_cat=prod_cat::get();

        return redirect('pcview');
    }



    public function show1()
                 {

                    

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


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

                    //return redirect('prodview');
                  } 



}

Kanchan186 started a new conversation Illuminate \ Database \ QueryException (23000) SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'c_id' Cannot Be Null (SQL: Insert Into `prod_cats` (`p_id`, `c_id`, `updated_at`, `created_at`) Values (1, ?, 2019-08-30 04:46:52, 2019-08-30 04:4

prodview.blade.php

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

            <div class="content">
               
                <form method="post" action="{{url('/')}}/store1" enctype="multipart/form-data">
                        {{csrf_field()}}
                <input type="hidden" name="MAX_FILE_SIZE" value="10485760">


                     <table  class="table table-striped">
                        
                   
                        <tr> <td><select name="p_id" class="form-control">
                             @foreach($product as $prod)
                             <option value ="{{$prod->p_id}}">{{$prod->p_name}}</option>
                             @endforeach
                             </select></td> 
                        </tr>

                        <tr><td>
                            @foreach($category as $cat)
                            <input type="checkbox" name="c_id"  value ="{{$cat->c_id}}">{{$cat->c_name}}<br>
                            @endforeach</td>

                        <tr><td><input type="submit" name=""></td></tr>


                       </table> </form><br><hr>
               
            </div>
        </body>

ProdCatController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\prod_cat;


class ProdCatController extends ProductController
{
   public function store1(Request $req)
    {
        //dd($req->all());
        prod_cat::create([
                    'p_id'=>request('p_id'),
                    'c_id'=>request('c_id'),
                    

                ]);
         $product=product::get();
         $category=category::get();
         $prod_cat=prod_cat::get();

        //return redirect('viewprod');
    }

}

web.php

<?php


Route::get('/', function () {
    return view('addprod');
});

Route::get('addpd','[email protected]');
Route::post('store','[email protected]');
Route::get('viewprod','[email protected]');

Route::post('store1','[email protected]');
29 Aug
2 weeks ago

Kanchan186 started a new conversation ErrorException (E_ERROR) Undefined Variable: Product (View: C:\xampp\htdocs\check\resources\views\prodview.blade.php)

please tell me where i going wrong

ProductController.php


<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\product;


class ProductController extends Controller
{
    

public function show()
                 {



                    $product=product::get();

                    return view('prodview',compact('product'));

                    //return redirect('prodview');
                  } 


}

prodview.blade.php


            <div class="content">
               
                <form method="post" action="{{url('/')}}/store1" enctype="multipart/form-data">
                        {{csrf_field()}}
                <input type="hidden" name="MAX_FILE_SIZE" value="10485760">


                     <table  class="table table-striped">
                        
                   
                         <td><select name="p_id" class="form-control">

                           @foreach($product as $prod)

                            <option value ="{{$prod->p_id}}">{{$prod->p_name}}</option>
                           @endforeach
                        </select></td> 

                       
                        
                        </table>



                 



                  
                </form>

               <br><hr>
               
            </div>


web.php



Route::get('/', function () {
    return view('prodview');
});

Route::get('show','[email protected]');


27 Aug
2 weeks ago

Kanchan186 left a reply on Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_PARSE) Syntax Error, Unexpected '$subcategory' (T_VARIABLE)

addstg.blade.php

<body>
        <div class="flex-center position-ref full-height">
                         
        
            <div class="content">
               
                <form method="post" action="{{url('/')}}/store2" enctype="multipart/form-data">
                        {{csrf_field()}}
                <input type="hidden" name="MAX_FILE_SIZE" value="10485760">


                     <table border="1" class="table table-striped">
                        
                    <tr><th>choose product</th>
                        <th> choose Product Category</th>
                        <th>Enter product Sub-Category</th>
                        <th>sub category Image</th></tr>   
                            
                        <tr>
                         <td><select name="p_id" class="form-control">
                           @foreach($product as $prod)
                            <option value ="{{$prod->p_id}}">{{$prod->p_name}}</option>
                           @endforeach
                        </select></td> 

                         <td><select name="c_id" class="form-control">
                            @foreach($category as $cat)
                            <option value ="{{$cat->c_id}}">{{$cat->c_name}}</option>
                           @endforeach
                        </select></td> 

                        <td><input type="text" name="s_name" ></td>
                        <td><input type="file" name="s_image" ></td>
                        <td><input type="submit" name=""></td></tr>
                        </table>



                 



                  
                </form>

               <br><hr>
               
            </div>
         
        </div>
    </body>

Kanchan186 left a reply on Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_PARSE) Syntax Error, Unexpected '$subcategory' (T_VARIABLE)

SubcategoryController.php

<?php

namespace App\Http\Controllers;

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

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= \DB::table('subcategories')
          ->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');
                  } 




}


26 Aug
2 weeks ago

Kanchan186 started a new conversation Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_PARSE) Syntax Error, Unexpected '$subcategory' (T_VARIABLE)

<?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');
                  } 




}

Kanchan186 started a new conversation Declaration Of App\Http\Controllers\CategoryController::edit(App\category $c_id) Should Be Compatible With App\Http\Controllers\ProductController::edit(App\product $p_id)

namespace App\Http\Controllers;
 
use Illuminate\Http\Request;
use App\product;
use App\category;
use File;
 
 
 
class CategoryController extends ProductController
{
    public function addctg()
        {
        $product=product::get();
        $category=category::get();
 
        return view('addctg',compact('product','category'));
        }
 
 
   public function store1(Request $request)
      {
         //dd('hi');
       // dd(request('image'));
        //dd($request->all());

22 Aug
3 weeks ago

Kanchan186 left a reply on ErrorException (E_ERROR) Trying To Get Property 'p_name' Of Non-object (View: C:\xampp\htdocs\product\resources\views\prodview.blade.php)

again error

SQLSTATE[HY000]: General error: 1364 Field 'p_name' doesn't have a default value (SQL: insert into `products` (`updated_at`, `created_at`) values (2019-08-22 07:28:23, 2019-08-22 07:28:23))

Kanchan186 left a reply on ErrorException (E_ERROR) Trying To Get Property 'p_name' Of Non-object (View: C:\xampp\htdocs\product\resources\views\prodview.blade.php)

when i add dd($request->all()); to productController.php

output:


array:4 [▼
  "_token" => "cNjqi1BY7C2OMyAkCvrStcxKAcwuLnwoFGZUNyZv"
  "p_name" => "xcvcfv"
  "image" => "86282.jpg"
  "submit" => null
]

problem is that image not stored in database

Kanchan186 left a reply on ErrorException (E_ERROR) Trying To Get Property 'p_name' Of Non-object (View: C:\xampp\htdocs\product\resources\views\prodview.blade.php)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class product extends Model
{
    protected  $table = 'products';
   protected $fillable = ['p_name', 'image'];
    protected  $primaryKey = 'p_id';

}

Kanchan186 left a reply on ErrorException (E_ERROR) Trying To Get Property 'p_name' Of Non-object (View: C:\xampp\htdocs\product\resources\views\prodview.blade.php)

after made changes

ErrorException (E_ERROR)
Undefined variable: Product (View: C:\xampp\htdocs\product\resources\views\prodview.blade.php)

Kanchan186 left a reply on ErrorException (E_ERROR) Trying To Get Property 'p_name' Of Non-object (View: C:\xampp\htdocs\product\resources\views\prodview.blade.php)

yes sir, actually sir, i am very new to laravel. please help me to find out error

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\product;


class ProductController extends Controller
{
   public function addpd()
                {
                $product=product::get();
                      return view('addprod',compact('product'));
                  }


   public function store(Request $request)
      {
         //dd($request->all());

         //$product=new product();
        // $product->save();

         $product=new product();
 
    $product->p_id = request('p_id');
    $product->p_name = request('p_name'); 
 
    if($request->hasfile('image'))
    {
        $file=$request->file('image');
 
        $extension=$file->getClientOriginalExtension();
 
        $filename=time().'.'.$extension;
            
        $file->move('uploads/product/',$filename);
 
        $product->image=$filename;
    }

    $product->save();
    return view('prodview')->with('product',$product);
    

    }



 public function show()
                 {
                    $product=product::get();
                    return view('prodview',compact('product'));

                    //return redirect('addstate');
                  }                 



    }

Kanchan186 started a new conversation ErrorException (E_ERROR) Trying To Get Property 'p_name' Of Non-object (View: C:\xampp\htdocs\product\resources\views\prodview.blade.php)

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

            <div class="content">
                
                    <a href="{{url('/')}}/store">Add Prod</a>
                    <table border="1" >
                        
                        <tr>
                            <th>Prod Name</th>
                            <th>Product image</th>
                        </tr>


                        @foreach($product as $prod)
                         <tr>
                         <td>{{$prod->p_name}}</td>
                         <td>{{url('/')}}/$prod->image}}</td>
                            
                        </tr>
                        @endforeach
                    </table>
                        
                </div>

                
            </div>
       
    </body>

Kanchan186 left a reply on How To Define Variable Filename ErrorException (E_NOTICE) Undefined Variable: Filename

thanks sir, above error solved but getting new error

ErrorException (E_ERROR)
Trying to get property 'p_name' of non-object (View: C:\xampp\htdocs\product\resources\views\prodview.blade.php)



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

            <div class="content">
                
                    <a href="{{url('/')}}/store">Add Prod</a>
                    <table border="1" >
                        
                        <tr>
                            <th>Prod Name</th>
                            <th>Product image</th>
                        </tr>


                        @foreach($product as $prod)
                         <tr>
                         <td>{{$prod->p_name}}</td>
                         <td>{{url('/')}}/$prod->image}}</td>
                            
                        </tr>
                        @endforeach
                    </table>
                        
                </div>

                
            </div>
       
    </body>

Kanchan186 started a new conversation How To Define Variable Filename ErrorException (E_NOTICE) Undefined Variable: Filename

public function store(Request $request)
      {
         
         $product=new product();
 
 
         product::create([
                                            'p_id' => request('p_id'),
                                            'p_name' => request('p_name'),
                                            'image' =>$filename 
                                          ]);
 
 
 
         if($request->hasfile('image'))
         {
            $file=$request->file('image');
 
            $extension=$file->getClientOriginalExtension();
 
            $filename=time().'.'.$extension;
            
            $file->move('uploads/product/',$filename);
 
            $product->image=$filename;

Kanchan186 started a new conversation Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_PARSE) Syntax Error, Unexpected 'product' (T_STRING), Expecting Function (T_FUNCTION) Or Const (T_CONST)

ProductController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\product;


class ProductController extends Controller
{
   public function addpd()
                {
                $product=product::get();
                      return view('addprod',compact('product'));
                  }


   public function store(Request $request)
      {
         
         if($request->hasfile('image'))
         {
            $file=$request->file('image');
            $extension=$file->getClientOriginalExtension();
            $filename=time().'.'.$extension;
            $file->move('uploads/product/',$filename);

            $product->image=$filename;
           }
          
          else
          {
            return $request;
            $product->image='';
          } 

    $product->save();
    return view('product')->with('product',$product);
    }


//dd($req->all());
                               product::create([
                                            'p_id' => request('p_id'),
                                            'p_name' => request('p_name'),
                                            
                                            'image' =>$filename 
                                          ]);
                       }
                  


      public function show()
                 {
                    $product=product::get();
                    return view('prodview',compact('product'));

                    //return redirect('addstate');
                  }                 


}


21 Aug
3 weeks ago

Kanchan186 started a new conversation ErrorException (E_ERROR) Property [image] Does Not Exist On This Collection Instance. (View: C:\xampp\htdocs\product\resources\views\prodview.blade.php) Previous Exceptions

prodview.blade.php

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

            <div class="content">
                <div class="title m-b-md">
                    <a href="{{url('/')}}/store">Add Prod</a>
                    <table border="1" >
                        
                        <tr>
                            <th>Prod Name</th>
                            <th>Product image</th>
                        </tr>


                        @foreach($product as $prod)
                         <tr>
                         <td>{{$prod->p_name}}</td>
                         <td><img src="{{asset('uploads/product'.$product->image)}}" alt="Image"></td>
                            
                        </tr>
                        @endforeach
                    </table>
                        
                </div>

                
            </div>
        </div>
    </body>

Kanchan186 left a reply on {"_token":"aPxhuhWNZm2KBVJoWiuEvN2Xc4tI3UTORCGIlpMs","p_name":"dfgm","image":"86282.jpg","submit":null}

when i made changes, again getting error

SQLSTATE[HY000]: General error: 1364 Field 'p_name' doesn't have a default value (SQL: insert into `products` (`updated_at`, `created_at`) values (2019-08-21 10:36:06, 2019-08-21 10:36:06))

Kanchan186 left a reply on {"_token":"aPxhuhWNZm2KBVJoWiuEvN2Xc4tI3UTORCGIlpMs","p_name":"dfgm","image":"86282.jpg","submit":null}

web.php

<?php

Route::get('/', function () {
    return view('addprod');
});

Route::get('addpd','[email protected]');
Route::post('store','[email protected]');
//Route::get('viewprod','[email protected]');

Kanchan186 left a reply on {"_token":"aPxhuhWNZm2KBVJoWiuEvN2Xc4tI3UTORCGIlpMs","p_name":"dfgm","image":"86282.jpg","submit":null}

product.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class product extends Model
{
    //protected  $table = 'products';
   protected $fillable = ['p_name', 'image'];
    protected  $primaryKey = 'p_id';

}

Kanchan186 left a reply on {"_token":"aPxhuhWNZm2KBVJoWiuEvN2Xc4tI3UTORCGIlpMs","p_name":"dfgm","image":"86282.jpg","submit":null}

productController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\product;

class ProductController extends Controller
{
   public function addpd()
                {
                $product=product::get();
                      return view('addprod',compact('product'));
                  }


   public function store(Request $request)
         {
           //dd($request->all());
          
            $product=new product();

            $product->p_name=$request->input('p_name');


            if ($request->hasfile('image'))
          {
                    
            $file=$request->file('image');

            $extension=$file->getClientOriginalExtension();

            $filename=time().'.'.$extension;

            $file->move('uploads/product',$filename);

            $product->image=$filename;
          }

          else{

             return $request;
             $product->image='';
           }
        $product->save();
        //return view('addprod')->with('product',$product);
         return view('viewprod',compact('product'));


            }
  
   //return redirect('viewprod');
   }

Kanchan186 left a reply on {"_token":"aPxhuhWNZm2KBVJoWiuEvN2Xc4tI3UTORCGIlpMs","p_name":"dfgm","image":"86282.jpg","submit":null}

sir, I switched on markdown option but still preview not proper.

Kanchan186 left a reply on {"_token":"aPxhuhWNZm2KBVJoWiuEvN2Xc4tI3UTORCGIlpMs","p_name":"dfgm","image":"86282.jpg","submit":null}

addprod.blade.php

        <div class="content">
           
                <form method="post" action="{{url('/')}}/store">
                    {{csrf_field()}}

             <table>

            <tr>
            <label>Enter product name</label>
            <input type="text" class="form-group" name="p_name" >
            </tr>

            <tr>
            <input type="file" name="image" class="custom-file-input">  
            <label >choose file</label>  
            </tr>
                    
             <tr><input type="submit" name=""></tr> 
             </table>      
            </form>
                
        </div>
    </div>
</body>

Kanchan186 started a new conversation {"_token":"aPxhuhWNZm2KBVJoWiuEvN2Xc4tI3UTORCGIlpMs","p_name":"dfgm","image":"86282.jpg","submit":null}

values not store to database. please tell me where i going wrong