developer_

developer_

Member Since 4 Months Ago

Experience Points 1,880
Experience Level 1

3,120 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 10
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

17 Apr
1 month ago

developer_ left a reply on Data Isn't Showing On Page

@MUNAZZIL - bro m also using it but still same result

developer_ left a reply on Data Isn't Showing On Page

@MUNAZZIL - i hvn't followed passport documentation, but hv used the above link bt nthing happens and vue version is 2 here what m using https://ibb.co/cwndyV7 https://ibb.co/g4V12NF

developer_ left a reply on Data Isn't Showing On Page

@MUNAZZIL - By running this command most of the styling mistakes are correct now but data is still not showing in page, this is its output: https://ibb.co/Tr10D8K

developer_ left a reply on Data Isn't Showing On Page

@BOBBYBOUWMANN - Sory i didn't compile it, can u suggest me how to do it?

developer_ started a new conversation Data Isn't Showing On Page

Hi i hv made a component in laravel and when i write some txt init, than its not displaying, any solution to solve this issue,

screenshot of folders: https://ibb.co/G0VBqTP

code of users.vue:

  <template>
<div class="container">
    <div class="row">
      <div class="col-12">
        <div class="card">
          <div class="card-header">
            <h3 class="card-title">Users Table</h3>

            <div class="card-tools">
              
            </div>
          </div>
          <!-- /.card-header -->
          <div class="card-body table-responsive p-0">
            <table class="table table-hover">
              <tbody><tr>
                <th>ID</th>
                <th>User</th>
                <th>Date</th>
                <th>Status</th>
                <th>Reason</th>
              </tr>
              <tr>
                <td>183</td>
                <td>John Doe</td>
                <td>11-7-2014</td>
                <td><span class="tag tag-success">Approved</span></td>
                <td>Bacon ipsum dolor sit amet salami venison chicken flank fatback doner.</td>
              </tr>
            </tbody></table>
          </div>
          <!-- /.card-body -->
        </div>
        <!-- /.card -->
      </div>
    </div>
</div>

export default { mounted() { console.log('Component mounted.') } }
08 Mar
2 months ago

developer_ started a new conversation Connection Could Not Be Established With Host Mailtrap.io

