KACKbIP

KACKbIP

Member Since 3 Months Ago

Aktobe

Experience Points
1,630
Total
Experience

3,370 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
9
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.

Level 1
1,630 XP
Feb
12
2 weeks ago
Activity icon

Started a new Conversation Hi, Could You Recommend Me Packages For Education Systems?

Hi I need your help. I need packages related to education systems

Dec
01
2 months ago
Activity icon

Replied to Have A Problem With The Array

I got an error

Uncaught TypeError: Cannot read property 'innerText' of null
Activity icon

Started a new Conversation Have A Problem With The Array


    <script>
        $(document).on('click', '.number-spinner button', function () {
            var btn = $(this);
            var oldValue = btn.closest('.number-spinner').find('input').val().trim();
            var proid = btn.closest('.spin2').find('input').val().trim();
            // var price = document.getElementById('proprice-' + proid).value;

            var oldValue2 = document.getElementById('p-' + proid).innerText;

                newVal = 0;

                newVal2 = 0;
            var all = [oldValue2];

            all = oldValue2;

            alert(all);

            if (btn.attr('data-dir') == 'up') {
                newVal = parseInt(oldValue) + 1;
                newVal2 = parseInt(oldValue2) * newVal;

            } else {
                if (oldValue > 1) {
                    newVal = parseInt(oldValue) - 1;
                    newVal2 =parseInt(oldValue2)  * newVal ;

                } else {
                    newVal = 1;
                    newVal2 = parseInt(oldValue2) * newVal;
                }
            }
            btn.closest('.number-spinner').find('input').val(newVal);
            document.getElementById('p-' + proid).innerText = newVal2;
        });

    </script>

I tried to save to use the variable all as an array. But a new variable is overwrite it. I need to get a value like this:

all = [oldValue2[first_value], oldValue2[second_value] ...]

but it saves all = [oldValue2[last_value], oldValue2[last_value] ...]

Nov
30
2 months ago
Activity icon

Started a new Conversation Hi Guys I Need Help

I want to make increment and decrement cart without loading a page. My Javascript(Ajax)

    <script type="text/javascript">

        $.ajaxSetup({

            headers: {

                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

            }

        });

        $(".increment").click(function(e){

            e.preventDefault();

            var proid = $("input[name=proid]").val();

            var quantity = $("input[name=quantity]").val();



            $.ajax({

                type:'POST',

                url:'one/product/cart',

                data:{proid:proid, quantity:quantity},

             

            });



        });

    </script>

my route

Route::post('one/product/cart', '[email protected]ddingOneProduct')->name('adding.product');

My view

  <div class="row row-count-cart">
    <form method="POST" action="{{ route('adding.product') }}">
        {{ csrf_field() }}
        <div class="small-6 column">
        <input type="hidden" value="{{ $pro->id }}" name="proid">
            <div class="product-count">
                <div class="input-group number-spinner">
                    <div class="input-group-button input-group-btn">
                        <button class="button decrement " type="button" name="decr"  data-dir="dwn" value="true">-</button>
                    </div>
                        <input class="input-group-field" type="number" id="bx_3966226736_2425_quantity" name="quantity" value="{{ \Cart::get($pro->id) ? \Cart::get($pro->id)->quantity : 1 }}" min="1">
                    <div class="input-group-button">
                    <button  class="button increment " type="button" name="inc"  data-dir="up" value="true">+</button>
                    </div>
                </div>
            </div>
        </div>
    <div id="bx_3966226736_2808_basket_actions" class="small-6 columns">
         <button  id="bx_3966226736_2808_buy_link" href="" class="button tiny add2cart" data-preview="#bx_3966226736_2808_pict" data-product-id="2808" type="submit"><span>Купить</span></button>
    </div>
</form>
</div>

