Lars-Janssen

Experience

142,475

46 Best Reply Awards

  • Member Since 3 Years Ago
  • 890 Lessons Completed
  • 9 Favorites

11th October, 2018

Lars-Janssen left a reply on Requesting And Bundling Vendor Libraries With Mix • 6 days ago

@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 • 6 days ago

Try this:

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

5th October, 2018

Lars-Janssen left a reply on Webserver Or Forge Or AWS • 1 week ago

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

3rd October, 2018

Lars-Janssen left a reply on Horizon Is Not Showing Jobs • 2 weeks ago

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

Lars-Janssen left a reply on Horizon Is Not Showing Jobs • 2 weeks ago

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

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?

13th September, 2018

Lars-Janssen left a reply on Lumen Intro • 1 month ago

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

10th September, 2018

Lars-Janssen left a reply on Instantiate Object • 1 month ago

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

7th September, 2018

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

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

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

15th August, 2018

Lars-Janssen left a reply on Connect Laravel With Third-party API That Requires A API-key • 2 months 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 months ago

@gcwilliams thanks!

Lars-Janssen started a new conversation Vue.js Form Validation • 2 months 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 • 3 months ago

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

Lars-Janssen left a reply on Running My Tests Empties My Database • 3 months ago

Try php artisan config:clear

Lars-Janssen left a reply on Notifications Without Eloquent User Model • 3 months 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 • 3 months ago

Try this trait:


use DatabaseMigrations;

Namespace:

use Illuminate\Foundation\Testing\DatabaseMigrations;

Lars-Janssen left a reply on Notifications Without Eloquent User Model • 3 months 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 • 3 months 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? • 3 months 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 • 3 months 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 • 3 months 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' • 4 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) • 4 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 • 4 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 • 4 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 • 4 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 • 4 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? • 5 months ago

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

Lars-Janssen left a reply on FormData Becomes An Object Instead Of Array? • 5 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? • 5 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 • 5 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 • 5 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 • 5 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 • 5 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 • 5 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 • 6 months ago

@rin4ik The custom control class builds the button.

Lars-Janssen started a new conversation Add Click Event Listener Not Working • 6 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? • 6 months ago

@ejdelmonico Thanks!

28th March, 2018

Lars-Janssen started a new conversation Laravel Spark Is This Normal? • 6 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 • 6 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 • 7 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 • 7 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 • 7 months ago

Anyone?

Lars-Janssen started a new conversation Change Creditcard Fields • 7 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 • 7 months ago

Yes, it is.

15th February, 2018

Lars-Janssen left a reply on Calling Save Method On All Records • 8 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 • 8 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? • 8 months ago

@Snapey whooops that's indeed true haha.

Edit Your Profile
Update

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