Bastet

Bastet

Member Since 3 Weeks Ago

Experience Points 210
Experience Level 1

4,790 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 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.

12 Jun
5 days ago

Bastet started a new conversation Undefined Variable

This might be silly, but I don't know what I'm missing, but I keep getting this error

Undefined variable: shoppingCart

and as far as I know, I'm passing the variable across.

here is my function in the controller

public function getCart()
{

    $shoppingCart = ShoppingCart::where('user_id', Auth::user()->id)->get();
    
    if(Auth::check())
    {

        if($shoppingCart->isEmpty())
        {
            $newShoppingCart = new ShoppingCart();
            $newShoppingCart->user_id = Auth::user()->id;
            $newShoppingCart->cart = json_encode($cart);
            $newShoppingCart->save();
        }else{
            $user_id = Auth::user()->id;
            $updateShoppingCart = ShoppingCart::where('user_id', $user_id)->get();

            foreach($updateShoppingCart as $shoppingCart)
            {
                $shoppingCart->cart = json_encode($cart);
                $shoppingCart->save();
            }
        }
    }



    return view('public.shopping-cart', [
                                        'shoppingCart' => $shoppingCart
                                    ]);

}

and this is the view

@extends('layouts.public')
@section('content')
    <div class="content_wrapper">
        {{ $shoppingCart }}
    </div>
@stop
28 May
2 weeks ago

Bastet left a reply on Destroying Only The Login Session

I'm not sure if I need to make a new question for this or if I can post it on here, but I almost have my cookies working perfectly, but I need to know if there is a way to save the cookies.

So what is happening now is that after I've made a cookie, when I log out I still have that cookie showing and what I would like is that when I log out the cookie is gone but when I log in the cookie is there.

Is that possible? And is it possible to make a cookie unique to a logged in user?

Bastet left a reply on Vue Form Not Hitting Controller Function

@KEVINBUI - Sure here it is -

<?php

/* BEGIN PUBLIC ROUTES */
Auth::routes();
Route::get('/shopping-cart', '[email protected]')->name('product.shoppingCart');
Route::any('/add-to-cart/{id}', '[email protected]')->name('product.addToCart');
Route::any('/add-item/{id}', '[email protected]')->name('product.addItem');
Route::get('/remove-from-cart/{id}', '[email protected]')->name('product.removeFromCart');
Route::get('/remove-row-from-cart/{id}', '[email protected]')->name('product.removeWholeItem');
Route::post('/cart-update/{id}', '[email protected]')->name('cart.update');
Route::get('/account', '[email protected]')->name('account.loginRegister');

Route::get('/', '[email protected]')->name('public.home');

Route::any('search', '[email protected]')->name('search');
Route::get('/category/{category}', '[email protected]')->name('category.item');
Route::get('/product/{slug}', '[email protected]')->name('product.item');
Route::post('/contact', '[email protected]')->name('post.contact');
Route::post('/send-to-cart/{id}', '[email protected]')->name('product.sendToCart');

/* END PUBLIC ROUTES */



24 May
3 weeks ago

Bastet started a new conversation Vue Form Not Hitting Controller Function

I'm not sure if this is a vue question or a laravel one, but I've created a page that a user can select an item to add to a cart. The page in normal laravel but it has a vue component for the select box. The problem I'm having is that even though in my dev tools it's pointing to the correct place I'm not hitting the controller function.

Here is my item.blade.php