my controller

 public function addingOneProduct(Request $request)
    {

        if(isset($request->inc)) {
            if(empty(\Cart::get($request->proid))) {
                $product = Product::where('id', $request->proid)->first();

                \Cart::add(
                    array(
                        'id' => $product->id,
                        'name' => $product->name,
                        'price' => $product->price,
                        'quantity' => 2,
                        'attributes' => array(
                            'image' => $product->image,
                            'discount' => $product->discount,
                        ),

                    ));

                return redirect()->back();
            } else {
                $product = Product::where('id', $request->proid)->first();

                \Cart::update($product->id, array(
                    'name' => $product->name,
                    'price' => $product->price,
                    'quantity' => 1,
                    'attributes' => array(
                        'image' => $product->image,
                        'discount' => $product->discount,
                    ),
                ));

                return redirect()->back();
            }
            
        }
        else if(isset($request->decr))
        {
            $product = Product::where('id', $request->proid)->first();

            \Cart::update($product->id, array(
                'name' => $product->name,
                'price' => $product->price,
                'quantity' => -1,
                'attributes' => array(
                    'image' => $product->image,
                    'discount' => $product->discount,
                ),
            ));


            return redirect()->action('[email protected]');
        }


    }

it works fine without Javascript, but I need to do it without refreshing the page. I can't get incremented and decremented values

Activity icon

Replied to Hi I Started To Learn Js.

Thanks for the shared link

Activity icon

Replied to Hi I Started To Learn Js.

For example, in my situation I have two parts of id the first one is pr- and the second one is {{ $pro->id}}. I know how to get an element by Id if my ID consists of only id="pr" without the second part

Activity icon

Replied to Hi I Started To Learn Js.

or sorry the second ID was added it by mistake

Activity icon

Started a new Conversation Hi I Started To Learn Js.

<div id="bx_price_block " class="number-spinner2">
    <div class="price"  id="pr-{{ $pro->id }}" >
        {{ $pro->price }}
    </div>
</div>

I have to get the value of $pro->price in Javascript. How can I get it?

Activity icon

Replied to Hi Everyone WhereBetween Doesn't Work Properly Somehow

Thank Mr Tray2 for your advice

Activity icon

Replied to Hi Everyone WhereBetween Doesn't Work Properly Somehow

I will convert it into floats.

Activity icon

Replied to Hi Everyone WhereBetween Doesn't Work Properly Somehow

Mr Sinnbeck thanks a lot for your quick reply.

Activity icon

Replied to Hi Everyone WhereBetween Doesn't Work Properly Somehow

Sorry, I solved it. It is because of the type of the price column. It was a float type. I changed it into integer it works fine. I thought it will work fine with the int type numbers too

Activity icon

Replied to Hi Everyone WhereBetween Doesn't Work Properly Somehow

No results. Only when I enter a number by hand I got the results

Activity icon

Replied to Hi Everyone WhereBetween Doesn't Work Properly Somehow

I tried like this, but result is the same

Activity icon

Started a new Conversation Hi Everyone WhereBetween Doesn't Work Properly Somehow

 $products = Product::whereIn('id', $plucked)->whereBetween('price',
                        array($minPrice, $maxPrice))->get();