Hello, i have make a site in laravel, initially it was working fine but suddenly it started showing this error on user-signup: (m using localhost xampp)

  Connection could not be established with host mailtrap.io [A connection attempt failed because the 
connected party did not properly respond after a period of time, or established connection failed because 
connected host has failed to respond. #10060]

i hv tried a lot but it is not resolving, anyone can suggest a solution

08 Feb
3 months ago

developer_ started a new conversation Syntax Error, Unexpected '" Class="' (T_CONSTANT_ENCAPSED_STRING), Expecting ',' Or ';'

the line of error showing is:

 <img src="<?php echo e(asset('images/backend_images/iconbox_bg.png'))" class="k-widget- 
 21__bg" alt="bg"/>

my code is:

   <img class="k-widget-19__bg"  src="{{ asset('images/backend_images/iconbox_bg.png') }}" 
     alt="bg"/>

any suggestionn to ressolve this issue

01 Feb
3 months ago

developer_ left a reply on Failed To Clear Cache. Make Sure You Have The Appropriate Permissions.

@TALINON - same error after delete the cache folder manually and re-create it,

developer_ started a new conversation Failed To Clear Cache. Make Sure You Have The Appropriate Permissions.

php artisan cache:clear says:

Failed to clear cache. Make sure you have the appropriate permissions.

i also have created data folder in /storage/framework/cache but still same issue, any suggestion to solve it

developer_ left a reply on File_put_contents

@MUNAZZIL - cache isn't clearing:

Failed to clear cache. Make sure you have the appropriate permissions.

developer_ left a reply on File_put_contents

@MUNAZZIL - i have already linked it using this command

php artisan storage:link

developer_ started a new conversation Failed To Clear Cache. Make Sure You Have The Appropriate Permissions.

i created a project on another pc it was working fine, but when i copy it into another pc and try to open it, thn it says: file_put_contents(E:\xampp\htdocs\lweb2\storage\framework/sessions/tQp2cprdDgWqpDLBx52ncxsrn6vRlCpHcZjZXdjI): failed to open stream: No such file or directory its using the older path where it is created,

14 Jan
4 months ago

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

@VILFAGO - thnx a lot bro, sory it was an attribute i added first now i remove it and code is working fine

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

@VILFAGO - SQLSTATE[HY000]: General error: 1364 Field 'care' doesn't have a default value

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

@VILFAGO - category model:

<?php

   namespace App;

   use Illuminate\Database\Eloquent\Model;

   class Category extends Model
  {
    public function category(){
    return $this->hasMany('App\Category','parent_id');
  }

}

product model:

   <?php

    namespace App;

    use Illuminate\Database\Eloquent\Model;

   class Product extends Model
   {
     public function products(){
      return $this->hasMany('App\Product','product_id');
    }
  }

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

@VILFAGO - public function categories(){ return $this->hasMany('App\Category','parent_id'); }

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

@VILFAGO - error:

 Call to undefined method App\Category::products()

is there any issue in model than can u tell me

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

@VILFAGO - public function product(){ return $this->hasMany('App\Product','product_id'); }

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

product model :

  public function product(){
    return $this->hasMany('App\Product','product_id');
  }

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

@SIGNAR - but its not saving in db and m not getting the added product in browser, its still showing the same error, now i hv cleard the histroy of browser but still same issue

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

@SIGNAR - bro i hv added this line and also clear the view using php artisan view:clear by i dont know y getting the same error

developer_ left a reply on SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

@SIGNAR - yes $data['category_id'] gets passed through controller, and $categories_drop_down is only showing the category id in output not the text formatted value like other values

developer_ started a new conversation SQLSTATE[HY000]: General Error: 1364 Field 'category_id' Doesn't Have A Default Value

I'm new to Laravel and trying to add Product under Category but when I add Product then it shows this error:

SQLSTATE[HY000]: General error: 1364 Field 'category_id' doesn't have a default value (SQL: insert into products ..."

Initially i was adding these products without under any category than it was working and now its not adding under Category.

can anyone would prefer to provide me its solution?

here is my form:

  <form enctype="multipart/form-data" class="form-horizontal" method="post" action="{{ 
  url('admin/add-product') }}" name="add_product" id="add_product" 
  novalidate="novalidate">{{ csrf_field() }}
      <div class="control-group">
        <label class="control-label">Under Category</label>
        <div class="controls">
          <select name="category_id" id="category_id" style="width:220px;">
            <?php echo $categories_drop_down; ?>
          </select>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label">Product Name</label>
        <div class="controls">
          <input type="text" name="product_name" id="product_name">
        </div>
      </div>
 <div class="uploader" id="uniform-undefined"><input name="image" id="image" type="file" 
 size="19" style="opacity: 0;"><span class="filename">No file selected</span><span 
 class="action">Choose File</span></div>
 div class="form-actions">
        <input type="submit" value="Add Product" class="btn btn-success">
      </div>
    </form>

