hadis

hadis

Member Since 8 Months Ago

Experience Points
2,870
Total
Experience

2,130 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
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 1
2,870 XP
Jun
22
3 weeks ago
Activity icon

Started a new Conversation Add Diffrent Images To A Page

I want to add diffrent images to a page,the_post_thumbnail_url() just show feature image but I don't want to dispaly feature image at all! what should I do? Is there another solution?

Jun
10
1 month ago
Activity icon

Started a new Conversation Warning: Count(): Parameter Must Be An Array Or An Object That Implements Countable

when I use the_content method the error apears.this is what I did:

<div class="b-bottom">
     <p class="sub"><?php the_content(); ?></p>
</div>

what is the problem?

May
22
1 month ago
Activity icon

Started a new Conversation Count(): Parameter Must Be An Array Or An Object

I want to change a html theme to wordpress theme,when I want to show posts I got this error: "Warning: count(): Parameter must be an array or an object that implements Countable in...." and this is the code:

<div class="post-info"><span class="post-category"><a href="#"> سبک زندگی</a></span>
  <header class="post-title">
    <h3 class="serif-font"><a href="#"><?php echo get_the_title(); ?></a></h3>
  </header>
  <div class="post-body">
    <p class="serif-font"><?php  the_content()?></p>
  </div>
<?php
            $args = array(
                    'posts_per_page'=> 3,
                    'offset'=> 0,
                    'category' => '',
                    'category_name' => '',
                    'orderby' => 'post_date' ,
                    'order' => 'DESC',
                    'include' => '',
                    'exclude' => '',
                    'meta_key' => '',
                    'meta_value' => '',
                    'post_type' => 'post',
                    'post_mime_type' => '',
                    'post_parent' => '',
                    'post_status' => 'publish',
                    'suppress_filters' => true,

            );
                $my_posts = query_posts($args);
                foreach ($my_posts as $post){

            ?>

when I use the_content() this error apears! what's the problem?

May
18
1 month ago
Activity icon

Replied to Undefined Variable

ooops yeah thnx

Activity icon

Started a new Conversation Undefined Variable

I want to show user orders and this is what I did:

 @foreach($$orderHistory as $order)
                <div class="with-spacing three-col orders" id="works-grid">
                    <div class="work-item branding ui-ux">
                        <div class="work-detail">
                            <a href="#">
                                <img src="images/portfolio-1.jpg" alt="">
                                <div class="work-info">
                                    <div class="centrize">
                                        <div class="v-center">
                                            <h3>{{ $order->product_name }}</h3>
                                            <p> {{ $order->product_price }}</p>
                                        </div>
                                    </div>
                                </div>
                            </a>
                        </div>
                    </div>
                </div>
                @endforeach

and the error is:" Undefined variable: [{"name":"product 1","qty":15,"product_price":150000}] "

what is the problem?

Activity icon

Replied to SQLSTATE[42S02]: Base Table Or View Not Found

oooops,yeah that was the problem,thanks a lot

Activity icon

Replied to SQLSTATE[42S02]: Base Table Or View Not Found

no,it's singleproducts

Activity icon

Started a new Conversation SQLSTATE[42S02]: Base Table Or View Not Found

I am using this code:

$history = DB::table('cart')
            ->where('user_id', auth()->id())
            ->join(' singleproducts', 'singleproducts.id', '=', 'cart.product_id')
            ->select('singleproducts.name', 'cart.quantity', 'cart.price')
            ->get();

and I have singleproducts table but I got this error "SQLSTATE[42S02]: Base table or view not found: 1146 Table '***. singleproducts' doesn't exist (SQL: select singleproducts.name, cart.quantity, cart.price from cart inner join singleproducts on singleproducts.id = cart.product_id where user_id is null)"

what is the problem?

May
16
1 month ago
Activity icon

Replied to Show Users What They Bought

Cart model?Actully I don't have cart model,this is my cart method:

public  function  addtocart(Request $request){
        $data = $request->all();
        if (empty($data['user_email'])){
            $data['user_email'] = ' ';
        }

        $user_id = Auth::id();

        $session_id = Session::get('session_id');
        if (empty($session_id)){
            $session_id = Str::random(40);
            Session::put('session_id' , $session_id);
        }

        DB::table('cart')->insert(['product_id' => $data['product_id'] ,  'product_name' => $data['product_name'], 'user_id'=>$user_id,
            'product_price' => $data['product_price'], 'qty' => $data['qty'], 'user_email' => $data['user_email'] , 'session_id' => $session_id ]);

        return redirect('cart');
    }

 public function cart(){
        $user_id = Auth::user()->id;
        $session_id = Session::get('session_id');
        $userCart = DB::table('cart')->where(['session_id'=>$session_id])->get();
        foreach ( $userCart as $key=>$product){
            $productDetail = Singleproduct::where('id' , $product->product_id)->first();
            $userCart[$key]->image = $productDetail->image;
        }
        return view('UI.store.cart' , compact('userCart'));
    }
Activity icon

Replied to Show Users What They Bought

For profile just view created and in cart I got user_id but nothing else

Activity icon

Started a new Conversation Show Users What They Bought

I want to create a page that shows users what they bought but I really have no idea how can I do this! can anyone help me in it plz?

May
02
2 months ago
Activity icon

Started a new Conversation SQLSTATE[22007]: Invalid Datetime Forma

I want to add to cart but faced with this error: " SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '[{"id":1}]' for column 'user_id' at row 1 "

CartController:

public  function  addtocart(Request $request){
        $data = $request->all();
        if (empty($data['user_email'])){
            $data['user_email'] = ' ';
        }
        $user_id = User::get('id');
        if (empty($user_id)){
            $user_id = Auth::user()->id;
        }

        $session_id = Session::get('session_id');
        if (empty($session_id)){
            $session_id = Str::random(40);
            Session::put('session_id' , $session_id);
        }

        DB::table('cart')->insert([ 'product_name' => $data['product_name'], 'user_id'=>$user_id,
            'product_price' => $data['product_price'], 'qty' => $data['qty'], 'user_email' => $data['user_email'] , 'session_id' => $session_id ]);

        return redirect('cart');
    }

 public function cart(){
        return $this->hasOne('App\User');
    }
 public function cart(){
        return $this->hasOne('App\Cart');
    }
 Schema::create('cart', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id');
            $table->string('session_id');
            $table->string('product_name');
            $table->string('user_email');
            $table->integer('qty');
            $table->integer('product_price');

            $table->timestamps();
        });
