Lars-Janssen

Experience

138,245

45 Best Reply Awards

  • Member Since 2 Years Ago
  • 856 Lessons Completed
  • 9 Favorites

15th August, 2018

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

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

1st August, 2018

Lars-Janssen left a reply on Vue.js Form Validation • 2 weeks ago

@gcwilliams thanks!

Lars-Janssen started a new conversation Vue.js Form Validation • 2 weeks ago

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!

10th July, 2018

Lars-Janssen left a reply on Running My Tests Empties My Database • 1 month ago

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

Lars-Janssen left a reply on Running My Tests Empties My Database • 1 month ago

Try php artisan config:clear

Lars-Janssen left a reply on Notifications Without Eloquent User Model • 1 month ago

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 • 1 month ago

Try this trait:


use DatabaseMigrations;

Namespace:

use Illuminate\Foundation\Testing\DatabaseMigrations;

Lars-Janssen left a reply on Notifications Without Eloquent User Model • 1 month ago

Like this:

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

1st July, 2018

Lars-Janssen started a new conversation Laravel Validation Validated • 1 month ago

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!

25th June, 2018

Lars-Janssen started a new conversation Changing Card Nothing Is Added? • 1 month ago

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 • 1 month ago

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

24th June, 2018

Lars-Janssen started a new conversation On Page Back I Only See JSON • 1 month ago

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!

13th June, 2018

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

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

5th June, 2018

Lars-Janssen started a new conversation 502 Bad Gateway (no Laravel) • 2 months ago

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?

31st May, 2018

Lars-Janssen left a reply on Visual Studio Code Php Storm Method Docblocks • 2 months ago

@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 • 2 months ago

Hi,

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

Thanks

26th May, 2018

Lars-Janssen left a reply on Image Url Wrong For Background Image/ Fonts Etc • 2 months ago

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

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

19th May, 2018

Lars-Janssen started a new conversation Laravel Query Builder Join Where • 3 months ago

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?

11th May, 2018

Lars-Janssen left a reply on FormData Becomes An Object Instead Of Array? • 3 months ago

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

Lars-Janssen left a reply on FormData Becomes An Object Instead Of Array? • 3 months ago

@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? • 3 months ago

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 • 3 months ago

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 • 3 months ago

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!

4th May, 2018

Lars-Janssen left a reply on Vue Pluralize In Combination With Php • 3 months ago

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

3rd May, 2018

Lars-Janssen started a new conversation Vue Pluralize In Combination With Php • 3 months ago

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!

Lars-Janssen started a new conversation Mapbox Set Multiple Markers • 3 months ago

Hi,

I'm working with mapbox and placing several markers on the map. My code looks like this:

add.locations.forEach((location) => {
    console.log(location.long + " " + location.lat);
    // add marker to map
    let marker = new mapboxgl.Marker(el)
        .setLngLat([location.long, location.lat])
        .setPopup(popup)
        .addTo(this.map);

    this.markers.push(marker);
});

When I look into the console the console.log(location.long + " " + location.lat); with 2 different long and lat is visible. But on the map only the last location/pointer is there!?

What could be wrong here?

8th April, 2018

Lars-Janssen left a reply on Add Click Event Listener Not Working • 4 months ago

@rin4ik The custom control class builds the button.

Lars-Janssen started a new conversation Add Click Event Listener Not Working • 4 months ago

Hi,

I'm usingmapbox for building a map. I want to add a custom button to this map that's triggered on click.

In my vue.js project I've got a class that looks like this:

export default class CustomControl {

    constructor(className, text) {
        this.className = className;
        this.text = text;
    }

    onAdd(map){
        this.map = map;
        this.container = document.createElement('div');
        this.container.addEventListener('click', function(){
            console.log('clicked!');
        } );
        this.container.id = 'test';
        this.container.className = this.className;
        this.container.textContent = this.text;
        return this.container;
    }
    onRemove(){
        this.container.parentNode.removeChild(this.container);
        this.map = undefined;
    }
}

Then I add it to the map:

mounted() {
       const showAllControl = new CustomControl('show-all-control', 'SHOW ALL');
       this.map.addControl(showAllControl, 'top-left');
}

The button shows up but the click event is not triggered!!! What could be going wrong here?

29th March, 2018

Lars-Janssen left a reply on Laravel Spark Is This Normal? • 4 months ago