here is ProductsController:

   public function addProduct(Request $request)
   {
    if ($request->isMethod('post'))
    {
    $data = $request->all();

    $product = new Product;
    $product->product_name = $data['product_name'];
    $product->product_code = $data['product_code'];
    $product->product_color = $data['product_color'];
    if ( ! empty($data['description']))
    {
        $product->description = $data['description'];
    }
    else
    {
        $product->description = '';
    }
    $product->price = $data['price'];

    // Upload Image
    if ($request->hasFile('image'))
    {
        $image_tmp = Input::file('image');
        if ($image_tmp->isValid())
        {
            $extension = $image_tmp->getClientOriginalExtension();
            $filename = rand(111, 99999) . '.' . $extension;
            $large_image_path = 'images/backend_images/products/large/' . $filename;
            $medium_image_path = 'images/backend_images/products/medium/' . $filename;
            $small_image_path = 'images/backend_images/products/small/' . $filename;
            // Resize Images
            Image::make($image_tmp)->save($large_image_path);
            Image::make($image_tmp)->resize(600, 600)->save($medium_image_path);
            Image::make($image_tmp)->resize(300, 300)->save($small_image_path);
            // Store image name in products table
            $product->image = $filename;
        }
    }

    $product->save();

    /*return redirect()->back()->with('flash_message_success','Product has been added 
    successfully!');*/

    return redirect('/admin/view-products')->with('flash_message_success', 'Product has been 
    added successfully!');
    }

   $categories = Category::where(['parent_id' => 0])->get();
   $categories_drop_down = "<option value='' selected disabled>Select</option>";

   foreach ($categories as $cat)
   {
    $categories_drop_down .= "<option value='" . $cat->id . "'>" . $cat->name . "</option>";
    $sub_categories = Category::where(['parent_id' => $cat->id])->get();
    foreach ($sub_categories as $sub_cat)
    {
        $categories_drop_down .= "<option value='" . $sub_cat->id . "'>&nbsp;&nbsp;--&nbsp;" . 
       $sub_cat->name . "</option>";
      }
   }

   return view('admin.products.add_product')->with(compact('categories_drop_down'));
  }
13 Jan
4 months ago

developer_ left a reply on Undefined Variable: Filename

@realrandyallen thnx a lot, now its working fine that both image and text values are editing collectively or alone image can change, but would u prefer to tell me how to set that variable at the top as null for a default

developer_ left a reply on Undefined Variable: Filename

thnx i changed it to $filename but still same error

developer_ started a new conversation Creating Default Object From Empty Value “error In Laravel”

hi m working on update products form of ecommerce site but when i try to edit details then it shows error "Undefined variable: fileName" and error line is:

  Product::where(['id'=>$id])->
  update(['product_name'=>$data['product_name'],
  'product_code'=>$data['product_ code'],
  'product_color'=>$data['product_color'],
  'description'=>$data['description'],
  'price'=>$data['price'],'image'=>$fileName]);
  return redirect()->back()->with('flash_message_success','Product 
  updated successfully!');

or when i try to update image only then its error is: "Creating default object from empty value", or error line is:

  $product->image = $filename;

this is code of ProductsController:

  public function editProduct(Request $request, $id=null){

  if($request->isMethod('post')){
  $data = $request->all();
  //echo "<pre>"; print_r($data); die;

  if($request->hasFile('image')){
  $image_tmp = Input::file('image');
  if($image_tmp->isValid()){
    $extension = $image_tmp->getClientOriginalExtension();
    $filename = rand(111,99999).'.'.$extension;
    $large_image_path = 
  'images/backend_images/products/large/'.$filename;
    $medium_image_path = 
   'images/backend_images/products/medium/'.$filename;
    $small_image_path = 
  'images/backend_images/products/small/'.$filename;
    // Resize Images
    Image::make($image_tmp)->save($large_image_path);
    Image::make($image_tmp)->resize(600,600)->save($medium_image_path);
    Image::make($image_tmp)->resize(300,300)->save($small_image_path);

    // Store image name in products table
    $product->image = $filename;
    }
   }

    if(empty($data['description'])){
      $data['description'] = '';
      }


  Product::where(['id'=>$id])- 
   >update(['product_name'=>$data['product_name'],
    'product_code'=>$data['product_code'],
    'product_color'=>$data['product_color'],
    'description'=>$data['description'],
    'price'=>$data['price'],'image'=>$fileName]);
    return redirect()->back()->with('flash_message_success','Product 
     updated successfully!');
    }

   //Get product details
  $productDetails = Product::where(['id'=>$id])->first();

  return view('admin.products.edit_product')- 
   >with(compact('productDetails'));
  }
10 Jan
4 months ago

developer_ left a reply on Syntax Error, Unexpected 'public' (T_PUBLIC)

@manelgavalda now its fine than before, i mean add products page is showing but when i add products then it shows another error:

  SQLSTATE[HY000]: General error: 1364 Field 'category_id' doesn't have a default value (SQL: 
  insert into `products` (`product_name`, `product_code`, `product_color`, `description`, 
  `price`, `image`, `updated_at`, `created_at`) values (Filter, ASD, CLR, ASDE, 123, 67493.png, 
   2019-01-10 15:48:53, 2019-01-10 15:48:53))

developer_ left a reply on Syntax Error, Unexpected 'public' (T_PUBLIC)

@manelgavalda sory still same error, and i hv showed all code above, can u plz see it

developer_ left a reply on Syntax Error, Unexpected 'public' (T_PUBLIC)

@realrandyallen complete code of product controller

  public function addProduct(Request $request){

  if($request->isMethod('post')){
    $data = $request->all();
    //echo "<pre>"; print_r($data); die;
    //if(empty($data['category_id'])){
      //return redirect()->back()->with('flash_message_error','Under Category is missing!');  
    //}
    $product = new Product;
    //$product->category_id = $data['category_id'];
    $product->product_name = $data['product_name'];
    $product->product_code = $data['product_code'];
    $product->product_color = $data['product_color'];
    if(!empty($data['description'])){
      $product->description = $data['description'];
    }else{
    $product->description = '';         
    }
    $product->price = $data['price'];

    // Upload Image
    if($request->hasFile('image')){
      $image_tmp = Input::file('image');
      if($image_tmp->isValid()){
        $extension = $image_tmp->getClientOriginalExtension();
        $filename = rand(111,99999).'.'.$extension;
        $large_image_path = 'images/backend_images/products/large/'.$filename;
        $medium_image_path = 'images/backend_images/products/medium/'.$filename;
        $small_image_path = 'images/backend_images/products/small/'.$filename;
        // Resize Images
        Image::make($image_tmp)->save($large_image_path);
        Image::make($image_tmp)->resize(600,600)->save($medium_image_path);
        Image::make($image_tmp)->resize(300,300)->save($small_image_path);

        // Store image name in products table
        $product->image = $filename;
      }
     }

     $product->save();
     /*return redirect()->back()->with('flash_message_success','Product has been added 
    successfully!');*/
        return redirect('/admin/view-products')->with('flash_message_success','Product has 
   been added successfully!');
   }

    //Categories dropdown start
  $categories = Category::where(['parent_id'=>0])->get();
  $categories_dropdown = "<option value='' selected disabled>Select</option>";
  foreach($categories as $cat){
    $categories_dropdown .= "<option value='".$cat->id."'>".$cat->name."</option>";
    $sub_categories = Category::where(['parent_id'=>$cat->id])->get();
    foreach ($sub_categories as $sub_cat) {
      $categories_dropdown .= "<option value = '".$sub_cat->id."'>&nbsp;--&nbsp;".$sub_cat- 
   >name."</option>";
    }
  }
  //Categories dropdown start

  return view('admin.products.add_product')->with(compact('categories_dropdown'));
  }

 public function editProduct(Request $request, $id=null){

   if($request->isMethod('post')){
     $data = $request->all();
     //echo "<pre>"; print_r($data); die;


     if($request->hasFile('image')){
      $image_tmp = Input::file('image');
      if($image_tmp->isValid()){
        $extension = $image_tmp->getClientOriginalExtension();
        $filename = rand(111,99999).'.'.$extension;
        $large_image_path = 'images/backend_images/products/large/'.$filename;
        $medium_image_path = 'images/backend_images/products/medium/'.$filename;
        $small_image_path = 'images/backend_images/products/small/'.$filename;
        // Resize Images
        Image::make($image_tmp)->save($large_image_path);
        Image::make($image_tmp)->resize(600,600)->save($medium_image_path);
        Image::make($image_tmp)->resize(300,300)->save($small_image_path);

        // Store image name in products table
        $product->image = $filename;
       }
     }

     if(empty($data['description'])){
           $data['description'] = '';
         }


      Product::where(['id'=>$id])->update([/*'category_id'=>$data['category_id'],*/'product_name'=>$data['product_name'],'product_code'=>$data['product_code'],'product_color'=>$data['product_color'],'description'=>$data['description'],'price'=>$data['price'],'image'=>$fileName]);
    return redirect()->back()->with('flash_message_success','Product updated successfully!');
     }

     //Get product details
     $productDetails = Product::where(['id'=>$id])->first();

    //Categories dropdown start
    /*$categories = Category::where(['parent_id'=>0])->get();
    $categories_dropdown = "<option value='' selected disabled>Select</option>";
    foreach($categories as $cat){
    if($cat->id==$productDetails->category_id){
      $selected = "selected";
    }
    else{
      $selected = "";
    }
    $categories_dropdown .= "<option value='".$cat->id."' ".$selected.">".$cat->name." 
    </option>";
    $sub_categories = Category::where(['parent_id'=>$cat->id])->get();
    foreach ($sub_categories as $sub_cat) {
      if($sub_cat->id==$productDetails->category_id){
        $selected = "selected";
      }
      else{
        $selected = "";
      }
      $categories_dropdown .= "<option value = '".$sub_cat->id."' ".$selected.">&nbsp;-- 
   &nbsp;".$sub_cat->name."</option>";
    }
  }
  //Categories dropdown start

   return view('admin.products.edit_product')- 
   >with(compact('productDetails','categories_dropdown'));
   }*/

   public function viewProducts(){
      $products = Product::get();
      $products = json_decode(json_encode($products));
      /*foreach($products as $key => $val){
        $category_name = Category::where(['id'=>$val->category_id])->first();
        $products[$key]->category_name = $category_name->name;
      }*/
      //echo "<pre>"; print_r($products); die;
      return view('admin.products.view_products')->with(compact('products'));
    }

developer_ started a new conversation Syntax Error, Unexpected 'public' (T_PUBLIC)

hi, m trying to add products from admin panel to index, but when i add product then it shows an error "syntax error, unexpected 'public' (T_PUBLIC)", and hilighted the first line which is given below, any solution to resolve it?

code of ProductsController:

  public function viewProducts(){
        $products = Product::get();
        $products = json_decode(json_encode($products));
    
        return view('admin.products.view_products')->with(compact('products'));
   }

developer_ left a reply on Can't Write Image Data To Path

thnx @tokoiwesley there was just a spell mistake and now its working fine

09 Jan
4 months ago

developer_ started a new conversation Can't Write Image Data To Path

hi, m working to show products on index page from db. firstly i added the product from admin panel(add_product) and show it in admin panel(view_product), and when i try to show that product in index page then its name or price are showing but when i try to show the pic then it says "Can't write image data to path (images/backend_images/products/large/18900.jpg)" is there any sol.

code of index.blade.php:

  <img src="{{ asset('images/backend_images/products/small/'.$product->image) }}" alt="IMG- 
  PRODUCT">

code of add_product .blade.php

      <div class="controls">
              <input type="file" name="image" id="image">
            </div>

developer_ left a reply on Undefined Variable: ProductsAll

@manelgavalda thnx by using this return view('index')->withProductsAll($productsALL); its working fine,

developer_ started a new conversation Undefined Variable: ProductsAll

Hi, m new to laravel and working on simple project to show products from db to index page, but it says "Undefined variable: productsAll" this is the error showing by it:

  <?php $__currentLoopData = $productsAll; $__env->addLoop($__currentLoopData); 
  foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env- 
  >getLastLoop(); ?>

here is IndexController:

  public function index()
 {
    $productsALL = Product::get();
    return view('index')->with(compact('productsALL'));
 }

and m working on index page which is:

  @foreach($productsAll as $product)
  <!----------some html code--------->
  @endforeach