Apr
30
2 months ago
Activity icon

Started a new Conversation How To Assign Value Of User_id From Users Table In Cart?

I want to assign id from Users table as user_id for cart and I want to use many to many relationship this is what I did:

 public function user(){
        return $this->belongsTo('App\User');
    }
public function profile(){
        return $this->hasOne('App\Profile');
    }

next I don't know what should I do :) can anyone help me in it?

Apr
26
2 months ago
Activity icon

Started a new Conversation User_id In Cart

I want to show purchased products in user profie but I dont know how to undrestand which product is for which user

this is add to cart method:

public  function  addtocart(Request $request){
        $data = $request->all();
     
        $session_id = Session::get('session_id');
        if (empty($session_id)){
            $session_id = Str::random(40);
            Session::put('session_id' , $session_id);
        }
        DB::table('cart')->insert(['product_id' => $data['product_id'], 'product_name' => $data['product_name'],
            'product_price' => $data['product_price'], 'qty' => $data['qty'], 'session_id' => $session_id ]);

        return redirect('cart');
    }

and user model:

protected $fillable = [
         'name','email', 'password', 'admin'
    ];

Can someone give me a solution?

Apr
20
2 months ago
Activity icon

Started a new Conversation Install Npm And Gulp

I am pretty new to using terminal and installing gulp.node js,npm and gulp install properly and even it returns me version of them but when I use gulp watch it returns me " No gulpfile found "

what is the problem?

Apr
15
2 months ago
Activity icon

Replied to Download As Unknown File