It works fine when I add a maxPrice number by hand. When I try to do it from my input it doesn't work properly. I have checked the value of $maxPrice. I have got a number there, but somehow it doesn't work ((

Nov
29
2 months ago
Activity icon

Replied to Hi. Is It Possible To Get Variable Names Which Were Generated Dynamically?

I know about it

dd($request->all());

My result is

  "arrFilter_P1_MIN" => null
  "arrFilter_P1_MAX" => null
  "power_i_1" => "50"
  "power_i_4" => "12"
  "filter_5" => "12"
  "set_filter" => null
Activity icon

Started a new Conversation Hi. Is It Possible To Get Variable Names Which Were Generated Dynamically?

For example

    @foreach($specification as $spec)

       <div class="body bx-filter-container-modef">
        <fieldset class="checkbox">
              <input type="checkbox" name="{{ $sp->name }}_{{ $sp->id }}" value="{{ $sp->value }}" id="{{ $sp->name }}_{{ $sp->id }}" class="show-for-sr"   data-tip-top="-5">
             <label data-role="label_{{ $sp->name }}_{{ $sp->id }}" for="{{ $sp->name }}_{{ $sp->id }}" class="bx-filter-param-label">{{ $sp->value }}</label>
          </fieldset>
   </div>

   @endforeach

My controller

 public function getSpecification(Request $request)
    {
        dd($request);
    }
Nov
25
3 months ago
Activity icon

Replied to Missing Required Parameters For [Route: Admin.post.update] [URI: Admin/post/{post}].

"{{ route('admin.post.update', $post->id) }}"

You can write like this but it is the same with this

"{{ route('admin.post.update', $post) }}"
Activity icon

Replied to Missing Required Parameters For [Route: Admin.post.update] [URI: Admin/post/{post}].

Does it work even your post param with the lowercase? Please write it in upper case

 public function update(Request $request, Post $post)
Nov
23
3 months ago
Activity icon

Replied to Hi, How To Save One To One Relationship Data?

Thanks a lot it works fine

Activity icon

Replied to Hi, How To Save One To One Relationship Data?

But I save data at the same time. For example when I create a new product with the multiple image. I don't know the id of the inserted product. If I will get the latest added product id it is not good way to solve the problem.

Activity icon

Replied to Hi, How To Save One To One Relationship Data?

$picture->picture1 = $fileName1;
        $picture->picture2 = $fileName2;
        $picture->picture3 = $fileName3;
        $picture->picture4 = $fileName4;
        $picture->picture5 = $fileName5;



        $picture->picture->save($picture);

I got the same error

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to a member function save() on null

I can't save product_id into the picture table

Activity icon

Replied to Hi, How To Save One To One Relationship Data?

class Picture extends Model
{
    public function product()
    {
        return $this->belongsTo('App\Product');
    }
}

My Picture model

Activity icon

Replied to Hi, How To Save One To One Relationship Data?

 $picture = new Picture();

I will get nothing because I would like to save images into pictures table. There are no a data

Activity icon

Replied to Hi, How To Save One To One Relationship Data?

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to a member function save() on null

It is the error

$picture->picture1 = $fileName1;
        $picture->picture2 = $fileName2;
        $picture->picture3 = $fileName3;
        $picture->picture4 = $fileName4;
        $picture->picture5 = $fileName5;
        
        $picture->product->save($picture);

        $product->save();

When I tried to save data

Activity icon

Replied to Hi, How To Save One To One Relationship Data?

class Product extends Model
{

    public function category()
    {
        return $this->hasOne('App\Category');
    }

    public function option()
    {
        return $this->hasOne('App\Option');
    }

    public function picture()
    {
        return $this->hasOne('App\Picture');
    }

}

My Product model

Activity icon

Started a new Conversation Hi, How To Save One To One Relationship Data?

I am trying to save 6 picture which are related to products

    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->text('description');
            $table->string('image')->nullable();
            $table->string('price')->nullable();
            $table->string('discount')->nullable();
            $table->string('category_id')->nullable();
            $table->string('label')->nullable();
            $table->string('option_id')->nullable();
            $table->text('short_desc')->nullable();
            $table->text('long_desc')->nullable();
            $table->timestamps();
        });
    }

my product table

 public function up()
    {
        Schema::create('pictures', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('picture1')->nullable();
            $table->string('picture2')->nullable();
            $table->string('picture3')->nullable();
            $table->string('picture4')->nullable();
            $table->string('picture5')->nullable();
            $table->string('picture6')->nullable();
            $table->string('product_id')->nullable();
            $table->timestamps();
        });
    }

My pictures table

 public function store(Request $request)
    {
        $product = new Product();

        $product->name = $request->name;
        $product->category_id = $request->category_id;
        $product->description = $request->description;
        $product->price = str_replace(' ', '', $request->price);
        $product->discount = str_replace(' ', '', $request->discount);
        $product->long_desc = $request->long;
        $product->short_desc = $request->short;
        $product->label = $request->options;
        $product->title = $request->title;
        $product->desc = $request->desc;

        $fileName = null;
        if (request()->hasFile('image')) {
            $file = request()->file('image');
            $fileName = rand() . '.' . $file->getClientOriginalExtension();
            $file->move(public_path('images'), $fileName);
        }


        $product->image = $fileName;

        $product->save();

        return redirect('admin/product')->with('success', ' добавили товар.');

    }

