Lars-Janssen

Lars-Janssen

Member Since 3 Years Ago

Tilburg

Experience Points 145,775
Experience Level 30

4,225 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 906
Lessons
Completed
Best Reply Awards 47
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.

22 Apr
1 month ago

Lars-Janssen started a new conversation Vue.js Some Items In Card Are Not Reactivity

Hi,

I'm struggling with this problem for days now. I hope someone can help me out.

I have a checkout card where I'm trying to update the quantity and total price. :

The parent component:

<template>
    <div>
        <upsell-checkout-product
                :product="product"
                :index="index"
                @remote="remove"
                @increment="increment"
                @decrement="decrement"
        ></upsell-checkout-product>
    </div>
</template>

<script>
    export default {
        props: {
            runId: {
                type: String,
                default: null
            },
            card: {
                type: Array,
                default: null
            },

            customer: {
                type: Object,
                default: null
            },

            order: {
                type: Object,
                default: null
            }
        },

        data() {
            return {
                localCard: []
            }
        },

        mounted() {
            this.localCard = this.card;
        },

        methods: {
            increment(index) {
                Vue.set(this.localCard[index], 'quantity', this.localCard[index].quantity+=1);
            },

            decrement(index) {
                if(this.localCard[index].quantity > 0) {
                    this.localCard[index].quantity--;
                }
            },

            remove(index) {
                this.localCard.splice(index, 1);
            }
        }
    }
</script>

Child component:

   <template>
        <div class="text-green">
            <div class="flex center p-2">
                <div class="w-1/3">
                    <img class="rounded-full h-24 w-24 border border-green"
                         :src="'/storage/articles/' + product.article.image_url"
                         v-if="product.article.image_url"
                    />
                </div>

                <div class="w-2/3">
                    <h3>{{ product.article.name }}</h3>

                    <h5 class="mt-2">Bestaalstatus</h5>

                    <div>
                        <div class="bg-red text-white text-xs mt-2 rounded p-1 w-1/3">
                            Niet voldaan
                        </div>
                    </div>
                </div>
            </div>

            <div class="center justify-between p-2 border-t border-b border-dotted border-green">
                <div class="w-1/5">
                    <div class="cursor-pointer" @click="$emit('remove', index)">
                        x
                    </div>
                </div>

                <div class="center w-2/5">
                    <div class="cursor-pointer" @click="$emit('decrement', index)">
                        -
                    </div>

                    <input type="number"
                           class="input-main w-1/2 ml-1 mr-1 h-8"
                           v-model="product.quantity">

                    <div class="cursor-pointer" @click="$emit('increment', index)">
                        +
                    </div>
                </div>

                <div class="flex justify-end w-2/5">
                    <div v-if="product.article.member_discount_percentage">
                        <p class="text-sm">€ <strike>{{ price }}</strike> - € {{ discountPrice }}</p>
                    </div>

                    <div v-else>
                        <p class="text-sm">€ {{ discountPrice }}</p>
                    </div>
                </div>
            </div>
        </div>
    </template>

    <script>
        export default {
            props: ['product', 'index'],

            computed: {
                price: function() {
                    return (this.product.quantity * this.product.article.price).toFixed(2);
                },

                discountPrice: function() {
                    return (this.product.quantity * this.product.article.discount_price).toFixed(2);
                }
            }
        }
    </script>

The problem is that card item's I already fetched from the server are reactive in the localCard, but item's that have not been fetched from the server but added throughout the checkout process are not...

I already tried to make a JsFiddle but I can't reproduce the problem. Obviously it's a reactivity problem, but I have no idea how I should fix this.

enter image description here

I need some help here, thank you!

05 Feb
3 months ago

Lars-Janssen started a new conversation Redirect Site With Query Param

Hi,

I'm using forge and I have 2 domains:

example.nl
example.com

I need to redirect example.nl to example.com?lang=nl.

The domains are already pointing to the same server. How could I get this working?

Is this possible with Forge?

Thanks!

13 Dec
5 months ago
06 Dec
5 months ago

Lars-Janssen left a reply on Get Download Link Of A File In Laravel 5.7