yup,it's the file i uploaded

Apr
14
2 months ago
Activity icon

Started a new Conversation Download As Unknown File

I want to download a pdf file from storage

 public function show($free)
    {
        $dl = SingleFreeDownload::find($free);
        return Storage::download($dl->file , $dl->title);
    }

and this is the file storage code:

 public function store(Request $request)
    {
	 $file = $request->file('file')->store('uploads');
	$single_download_page=[
		 'file' => $file, ];
SingleFreeDownload::create($single_download_page);
}

when I click on download button it downloads unknown file and it not open what is the problem?

Apr
07
3 months ago
Activity icon

Started a new Conversation Gulp Installation Error Source-map-resolve

I am pretty new to using terminal and installing gulp.while installing it has error. I am using windows10 this is the error:

$ npm install gulp-cli -g npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated

github links recomends me to install source-map-resolve but It has an error too!

$ npm install source-map-resolve npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\peyvand\package.json' npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\peyvand\package.json' npm WARN peyvand No description npm WARN peyvand No repository field. npm WARN peyvand No README data npm WARN peyvand No license field. [email protected] updated 1 package and audited 6 packages in 2.104s found 0 vulnerabilities

can anyone help me to install gulp?

Apr
02
3 months ago
Activity icon

Started a new Conversation Laravel Shopping Cart

When I click on submit button it go to cart but nothing show! actully I think it's because of addtocart() method

public  function  addtocart(Request $request){
        $data = $request->all();
        if (empty($data['user_email'])){
            $data['user_email'] = ' ';
        }
    $session_id = Session::get('session_id');
        if (empty($session_id)){
            $session_id = Str::random(40);
            Session::put('session_id' , $session_id);
        }
        $countProducts =DB::table('cart')->where(['product_id' => $data['product_id'] , 'product_name'=>$data['product_name'],
             'session_id'=>$session_id  ])->count();

        if ($countProducts > 0 ){
            DB::table('cart')->insert(['product_id' => $data['product_id'], 'product_name' => $data['product_name'],
                'product_price' => $data['product_price'], 'qty' => $data['qty'], 'user_email' => $data['user_email'], 'session_id' => $session_id]);
        }
        return redirect('cart');

    }

When I click on submit button it go to cart but nothing show! actully I think it's because of addtocart() method

when I var_dump $data it return product detail but when I var_dump $countProducts return int(0)

what is the problem?