My controller

class Product extends Model
{

    public function category()
    {
        return $this->hasOne('App\Category');
    }

    public function option()
    {
        return $this->hasOne('App\Option');
    }

    public function picture()
    {
        return $this->hasOne('App\Picture');
    }

}

My Product model

Nov
11
3 months ago
Activity icon

Started a new Conversation When I Increment Or Decrement All The Values Changed. How To Change Only Specific Value

        jQuery(document).ready(function(){
            // This button will increment the value
            $(".qtyplus").click(function(e){
                // Stop acting like a button
                e.preventDefault();
                // Get the field name
                fieldName = $(this).attr('field');
                // Get its current value
                var currentVal = parseInt($('input[name='+fieldName+']').val());
                // If is not undefined
                if (!isNaN(currentVal)) {
                    // Increment
                    $('input[name='+fieldName+']').val(currentVal + 1);
                } else {
                    // Otherwise put a 0 there
                    $('input[name='+fieldName+']').val(1);
                }
            });
            // This button will decrement the value till 0
            $(".qtyminus").click(function(e) {
                // Stop acting like a button
                e.preventDefault();
                // Get the field name
                fieldName = $(this).attr('field');
                // Get its current value
                var currentVal = parseInt($('input[name='+fieldName+']').val());
                // If it isn't undefined or its greater than 0
                if (!isNaN(currentVal) && currentVal > 1) {
                    // Decrement one
                    $('input[name='+fieldName+']').val(currentVal - 1);
                } else {
                    // Otherwise put a 0 there
                    $('input[name='+fieldName+']').val(1);
                }
            });
        });
</script>