Create a symlink ``php artisan storage:link```

23 Nov
6 months ago

Lars-Janssen left a reply on Laravel Observer Created

@andreich1980 that's the problem it's not created in the database, while I would expect this. Do I need to use another observer method for this?

Lars-Janssen left a reply on Laravel Observer Created

@andreich1980 I see that in the db :)

Lars-Janssen started a new conversation Laravel Observer Created

Hi,

I'm using an observer with a created method.

class ClientProductObserver
{
    public function created(Product $clientProduct): void
    {
    }
}

When I receive the $clientProduct here I would expect it to be already save to the database. However when I dd() here the clientProduct is not saved?

What am I doing wrong here?

22 Nov
6 months ago

Lars-Janssen started a new conversation Laravel Nova Filter Only On Pivot Table

Hi,

I've got a project that BelongsToMany Employees. I use a pivot table for that on that pivot table is a value is_project_manager.

Is it possible to add a filter on this ?

Thanks

17 Nov
6 months ago

Lars-Janssen left a reply on How To Use Access Token Without Filling It Inside The Postman?

If you have the new postman you can go to the tab Authorization here you can select Bearer and pass the token.

Lars-Janssen left a reply on Nova Actionable - How To Extend Or Show Field

You can use observers for that. When for example a user is created you can hook into that. https://appdividend.com/2018/01/02/laravel-model-observers-tutorial-example/

16 Nov
6 months ago

Lars-Janssen left a reply on Valet Storage Link?

I't can't happen by default. Maybe you did it by accident?

07 Nov
6 months ago
11 Oct
7 months ago

Lars-Janssen left a reply on Requesting And Bundling Vendor Libraries With Mix

@Cvetan you can do it like this:

mix.styles([
    'public/css/vendor/normalize.css',
    'public/css/vendor/videojs.css'
], 'public/css/all.css');

Lars-Janssen left a reply on Issue With Retrieving Value From Model And Increasing It By One

Try this:

 $views = Globals::where('name', 'Contador de visitas')->first();
 $views->int_value = $views->int_value++;
 $views->save();
05 Oct
7 months ago

Lars-Janssen left a reply on Webserver Or Forge Or AWS

I think you should start simple. And when your site grows you should upgrade. Maybe you can start with the hobby plan on forge?

03 Oct
7 months ago

Lars-Janssen left a reply on Horizon Is Not Showing Jobs

@D9705996 never mind now it suddenly works whutt haha thanks for you help.

Lars-Janssen left a reply on Horizon Is Not Showing Jobs

@D9705996

Thanks for helping. I did had indeed QUEUE_CONNECTION I changed that but still not working. It's the first time I set this up in Forge. I did restart the daemon!

APP_ENV=local
APP_KEY=base64:CiyCasdfsdfasdf
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydb
DB_USERNAME=forge
DB_PASSWORD=mypassword

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_CONNECTION=redis

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_KEY=
PUSHER_SECRET=
PUSHER_APP_ID=

Lars-Janssen started a new conversation Horizon Is Not Showing Jobs

Hi,

I'm using Horizon in Laravel Forge.

The problem is that I don't see any jobs being handled. I've created a daemon in forge that runs php artisan horizon. The status of Horizon is Active.

When I run my command that fires several Jobs:

 UpdateWeatherJob::dispatch($port, $this->buildUrl($port));
<?php

namespace App\Jobs;

use App\Models\Port;
use GuzzleHttp\Client;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class UpdateWeatherJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * @var Port
     */
    public $port;

    /**
     * @var String
     */
    public $url;

    /**
     * UpdateWeatherJob constructor.
     * @param Port $port
     * @param String $url
     */
    public function __construct(Port $port, String $url)
    {
        $this->port = $port;
        $this->url = $url;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        sleep(5);
    }
}

Nothing happens in Horizon? What could be wrong here?

13 Sep
8 months ago

Lars-Janssen left a reply on Lumen Intro

Lumen is the lightweight version of Laravel. That's why it's faster too.

10 Sep
8 months ago

Lars-Janssen left a reply on Instantiate Object

Maybe in the future they will be available out of the box https://wiki.php.net/rfc/typed_properties_v2

07 Sep
8 months ago

Lars-Janssen left a reply on Use KeyBy('name') On Eager-loaded Relation

Did it like this:

$ports = Port::filter($filters)
        ->with('scores')
        ->actives()
        ->paginate(14);

foreach($ports as $port) {
    $port->setRelation('scores', $port->scores->keyBy('name'));
}

Lars-Janssen started a new conversation Use KeyBy('name') On Eager-loaded Relation

Hi,

I've got this in my controller:

return Port::filter($filters)
            ->with('scores')
            ->actives()
            ->paginate(14);

Scores relation looks like this:

public function scores()
{
    return $this->hasMany(Score::class)
        ->select("id", "port_id", "name", DB::raw('AVG(score) as score'))
        ->groupBy('port_id', 'name');
}

Eager loaded response is this:

How do I rename the array keys 0 and 1 to the properties ("COSTS" and "SAIL_BOAT_FRIENDLY") ?

Thanks

15 Aug
9 months ago

Lars-Janssen left a reply on Connect Laravel With Third-party API That Requires A API-key

The api key goes in the header or url. There is no standard location in Laravel where you should put it.

01 Aug
9 months ago

Lars-Janssen started a new conversation Vue.js Form Validation

Hi,

I'm using https://github.com/laracasts/Vue-Forms for form validation.

However I have a very weird problem. When I try this:

<span class="help is-danger" v-if="form.errors.has('name')" v-text="form.errors.get('name')"></span>

It's always false even when I receive a name validation failure.

When I check the has method I see this:

 has(field) {
        return this.errors.hasOwnProperty(field);
    }

If I console.log(this.errors); in this method I see this:

So there is a property called name. Why do I receive always false!

10 Jul
10 months ago

Lars-Janssen left a reply on Running My Tests Empties My Database

@unlikenesses no idea config:clear is sometimes magic :)

Lars-Janssen left a reply on Running My Tests Empties My Database

Try php artisan config:clear

Lars-Janssen left a reply on Notifications Without Eloquent User Model

You can insert it yourself right? With db facade. See here: https://laravel.com/docs/5.6/queries#inserts

Lars-Janssen left a reply on Running My Tests Empties My Database

Try this trait:


use DatabaseMigrations;

Namespace:

use Illuminate\Foundation\Testing\DatabaseMigrations;

Lars-Janssen left a reply on Notifications Without Eloquent User Model

Like this:

Notification::route('mail', '[email protected]')
            ->route('nexmo', '5555555555')
            ->notify(new InvoicePaid($invoice));
01 Jul
10 months ago

Lars-Janssen started a new conversation Laravel Validation Validated

Hi,

I've got this code:

$request->merge([
    'address' => $location['formatted_address'],
    'lat' => $location['lat'],
    'long' => $location['lng']
]);

return $this->locationRepo->store($request->validated());

Is it possible to make the merge validated? Because right now it does not save my merge.

Thx!

25 Jun
10 months ago

Lars-Janssen started a new conversation Changing Card Nothing Is Added?

Hi,

When I want to change the default card that Spark is making:

var base = require('settings/subscription/subscribe-stripe');

Vue.component('spark-subscribe-stripe', {
    mixins: [base],

    methods: {
        /**
         * Create a Stripe Card Element.
         */
        createCardElement(container){
            if (!this.stripe) {
                throw "Invalid Stripe Key/Secret";
            }

            var card = this.stripe.elements().create('card', {
                hideIcon: true,
                hidePostalCode: true,
                style: {
                    base: {
                        '::placeholder': {
                            color: '#aab7c4'
                        },
                        fontFamily: '  \'Whitney A\',\n' +
                        '            \'Whitney B\',\n' +
                        '            \'-apple-system\',\n' +
                        '            \'BlinkMacSystemFont\',\n' +
                        '            \'Segoe UI\',\n' +
                        '            \'Roboto\',\n' +
                        '            \'Oxygen\',\n' +
                        '            \'Ubuntu\',\n' +
                        '            \'Cantarell\',\n' +
                        '            \'Fira Sans\',\n' +
                        '            \'Droid Sans\',\n' +
                        '            \'Helvetica Neue\'',
                        color: '#606f7b',
                        fontSize: '15px',
                        background: 'red',
                        padding: '20px'
                    }
                }
            });

            card.mount(container);

            return card;
        }
    },
});

Nothing happens? I see no background color and no padding. But the font family does change!

What am I doing wrong here?

Lars-Janssen left a reply on On Page Back I Only See JSON

@click thanks how does your interceptor look like? @bwrice when I do that I've the same result.

24 Jun
10 months ago

Lars-Janssen started a new conversation On Page Back I Only See JSON

Hi,

I've got a controller method:

public function index()
{
    if (request()->ajax()) {
        // Here I have a long query.....
        
        return request()->page ? $query->paginate(15) : $query->get();
    }
    
    return view('ads.ads');
}

So when the request is ajax I return json, otherwise I return a view. But when I want to visit the previous page I see a white page with only json, instead of the view!

How do I fix that?

Thanks!

13 Jun
11 months ago

Lars-Janssen left a reply on [PDOException] SQLSTATE[HY000] [1044] Access Denied For User ''@'localhost' To Database 'f Orge'

Try 127.0.0.1 instead of localhost. Is your db name forge correct?

05 Jun
11 months ago

Lars-Janssen started a new conversation 502 Bad Gateway (no Laravel)

Hi,

When I visit my magento 2 project I get the following error:

502 Bad Gateway
ProtocolException('Server connection to www.magento-project.test:8081 failed: Error connecting to "www.magento-project.test": [Errno 61] Connection refused',)
I'm trying to run a magento 2 project. I use Homestead for this, my Homestead.yaml looks like this:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: /Users/lars/Documents/code
      to: /home/vagrant/code

sites:
    - map: magento-project.test
      to: /home/vagrant/code/magento-project
      port: 8081
      php: "7.0"
      type: "apache"

databases:
    - homestead

When I ssh into my server (vagrant ssh) I can see that homestead created my projects successful. I've added the ip address to my hosts file on my mac 192.168.10.10 magento-project.test. When I start my server and exec command flip. It starts using apache instead of nginx so that's working.

But when I go to http://www.magento-project.test:8081/ I get the 503.

I already tried vagrant reload, vagrant provision, vagrant halt but nothing works. Any ideas?

When I try this with a laravel project (nxinx) it's working.

What can I try?

31 May
11 months ago

Lars-Janssen left a reply on Visual Studio Code Php Storm Method Docblocks

@tykus what keys do you press when you are in a method that will generate the docblocks?

Lars-Janssen started a new conversation Visual Studio Code Php Storm Method Docblocks

Hi,

How do I get the same docblocks like in phpstorm for a method but then in visual studio code`?