and this is cart method and blade:

 public function cart(){
        $session_id = Session::get('session_id');
        $userCart = DB::table('cart')->where(['session_id'=>$session_id])->get();

        foreach ( $userCart as $key=>$product){
            $productDetail = Singleproduct::where('id' , $product->product_id)->first();
            $userCart[$key]->image = $productDetail->image;
        }

    return view('UI.store.cart' , compact('userCart'));
 @foreach( $userCart as $cart)
                    <tr class="cart_item">
                        <td class="hidden-xs"><a href="{{ url('/cart/delete/' . $cart->id) }}"><i class="hc-close"></i></a>
                        </td>
                        <td class="hidden-xs">
                            <a href="#">
                                <img src="{{ $cart->image }}" alt="">
                            </a>
                        </td>
                        <td><a href="#">{{ $cart->product_name }}</a>
                        </td>
                        <td><span>{{ $cart->product_price }}</span>
                        </td>
                        <td>'
                            <div class="cart_quantity_button">
                                <a class="cart_quantity_up" href="{{ url('/cart/update_quantity/'.$cart->id.'1') }}"> + </a>
                                <input class="cart_quantity_input" type="text" step="1" min="0" value="{{ $cart->qty }}" title="Qty" placeholder="Qty">
                            @if($cart->qty > 1)
                                <a class="cart_quantity_down" href="{{ url('/cart/update_quantity/'.$cart->id.'/-1') }}"> - </a>
                                @endif
                            </div>
                        </td>
                        <td class="product-subtotal"><span>{{ $cart->product_price*$cart->qty }}</span>
                        </td>
                    </tr>
                    @endforeach
Mar
30
3 months ago
Activity icon

Started a new Conversation Image Update Problem

When I edit and update a data the image change to xxx.temp instead of xxx.png or jpg

 public function update(Request $request,$id)
    {
        $data = Singleproduct::find($id);
        $data->name = $request->name;
        $data->explain = $request->explain;
        $data->price = $request->price;
        $data->parent_name = $request->parent_name;
        $data->image = $request->image;

        $data->save();

        return redirect(route('product.index'));
    }

what is the problem?

Mar
28
3 months ago
Activity icon

Started a new Conversation Update Method

when I submit edit form I get this error: "The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE. "

Route::get("/allProducts/edit/{id}","[email protected]")->name('Allproduct.edit');
Route::post("/allProducts/update/{id}","[email protected]")->name('Allproduct.update');
 <form class="form-horizontal tasi-form" method="post" enctype="multipart/form-data"
                      action="{{ route('allProducts.update' , [ 'id'=>$allproduct->id ]) }}">
                    {{ csrf_field()}}
                  
  public function update(Request $request, $id)
    {
       $data = Allproduct::find($id);

        $data->name = $request->name;
        $data->save();

        return redirect(route('allProducts.index'));
    }

what's the problem?

Mar
27
3 months ago
Activity icon

Replied to Property [video] Does Not Exist On This Collection Instance.

but actully I want to show just the last item in database and when i use Index::last() it return an error

Activity icon

Started a new Conversation Property [video] Does Not Exist On This Collection Instance.

I want to show video in view but I don't know how!!

                            <video width="320" height="240" controls>
                                <source src="{{ URL::asset($about->video)}}" type="video/mp4">
                            </video>
public function store(Request $request)
        {
            $video = $request->file('video')->store('uploads');
            $new_file_data = [
                'about' => $request->input('about'),

                //video storage
                'video' => $video,
            ];
            Index::create($new_file_data);

            return view('admin.index.index');
    }
  $about = Index::get();
         return view('welcome' , compact( 'about' ) ;

I am using this but it has error

Activity icon

Started a new Conversation Call To Undefined Method App\Index::last()

I want show the last data in database and I'm using last() meyhod but this error "Call to undefined method App\Index::last() "!!

  $about = Index::get();
         return view('welcome' , compact( 'about');

                    @foreach( $about as $show)
                    <div class="icon-box align-center">
                        <div class="animated-icon gradient-icon" data-icon="images/icons/pencil-ruler.svg" data-gradients="#ff795f,#ce1768"></div>
                        <div class="ib-content">
                            <h3>{!! $show->last()->about !!}</h3>
                        </div>
                    </div>
                        @endforeach
            

Mar
26
3 months ago
Activity icon

Started a new Conversation SQLSTATE[42S02]: Base Table Or View Not Found: 1146 Table '***.indices' Doesn't Exist

I have table indexpage but still have this error! this is my code:

   public function up()
    {
        Schema::create('indexpage', function (Blueprint $table) {
            $table->increments('id');
            $table->text('about');
            $table->string('video');
            $table->timestamps();
        });
    }
Mar
25
3 months ago
Activity icon

Started a new Conversation SQLSTATE[HY000] [2002] No Connection Could Be Made Because The Target Machine Actively Refused It.

I have changed upload_max_filesize,post_max_size and memory_limit and now I got this error "No connection could be made because the target machine actively refused it." what is the problem?

Mar
21
3 months ago
Activity icon

Started a new Conversation Missing Required Parameters

I want to show a single page that relate to an topic but I have this problem: Missing required parameters for [Route: ui.singlefreedownload.show] [URI: Singlefreedownload/{free}]

and this is my code:

public function show($free)
    {
        $singlefile = SingleFreeDownload::findOrFail($free);
        return view('UI.freeDownload.SingleFreeDownload' , compact('singlefile' ));
    }
Route::get('/Singlefreedownload/{free}' , 'admin\[email protected]')->name('ui.singlefreedownload.show');
     <div class="container">
                <div class="col-md-5 col-sm-7 col-md-offset-7 col-sm-offset-5">
                    <div class="title">
                        <h2 data-bigletter="R">{{ $free->title }}</h2>
                        <h4>{{ $free->big_image }}</h4>
                    </div>
                    <div class="pricing-footer"><a class="btn btn-color upper no-radius" data-custom-bg="#2A68FC" href="#">دانلود</a>
                    </div>
                </div>
            </div>
Activity icon

Started a new Conversation Trying To Get Property 'image' Of Non-object

I want to show every thig in my database but I have this error and this is my code:

        @foreach( $free as $freelist)
        <div class="grid-posts-wrapper">
            <article class="card-post">
                <div class="card-post-wrapper">
                    <div class="card-post-image">
                        <a href="#">
                            <img src="{{ $freelist->image }}" alt="">
                        </a>
                    </div>
                    <div class="card-post-content">
                        <div class="post-body">
                            <h3><a href="#">{{ $freelist->title }} </a></h3>
                        </div>
                        <div class="pricing-footer"><a class="btn btn-color upper no-radius" data-custom-bg="#2A68FC" href="free-single.html">ادامه مطلب</a>
                        </div>
                    </div>
                </div>
            </article>
        </div>
        @endforeach
      

controller:

   public function show(FreeDownloadList $free)
    {
        return view('UI.freeDownload.FreeDownload' , compact('free' ));
    }

model:

 protected  $fillable = [
        'title' , 'image',
    ];
Mar
05
4 months ago
Activity icon

Replied to Shopping Cart

I have look there but most of them are packages and I don't want package

Mar
04
4 months ago
Activity icon

Started a new Conversation Shopping Cart

I have search a lot to find how to build shopping cart but I found nothig can you suggest me a good website or a learning source for this? by the way I am using laravel5.8

Mar
03
4 months ago
Activity icon

Replied to Call To Undefined Method Darryldecode\Cart\Cart::count()

I change it as you said but now something weird happen!! I have chosen 4 product but it shows just one and this is diffrent for each product but none of them is not right!!

Activity icon

Started a new Conversation Call To Undefined Method Darryldecode\Cart\Cart::count()

I am using darryldecode package shoppingcart but I have some issuse with it when I want to count products I got this error:Call to undefined method Darryldecode\Cart\Cart::count()

an this is cart view:

<section>
    <div class="container">
        <div class="row">
            <div class="col-md-8 mb-50">
                <table class="table" id="shopping-cart">
                    <thead>
                    <tr>
                        <th class="hidden-xs"> </th>
                        <th class="hidden-xs">تصویر</th>
                        <th>محصول</th>
                        <th>قیمت</th>
                        <th>تعداد</th>
                        <th>مجموع</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach(\Cart::getContent() as $pdt)
                    <tr class="cart_item">
                        <td class="hidden-xs"><a href="#"><i class="hc-close"></i></a>
                        </td>
                        <td class="hidden-xs">
                            <a href="#">
                                <img src="images/shop-1.jpg" alt="">
                            </a>
                        </td>
                        <td><a href="#">بیش از حد پررنگ</a>
                        </td>
                        <td><span>.99</span>
                        </td>
                        <td>
                            <input class="form-control" type="number" step="1" min="0" value="1" title="Qty" placeholder="Qty">
                        </td>
                        <td class="product-subtotal"><span>.99</span>
                        </td>
                    </tr>
                    @endforeach
                    </tbody>
                </table>
                <div class="coupon-form">
                    <div class="input-group">
                        <input class="form-control" type="text" placeholder="Coupon code">
                        <div class="input-group-btn">
                            <button class="btn btn-dark btn-block" type="button">ثبت کد تخفیف</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="cart-summary">
                    <div class="title">
                        <h6>جزییات سفارش</h6>
                    </div>
                    <table class="shop_table shop_table_responsive table">
                        <tbody>
                        <tr class="order-total">
                            <th>مجموع</th>
                            <td>
                                <h6>.99</h6>
                            </td>
                        </tr>
                        <tr class="order-total count">
                            <th>تعداد</th>
                            <td>
                                <h6>{{ \Cart::count() }}</h6>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="proceed-to-checkout">
                        <button class="btn btn-dark btn-block" type="button">ادامه جهت تسویه حساب</button><!--<a class="btn btn-color btn-block" href="#"></a>-->
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

what is the problem?

Mar
01
4 months ago
Activity icon

Replied to Trying To Get Property Of Non-object In Laravel Shopping Cart

I edited it as you said but still have that error(Trying to get property 'id' of non-object) and the above blade edited

Activity icon

Replied to Trying To Get Property Of Non-object In Laravel Shopping Cart

<form action="{{ route('cart.add') }}" method="post">
        {{ csrf_field()}}
    <section class="grey-bg">
        <div class="container">
            <div class="row">
                <div class="col-md-6">
                    <div class="row">
                        <div class="single-product-id">
                            <h3 name="id">{{ $singleproduct->id }}</h3>
                        </div>
                        <div class="col-sm-10 pull-md-right">
                            <div class="images-gallery" id="product-slider">
                                <img src="{{ asset($singleproduct->image )  }}" alt="">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-5 col-md-offset-1">
                    <div class="single-product-ratings">
                        <div class="product-rating"><span class="product-stars"><span class="product-rating-stars" data-width="90"></span></span>
                        </div>
                    </div>
                    <div class="title">
                        <h2  name="name">{{ $singleproduct->name }}</h2>
                    </div>
                    <div class="single-product-price">
                        <h3 name="price">{{ $singleproduct->price }}</h3>
                    </div>
                    <div class="single-product-desc">
                        <p>{!! $singleproduct->explain  !!} </p>
                    </div>
                    <div class="single-product-add">
                            <div class="input-group">
                                <input class="form-control" type="number" placeholder="QTY" name="qty" value="1" min="1">
                                <span class="input-group-btn"><button class="btn btn-dark" href=""  type="submit">افزودن به سبد خرید</button></span>
                            </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    </form>

Activity icon

Replied to Trying To Get Property Of Non-object In Laravel Shopping Cart

actually I have 3 product in database

Activity icon

Replied to Trying To Get Property Of Non-object In Laravel Shopping Cart

dd($request->input('id')); return null!what should I do?

Feb
29
4 months ago
Activity icon

Started a new Conversation Trying To Get Property Of Non-object In Laravel Shopping Cart

I am using darryldecode for shopping cart in my project

this is my shoppingcartController and add method:

public function add(){

         public function add(Request $request){

        $pdt = Singleproduct::find($request->input('id'));

       \Cart::add(array(
            array(
                'id' => $pdt->id,
                'name' => $pdt->name ,
                'price' => $pdt->price,
                'quantity' => \request()->qty ,
            )));

    }

and this is route list:

Route::post('/cart/add'  ,  'admin\[email protected]')->name('cart.add');

and in my SingleProduct i have id,price and name!

the error is:"Trying to get property 'id' of non-object"

where is the problem??

Feb
25
4 months ago
Activity icon

Replied to SQLSTATE[22007]

I cant use two increament!!

" SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table file_products (id int unsigned not null auto_increment primary key, file_id int unsigned not null auto_increment primary key, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci') "

Activity icon

Started a new Conversation SQLSTATE[22007]

I have package and file pages when I click on file name of files show apear and I select files I want and submit it to file_products table,this table show files that relate to a package this is my code:

file_products table:(this table show relation)

 public function up()
    {
        Schema::create('file_products', function (Blueprint $table) {
            $table->integer('id');  //product id
            $table->integer('file_id');
            $table->timestamps();
        });
    }

files table:

public function up()
    {
        Schema::create('product_files', function (Blueprint $table) {
            $table->increments('id');
            $table->string('file_name');
            $table->string('file_explain');
            $table->string('file');

            $table->timestamps();
        });
    }

product table:

 public function up()
    {
        Schema::create('singleproducts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->text('explain');
            $table->string('image');
            $table->string('price');
            $table->timestamps();
        });
    }

and the error is: " SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column 'file_id' at row 1 (SQL: insert into file_products (file_id, id) values (, 1)) "

Feb
24
4 months ago
Activity icon

Replied to Undefined Variable: Product_item

sorry it was my mistake! I edited it

Activity icon

Started a new Conversation Undefined Variable: Product_item

I want to update my selection this is my code:

productSync.blade:

 @if( $files && count($files) > 0)
        <form action="{{ route('product.updatesync_files' , [ 'id' => $product_item]) }}" method="post"  enctype="multipart/form-data">
            {{ csrf_field()  }}
            <h3 style="color: black; ">فایل مربوطه:</h3>
            <section class="panel">
                <table class="table table-striped table-advance table-hover">
            <ul>
                @foreach($files as $file)
                    <li>
                        <input type="checkbox" name="files[]" value="{{ $file->file_id  }}" {{ isset($id) && in_array($file->id,$id) ? 'checked':''  }}>
                        {{ $file->file_name }}
                    </li>
                @endforeach
            </ul>
            <div class="form-group">
                <input type="submit" class="btn btn-danger" name="submit_product_files" value="ذخیره اطلاعات">
            </div>
                </table>
            </section>
        </form>
    @endif

controller:

    public  function updatesyncFiles(Request $request , $id){
       $product_item = Singleproduct::find($id);
        $files = $request->input('files');
        if ($product_item && is_array($files)){
            $product_item->file()->sync($files);
        }
        return view('admin.SingleProduct.productSync', [
            'product_item' => $product_item
        ]);
 public  function syncFiles(Request $request , $id){
        $files = product_file::all();
      $product_item = Singleproduct::find($id);
      $product_files = $product_item->file()->get()->pluck('id')->toArray();
        return view('admin.SingleProduct.productSync'  , compact('files' , 'product_files'));
   }

route:

   Route::get('/product/sync_files/{id}', '[email protected]')->name('product.sync_files');
    Route::post('/product/updatesync_files/{id}', '[email protected]')->name('product.updatesync_files');

and the error is: "Undefined variable: product_item" in productSync.blade.php

Feb
18
4 months ago
Activity icon

Replied to The POST Method Is Not Supported For This Route. Supported Methods: GET, HEAD

this is update method,I think $product_item is the parameter that show update,is it right? because when I use $product_item in blade I get " Undefined variable: product_item " error!!

    public  function updatesyncFiles(Request $request , $id){
        $product_item = Singleproduct::find($id);
        $files = $request->input('files');
        if ($product_item && is_array($files)){
            $product_item->file()->sync($files);
        }
Activity icon

Replied to The POST Method Is Not Supported For This Route. Supported Methods: GET, HEAD

I did it and now I have this error: " Missing required parameters for [Route: product.sync_files] [URI: admin/product/sync_files/{id}]. "!!!

Activity icon

Started a new Conversation The POST Method Is Not Supported For This Route. Supported Methods: GET, HEAD

I want to select a title and send it to database but as I submit it I receive "The POST method is not supported for this route. Supported methods: GET, HEAD." error and this is my code:

productSync.blade:

@if( $files && count($files) > 0)
        <form action="" method="post">
            {{ csrf_field()  }}
            <h3 style="color: black; ">فایل مربوطه:</h3>
            <section class="panel">
                <table class="table table-striped table-advance table-hover">
            <ul>
                @foreach($files as $file)
                    <li>
                        <input type="checkbox" name="files[]" value="{{ $file->file_id  }}" {{ isset($id) && in_array($file->id,$id) ? 'checked':''  }}>
                        {{ $file->file_name  }}
                    </li>
                @endforeach
            </ul>
            <div class="form-group">
                <input type="submit" class="btn btn-danger" name="submit_product_files" value="ذخیره اطلاعات">
            </div>
                </table>
            </section>
        </form>
    @endif

route list:

Route::get('/product/sync_files/{id}', '[email protected]')->name('product.sync_files');
    Route::post('/product/updatesync_files/{id}', '[email protected]')->name('product.updatesync_files');