@ejdelmonico Thanks!

28th March, 2018

Lars-Janssen started a new conversation Laravel Spark Is This Normal? • 4 months ago

Hi,

Currently within my spark project I've three plans.

- Small
- Medium
- Pro

When a user is subscribed to plan Pro and then goes to plan Medium I would expect the user keeps the features of plan Pro for that current month.

However Spark immediately gives the features of Plan Medium and revokes all features from plan Pro?

Is that normal?

Thx!

Lars-Janssen started a new conversation Laravel Catch 403 In Spark • 4 months ago

Hi,

How can I catch custom http responses like a 403 within spark?

For example:

Spark.post('/stores-name', this.form)
    .then((response) => {
        this.storeCreated(response);
    })
    .catch(error => {
        console.log(error.response)
    });

However when I console.log(error.response); or console.log(error);

There is no status code?

15th March, 2018

Lars-Janssen started a new conversation Best Way To Disable Tab State • 5 months ago

Hi,

I'm working within a spark project where I've to customize some things. I

I've made my own tab-state that looks like this insettings.js:

var base = require('settings/settings');

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

    data() {
        return {
            menu: {
                profile: true,
                security: false,
                subscription: false,
                invoices: false
            }
        }
    },

    methods: {
        changeTab(tab) {
            for (let item in this.menu) {
                if (this.menu.hasOwnProperty(item)) {
                    this.menu[item] = false;
                }
            }

            this.menu[tab] = true;
        }
    }
});

However when I look in settings.js from spark that looks like this:

module.exports = {
    props: ['user', 'teams'],


    /**
     * Load mixins for the component.
     */
    mixins: [require('./../mixins/tab-state')],


    /**
     * The component's data.
     */
    data() {
        return {
            billableType: 'user',
            team: null
        };
    },


    /**
     * Prepare the component.
     */
    mounted() {
        this.usePushStateForTabs('.spark-settings-tabs');
    }
};

It's loading tab-state from a mixin. Obviously I can comment it out but then I'm changing within the core of spark. Is there no other way?

Lars-Janssen left a reply on Change Creditcard Fields • 5 months ago

@Cronix @hhda I already made lots of changes in the .blade files from Spark. Should be possible I guess for example ohdearapp.com is doing this aswel.