it is my Javascript

 @foreach($cart as $ca)
                            <div class="callout cart-product-item inline-block-container" data-product-id="{{ $ca->id }}" id="{{ $ca->id }}">
                                <div class="inline-block-item vertical-middle cart-product-item-preview">
                                    <img src="{{ asset("images/{$ca->attributes->image}") }}" alt="">
                                </div>
                                <div class="inline-block-item vertical-middle cart-product-item-info">
                                    <div class="inline-block-container">
                                        <div class="inline-block-item vertical-middle cart-product-item-desc">
                                            <a href="/catalog/motokultivatory/motoblok_power_tiller_fgt_7_100g.html" class="cart-product-item-name">
                                                {{ $ca->name }}                                            </a>                                                                                        <a href="#" class="button transparent add2liked" data-ajax="/nl_ajax/favorite.php" data-product-id="2719">
                                                <svg class="icon">
                                                    <use xlink:href="#svg-icon-liked"></use>
                                                </svg>
                                                <span>В избранное</span>
                                            </a>
                                        </div>
                                        <div class="inline-block-item vertical-middle cart-product-item-price medium-up-2 large-up-3">
                                            <div class="column">
                                                <div class="product-count">
                                                    <div class="product-info-caption">Количество</div>
                                                    <div class="input-group">
                                                        <div class="input-group-button">
                                                            <button class="button decrement qtyminus" type="submit" name="decr" field='quantity'>-</button>
                                                        </div>

                                                        <input class="input-group-field" type="number" id="bx_3966226736_2425_quantity" name="quantity" value="{{ $ca ? $ca->quantity : 1  }}" min="1">

                                                        <div class="input-group-button">

                                                                <button  class="button increment qtyplus" type="submit" name="inc" field='quantity' >+</button>
                                                        </div>
                                                    </div>
                                                    <input type="hidden" id="QUANTITY_1323" name="QUANTITY_1323" value="1" />
                                                </div>
                                            </div>
                                            <div class="column float-right">
                                                <div class="product-price">
                                                    <div class="product-info-caption">Итого:</div>
                                                    <div class="main" id="total_price_1323">{{ number_format($ca->price * $ca->quantity) }} ₸.</div>
                                                </div>
                                            </div>
                                            <div class="column show-for-large">
                                                <div class="product-price">
                                                    <div class="product-info-caption">Цена за  штуку</div>
                                                    <div class="main" id="current_price_1323">{{ number_format($ca->price) }} ₸.</div>
                                                    <div class="old" id="old_price_1323" data-old-price="0"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <button class="close-button" type="button" onclick="cartAjaxAction('/nl_ajax/cart.php', 'delete', '1323')">
                                    <span aria-hidden="true">+</span>
                                </button>
                            </div>
                            @endforeach```
this is my view
Nov
09
3 months ago
Activity icon

Replied to How To Make Incrementing And Decrementing In Ajax And Jquery

I just tested it. It will be $quantity. It is not a big deal. My aim is to increment the cart and get the result

Activity icon

Replied to How To Make Incrementing And Decrementing In Ajax And Jquery

{{ csrf_field() }}
                                                            <div class="input-group">

                                                                <input type="hidden" name="proid" value="{{ $pro->id }}">
                                                                <div class="input-group-button">
                                                                    <button class="button decrement" type="button" name="decr">-</button>
                                                                </div>

                                                                <input class="input-group-field" type="number" id="bx_3966226736_2425_quantity" name="quantity" value="{{ \Cart::get($pro->id) ? \Cart::get($pro->id)->quantity : 1  }}" min="1">

                                                                <div class="input-group-button">
                                                                  <button  class="button increment" type="button" name="inc" >+</button>


                                                                </div>
                                                            </div>
                                                        </form>

this is the view

$(document).ready(function() {

    $.ajaxSetup({

        headers: {

            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

        }

    });


    $(".decrement").click(function () {

        // e.preventDefault();

        var quantity = $("input[name=quantity]").val();


        $.ajax({

            type: 'POST',

            url:  'new/product/cart' ,

            data: {quantity:quantity},



        });


    });
});
this is my javascript

public function addOneProduct($id) { $product = Product::where('id', $id)->first();

\Cart::add(
    array(
        'id' => $product->id,
        'name' => $product->name,
        'price' => $product->price,
        'quantity' => 1,
        'attributes' => array(
            'image'  => $product->image,
            'discount' => $product->discount,
        ),

    ));

$menu = Menu::get()->toTree();


$products = Product::all();

$cart = \Cart::getContent();



return view('new', compact('company',
 'products','cart','menu'));

}

Activity icon

Replied to How To Make Incrementing And Decrementing In Ajax And Jquery

I tried to do that, but I didnt get an incremented number

Activity icon

Replied to How To Make Incrementing And Decrementing In Ajax And Jquery

I have already used a shopping cart package. Right now I have to do increment and decrement using ajax and javascript

Activity icon

Replied to How To Make Incrementing And Decrementing In Ajax And Jquery

I know how to do it in pure laravel and I have to do in using javascript and ajax

Activity icon

Started a new Conversation How To Make Incrementing And Decrementing In Ajax And Jquery

                                                                <input type="hidden" name="proid" value="{{ $pro->id }}">
                                                                <div class="input-group-button">
                                                                    <button class="button decrement" type="button" name="decr">-</button>
                                                                </div>

                                                                <input class="input-group-field" type="number" id="bx_3966226736_2425_quantity" name="quantity" value="{{ \Cart::get($pro->id) ? \Cart::get($pro->id)->quantity : 1  }}" min="1">

                                                                <div class="input-group-button">
                                                                  <button  class="button increment" type="button" name="inc" >+</button>


                                                                </div>
                                                            </div>

This is my view

public function addOneProduct($id){ $product = Product::where('id', $id)->first();

    \Cart::add(
        array(
            'id' => $product->id,
            'name' => $product->name,
            'price' => $product->price,
            'quantity' => 1,
            'attributes' => array(
                'image'  => $product->image,
                'discount' => $product->discount,
            ),

        ));

}