@extends('layouts.public')
@section('content')
    <div class="content_wrapper">
        @foreach($single_item as $item)
            <div class="row single_product_wrapper">
                <div class="col-lg-8 col-md-12-col-sm-12 product_details">
                    @foreach($parent_item as $parent)
                        <table style="width: 100%; height: 95px;" border="2" cellspacing="5" cellpadding="5">
                            <tbody>
                                <tr style="text-align: center;">
                                    <td>
                                        <strong>Code</strong>
                                    </td>

                                    @if(!empty($parent->title))
                                        <td>
                                            <strong>Title</strong>
                                        </td>
                                    @endif

                                    @if(!empty($parent->description))
                                        <td>
                                            <strong>Description</strong>
                                        </td>
                                    @endif

                                    @if(!empty($parent->price))
                                        <td>
                                            <strong>Price</strong>
                                        </td>
                                    @endif
                                </tr>

                                <tr style="text-align: center;">
                                    @if(!empty($parent->item_code))
                                        <td>
                                            {{ $parent->item_code }}
                                        </td>
                                    @endif

                                    @if(!empty($parent->title))
                                        <td>
                                            {{ $parent->title }}
                                        </td>
                                    @endif

                                    @if(!empty($parent->description))
                                        <td>
                                            {{ $parent->description }}
                                        </td>
                                    @endif

                                    @if(!empty($parent->price))
                                        <td>
                                            {{ $parent->price }}
                                        </td>
                                    @endif
                                </tr>
                                
                                @if(count($parent->parent))
                                    @foreach($parent->parent as $child)
                                        <tr style="text-align: center;">
                                            @if(!empty($child->item_code))
                                                <td>
                                                    {{ $child->item_code }}
                                                </td>
                                            @endif

                                            @if(!empty($child->title))
                                                <td>
                                                    {{ $child->title }}
                                                </td>
                                            @endif

                                            @if(!empty($child->description))
                                                <td>
                                                    {{ $child->description }}
                                                </td>
                                            @endif

                                            @if(!empty($child->price))
                                                <td>
                                                    {{ $child->price }}
                                                </td>
                                            @endif
                                        </tr>
                                    @endforeach
                                @endif
                            </tbody>
                        </table>
                    @endforeach

                    <!-- BEGIN ADD TO CART FORM -->
                    <div id="app">
                        @foreach($parent_item as $parent)
                            <item-selection :items="{{ $parent_item }}" :children="{{ $parent->parent }}"></item-selection>
                        @endforeach
                    </div>
                    <!-- END ADD TO CART FORM -->
                </div>
            </div>
        @endforeach
    </div>
@stop

and this is my vue

<template>
    <div>
        <form @submit.prevent="submit">
            <div class="row">
                <div class="col-lg-12 item_select">
                    <select name="item_code" id="item_code" class="form-control mb-2 mt-10" v-model="item_parent" required>
                        <option :value="item_parent">Please select your item</option>
                        <option v-for="item in items" :value="item.id">
                            {{ item.item_code }}
                        </option>

                        <option v-for="child in children" :value="child.id">
                            {{ child.item_code }}
                        </option>
                    </select>
                </div>
            </div>

            <input type="submit" class="btn btn-dark btn-lg btn-block" value="Add To Cart">
        </form>
    </div>
</template>

<script>
    import axios from 'axios'

    export default {
        props: [
            'items',
            'children',
            'item_parent'
        ],

        mounted() {
            console.log('Component mounted.')
        },

        methods: {
            submit(){
                var formData = new FormData();

                formData.append('item_code', this.item_parent);

                return axios.post('/add-to-cart/'+this.item_parent, formData)
                            .then(
                                function(response)
                                {
                                     console.log(response.data.redirect);
                                     window.location = response.data.redirect;
                                }
                            );
            },
        },
    }
</script>

and this is my function in my controller

public function getAddToCart(Request $request, $id)
{
    echo "Im here at getAddToCart";
}
22 May
3 weeks ago

Bastet left a reply on Destroying Only The Login Session

@BOBBYBOUWMANN - I think I'm almost there. I had to change

return response()->route('product.shoppingCart', $routeData)->withCookie(Cookie::make('cookieTest', $value));

to

return response(route('product.shoppingCart', $routeData))->withCookie(Cookie::make('cookieTest', $value));

but now when I go to my cart I just get a blank page and my url looks like this

http://shopping-site.test/product/undefined

Bastet left a reply on Destroying Only The Login Session

@BOBBYBOUWMANN - I ended up getting this error

Method Illuminate\Routing\ResponseFactory::route does not exist.

Though would

return response()->route('product.shoppingCart', $routeData)->withCookie(Cookie::make('cookieTest', $value));

work even though I'm using vue.js?

Bastet left a reply on Destroying Only The Login Session

@BOBBYBOUWMANN - I'm still busy looking into it, I'm still having issues trying to understand it and get the cookies to work

21 May
3 weeks ago

Bastet left a reply on Destroying Only The Login Session

@BOBBYBOUWMANN - Ok cool. I will have cookies a look then. Thanks

Bastet started a new conversation Destroying Only The Login Session

I've created a site that uses laravel auth and has multiple sessions that happen after the user logs in. I've also managed to save the sessions into the database. What I'm trying to figure out is how do I log out with out touching the other sessions.