Right now it looks awful :(

Schermafbeelding_2018_03_15_om_13_00_38

14th March, 2018

Lars-Janssen left a reply on Change Creditcard Fields • 5 months ago

Anyone?

Lars-Janssen started a new conversation Change Creditcard Fields • 5 months ago

Hi,

In Laravel Spark I can customize almost all subscription fields.

However the creditcard field is created with this:

<div id="subscription-card-element"></div>

Behind the scenes spark is making them self. Is it possible to change this:

<div id="subscription-card-element"></div>

With my own input fields?

Thanks!

28th February, 2018

Lars-Janssen left a reply on Forge And Php 7.2 • 5 months ago

Yes, it is.

15th February, 2018

Lars-Janssen left a reply on Calling Save Method On All Records • 6 months ago

Try this:

php artisan tinker

YourModel::all()->each->yourMethod();

2nd February, 2018

Lars-Janssen started a new conversation Disable Transactions When Running Tests • 6 months ago

Hi,

I've a controller method that looks like this:

public function store(Request $request)
{
        DB::connection($this->connection)->transaction(function () use($request) {
                 //Storing updating etc. 
        }
}

The problem is that when I test this controller method like this it fails. But if I remove this:

DB::connection($this->connection)->transaction(function () use($request) {
                
}

So is it possible to disable transactions while testing?

27th January, 2018

Lars-Janssen left a reply on Why Does UpdateGetId Not Exists On The Query Builder? • 6 months ago

@Snapey whooops that's indeed true haha.

Lars-Janssen left a reply on Change Carbon Date Format • 6 months ago

Put in your AppServiceProvider:

Carbon::setToStringFormat('your format');

Lars-Janssen left a reply on Why Does UpdateGetId Not Exists On The Query Builder? • 6 months ago

@Snapey that's not entirely true :)

For example i've this:

DB::connection('shop')->table('cata')
             ->select('id')
             ->where(['sku' => $sku])
             ->update([
                'content'    => 'bla bla bla',
             ]);

Lars-Janssen started a new conversation Why Does UpdateGetId Not Exists On The Query Builder? • 6 months ago

Hi,

I know createGetId(); exists on the query builder. But why is there no updateGetId();? Is there a reason for this or should I make a pull request because I need it ! :)

Thanks!

17th January, 2018

Lars-Janssen left a reply on Tests Fails With Sqlite But Works With Mysql? • 7 months ago

@Cronix whoops! thanks!

16th January, 2018

Lars-Janssen left a reply on Tests Fails With Sqlite But Works With Mysql? • 7 months ago

@ohffs @lostdreamer_nl sorry for the late reaction. It fails like this:

2) Tests\Unit\Product\Description\ProductDescriptionShortTest::it_creates_product_descriptions_short_correctly
Failed asserting that a row in the table [product_description] matches the attributes {
    "product_id": 1,
    "description": "test",
    "type": "short"
}.

Found: [
    {
        "id": "1",
        "product_id": "1",
        "description": "Test",
        "type": "short",
        "created_at": "2018-01-16 15:03:52",
        "updated_at": "2018-01-16 15:03:52"
    },
    {
        "id": "2",
        "product_id": "1",
        "description": "Short description...",
        "type": "short",
        "created_at": "2018-01-16 15:03:52",
        "updated_at": "2018-01-16 15:03:52"
    },
    {
        "id": "3",
        "product_id": "1",
        "description": "Test",
        "type": "long",
        "created_at": "2018-01-16 15:03:52",
        "updated_at": "2018-01-16 15:03:52"
    }
] and 1 others.

if I put it like this in my phpunit file:

 <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="DB_DEFAULT" value="sqlite_testing" />
    </php>

It works?

4th January, 2018

Lars-Janssen started a new conversation Tests Fails With Sqlite But Works With Mysql? • 7 months ago

Hi,

I've got a method that looks like this:

protected function saveDescriptions($descriptionsShort, $descriptionsLong, $productId)
{
    /*
     * Check if product description short already exists
     * otherwise create one.
     */

    foreach ($descriptionsShort as $description) {
        if(! ProductDescriptionModel::where(
            'description', $description
        )->where(
            'product_id', $productId
        )->where('type', 'short')->first()) {

            /*
            * If product description short does not exists create one.
            */

            ProductDescriptionModel::create([
                'product_id'    => $productId,
                'description'   => $description,
                'type'          => 'short'
            ]);
        }
    }

This is my test:

 /** @test */
    public function it_creates_product_descriptions_short_correctly()
    {
        $this->assertDatabaseMissing('product_description', [
            "product_id" => 1,
            "description" => "Short description...",
            "type" => "short"
        ]);

        $this->assertDatabaseMissing('product_description', [
            "product_id" => 1,
            "description" => "test",
            "type" => "short"
        ]);

        $this->saveProducts(__dir__ . '/xml/Descriptions.xml');

        $this->assertDatabaseHas('product_description', [
            "product_id" => 1,
            "description" => "Short description...",
            "type" => "short"
        ]);

        $this->assertDatabaseHas('product_description', [
            "product_id" => 1,
            "description" => "test",
            "type" => "short"
        ]);
    }

With this settings in my phpunit.xml file it fails:

<php>
        <env name="APP_ENV" value="testing"/>
        <env name="DB_CONNECTION" value="sqlite" />
        <env name="DB_DATABASE" value=":memory:" />
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
    </php>

but with this it works:

 <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="DB_DEFAULT" value="sqlite_testing" />
    </php>

What could be the problem? Thanks!

15th December, 2017

Lars-Janssen left a reply on Messages On Login Page • 8 months ago

Did it work? @molbol

Lars-Janssen left a reply on Noobie Question -> How To Add A Javascript Library Into App.js • 8 months ago

In webpack.mix.js you should link to the js file:

mix.js('resources/assets/yourjsfile.js, 'public/js')

Then in your index.blade.php or whatever you use:

<script src={{ mix('/js/app.js') }}></script>

Then run npm run production.

Hope it helps

13th December, 2017

Lars-Janssen left a reply on Messages On Login Page • 8 months ago

You should do:

public function showLoginForm()
{
   $notices = Notifications::all();
    return view('auth.login', compact('notices'));
}

Lars-Janssen left a reply on How To Enhance This Library. • 8 months ago

@36864 +1 for that.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.