Thanks

26 May
11 months ago

Lars-Janssen left a reply on Image Url Wrong For Background Image/ Fonts Etc

Put your images in storage and make a symlink to your public folder.

https://laravel.com/docs/5.6/filesystem

19 May
1 year ago

Lars-Janssen started a new conversation Laravel Query Builder Join Where

Hi,

I've got this query:

$query = QueryBuilder::for(Advertisement::class)
            ->with('locations');

The locations method on Advertisement looks like this:

public function locations()
{
    return $this->belongsToMany(Location::class, 'advertisement_locations', 'advertisement_id', 'location_id');
}

So a advertisements belongsToMany locations in between is a pivot table called advertisement_locations.

Now I would only get the advertisements between a given long and latitude that's on the locations table.

How could I do this?

11 May
1 year ago

Lars-Janssen left a reply on FormData Becomes An Object Instead Of Array?

@wilk_randall thanks for helping, but still the same :(

Lars-Janssen left a reply on FormData Becomes An Object Instead Of Array?

@wilk_randall already tried that:

for (var i = 0; i < this.form.locations.length; i++) {
    form.append('locations[]', this.form.locations[i]);
}

But that's not working.

Lars-Janssen started a new conversation FormData Becomes An Object Instead Of Array?

Hi,

In my app I'm sending form data and append it like this:

let form = new FormData();
form.append('locations[]', this.form.locations);

Then I send it with axios to the server.

The problem is that on my server I receive objects instead of an array.

When I send it without the FormData it looks like this:

https://cdn.pbrd.co/images/HkHuyDr.png

How do I fix that?

Lars-Janssen left a reply on Use SparkForm With FormData

Never mind.

Possible like this:

this.form.startProcessing();

axios.post('/adds', form).then((response) => {
    this.form.finishProcessing();
    alert('success!');
},  (error) => {
    this.form.setErrors(error.response.data.errors);
}).catch((error) => {
    this.catchMessage(error);
});

Lars-Janssen started a new conversation Use SparkForm With FormData

Hi,

Currently I'm using SparkForm for posting data to the server. However now I want to send images aswel. I don't want to lose the SparkForm functionalities.

However because I want to send images I have to make a FormData and add an extra header.

So my question is, is it possible to use FormData in combination with SparkForm?

Right now I've got this:

store() {
    let form = new FormData();

    for(let key in this.form.images) {
        form.append('attachment[' + key + ']', this.form.images[key]);
    }
    Spark.post('/adds', this.form).then((response) => {
        alert('success!');
    }).catch((error) => {
        this.catchMessage(error);
    });
}

But when I dd($request->all()); on my server the images array is empty.

Is this even possible with the SparkForm?

Thanks!

04 May
1 year ago

Lars-Janssen left a reply on Vue Pluralize In Combination With Php

@Snapey haha whoops did not thought about that :) Thanks

03 May
1 year ago

Lars-Janssen started a new conversation Vue Pluralize In Combination With Php

Hi!,

I've got this in a .blade file:

I want to pluralize ``location. But how do I add thejavascript length``` to the ngettext php method?

This is obviously not working:

{{ ngettext('location', 'locations', @{{ add.locations.length }} ) }}

Thanks!