bart

Experience

56,780

28 Best Reply Awards

  • Member Since 3 Years Ago
  • 470 Lessons Completed
  • 48 Favorites

16th October, 2017

bart left a reply on A/B Testing With Laravel 5.4 • 4 days ago

Exactly, that's why we searched for a package. In the end we created our own you can find here: https://github.com/bart/ab

We are not able to use providers like Optimizely and Google A/B because we don't just want to change one button but instead about 70% of the page including logical stuff (which needs changes in our core Vue components). For sure, there maybe is some way to handle it with those tools but in the end in my opinion this will take more effort than coding it into the project itself. For us this was the best solution.

1st August, 2017

bart started a new conversation Pretty Weird ES6 Issue • 2 months ago

Hey guys,

a colleague of mine found a pretty interesting ES6 issue that is very easy to reproduce. You can add the following lines of code somewhere in a script tag.

const data = [{title: 'a'}, {title: 'b'}, {title: 'c'}];
console.log(data);
data.forEach((d, index)=> {
    d.title = 'd';
});

What I expected as a result of console.log() was an array of three objects having titles of "a", "b" and "c". But what we actually got was an array of three objects with a title of "d". Why? Do you have any explanation for it? Why does console.log() gets called after the foreach loop?

Thanks and kind regards!

17th July, 2017

bart started a new conversation A/B Testing With Laravel 5.4 • 3 months ago

Hey everybody,

we want to add some A/B tests to our new website. Because it's not only changing a button color from green to red, using tools like optimizely isn't the right approach imo. Furthermore we should do this server-side. Unfortunately the AB testing package from Jens Segers (https://github.com/jenssegers/laravel-ab) isn't compatible with Laravel 5.4

So my question is: Do you guys have any alternative? Or maybe another better approach? How are you doing complex A/B testing?

Really looking forward your ideas. Thanks!!

bart left a reply on Spark Pay Per Use System • 3 months ago

Same question here! Did you find any solution for this?

20th June, 2017

bart left a reply on SEO Issue • 4 months ago

Thanks @martinbean but unfortunately this doesn't answer my question ;) The question that I had was about SEO and how I can prerender or something only for crawlers but prevent them from getting into cloaking issues.

bart started a new conversation SEO Issue • 4 months ago

Hey everybody,

we developed our new dynamic website with a lot of Vue components. The issue we came across with was the page source that gets rendered by the Google crawler for example.

<breadcrumb class="is-hidden-mobile" :items="[{ THIS IS AN OBJECT FROM TH BACKEND }]"></breadcrumb>

That's how the breadcrumb in our source code looks like. When I inspect the element in Chrome everything is fine and I see the rendered result. But that's not what Google crawls. I read a lot of articles about server-side rendering but for using this we need to change our entire infrastructure so that's not an option for now. Another way is prerendering but this only works for non-dynamic content so my question here is: Do you came across with this issue? And if so, what was your solution?

Thanks a lot and kind regards!

12th June, 2017

bart left a reply on Tricky SQL Problem • 4 months ago

Thanks a lot @jlrdw but I need to handle this in the database. I found an okay way to pre calculate everything and store it in the database. This created another tricky task but I'll try to solve it first by myself.

11th June, 2017

bart started a new conversation Tricky SQL Problem • 4 months ago

Hey guys,

I have two tables that contain spatial geo data. For example I have one table pois that has columns latitude and longitude and a second table cities that also has two columns latitude and longitude.

What I want to create a list of all cities in relation to all pois where the distance is not more than 100km.

Is that possible via mysql? Lets say we have about 500k cities and 1k POIs. I didn't find a way to do that in one live query but maybe you have a solution for that. Would be amazing!!

Thanks a lot.

31st May, 2017

bart left a reply on How To Turn Laravel Web App Into Iphone App? • 4 months ago

You can't convert a server-side application into a mobile app. The mobile part could only be the frontend part so to speak. If you want to start with as least work as possible I would suggest to use Ionic Creator (https://creator.ionic.io). But you always need a backend (Laravel) component for mobile application if you want to share data, store data in a database etc. It's possible to do this without a server for example using AWS Lambda functions etc. but I think that's a bit too much depth here.

bart started a new conversation Implementing Query Scope Selects • 4 months ago

Hey guys,

I want to add a select query scope like you can find here: https://theokouzelis.com/php/laravel-eloquent-calculated-fields.html

It would like to select the distance between my model and a passed geo location like this:

public function scopeWithDistanceToPoint($query, $latitude, $longitude)
    {
        return $query->selectRaw("ST_Distance_Sphere(POINT({$longitude}, {$latitude}), POINT(longitude, latitude)) as distanceToPoint");
    }

To get all fields in return I also need to override the newQuery() method of my model:

public function newQuery() {
        return parent::newQuery()->select('objects.*');
    }

What I can do now is:

return Object::take(10)->withDistanceToPoint(0, 0)->get();

I want to add specific fields I want to get back from the Eloquent collection like this:

return Object::take(10)->withDistanceToPoint(0, 0)->get(['id', "title->{$this->locale} as title"]);

But the problem is, that I don't get the title in the given locale back. Instead it returns the entire title JSON object. This is because of the newQuery() method override. Do you have an idea what's wrong here and how to resolve this issue?

Thanks a lot!!

2nd May, 2017

bart left a reply on Weird Collections Issue With Objects • 5 months ago

Pretty funny. I'm working with PHP since version 3 but didn't know about the reference topic. Shame on me ;)

bart left a reply on Weird Collections Issue With Objects • 5 months ago

I have seen that I can use clone() on objects but in this case I have an array of objects. The funny thing here is, that it creates a copy of the array but not if its (object) items. I'll try the hacky (object) (array) type selection,

bart left a reply on Weird Collections Issue With Objects • 5 months ago

Yes @nikazooz that's right. It seems like PHP always generates references when using object. I created another simple example, that demonstrates the issue without any Laravel specific method:

$link = (object) [
    'title' => 'Home',
    'url' => '/',
];

$link2 = $link;

$link->url = '#';

dd($link, $link2);

The url property is "#" for both now. Any idea how to "disable" the reference here when creating a new variable from it?

bart left a reply on Weird Collections Issue With Objects • 5 months ago

No idea?

bart started a new conversation Weird Collections Map Method • 5 months ago

Hey everybody,

I'm currently having some trouble wit the map() method of collection because it looks like it uses the source data as a reference. I will try to explain it by example:

$images = collect($this->dataFromExternal->images);

$images->map(function($image) {
            $image->filename = '#' . $image->filename;

            return $image;
        });

I would expect that the filename property of each $this->dataFromExternal->images element does not change but a dd($this->dataFromExternal->images) shows a hash as first character for each filename property here. Why? It looks like collection() creates a reference to the original array, doesn't it?! Any idea how to solve this?

Thanks a lot!

18th April, 2017

bart left a reply on Wait For External Resources • 6 months ago

OMG the answer is so simple, shame on me! You just have to load the external scripts before the bundled app.js file - that does the trick. Found this in a comment by Evan You.

bart left a reply on Wait For External Resources • 6 months ago

You're absolutely correct. I load an external Javascript file from inside the layout file and its not loading before the vue component. It should be possible to watch for a global variable named "flowplayer". How would I do that?

bart started a new conversation Wait For External Resources • 6 months ago

Hey guys,

I want to build a Vue component that handles flowplayer videos. Sounds pretty simple and I'm sure it is, but I don't know how to solve the "DOM ready" stuff in Vue.

I currently have the following (example):

<template>
    <div id="video"></div>
</template>

<script>
    export default {
        mounted() {
            flowplayer('#video');
        }
    }
</script>

When I do this I'm getting something like flowplayer is not defined. How can I wait for the external JS script to be ready? I already tried this.$nextTick() {} but it didn't work, too. Maybe I can try window.onload = function () {}; but that does not feel right to me. What do you think? What's the best solution here?

Thanks and best regards.

14th March, 2017

bart left a reply on OOP Question • 7 months ago

Okay, just for your information: it is possible accessing private values by using the setAccessible() method of the reflected property before. That does the trick here.

bart left a reply on OOP Question • 7 months ago

Hey @revati,

thanks for the answer. Well, creating an array and setting all keys and values manually using the corresponding getter is possible. But I hope that there is a more elegant way to solve this.

I already played around with ReflectionClass but is it possible to get the private values from the original class using this way? That would do the trick!

bart started a new conversation OOP Question • 7 months ago

Hey guys,

I'm using the Affilinet PHP SDK that returns product data for a given shop. The data I get in return is an object with private properties and lots of getters.

What I want to store this raw object in my database for further manipulation later on. But using json_encode() does not work here, due to the private scope of the properties. I can't add the implementation of \JsonSerializable because it's a third party class.

Do you have any idea how to store the plain object JSON? Thanks a lot!

22nd February, 2017

bart started a new conversation Mixing Collections • 7 months ago

Hey guys,

I have a collection of items that have two different priorities. I want to sort the items inside of this collection using the priority value but not simply sorting in ascending order. I want to take 3 of priority 1 and then 1 of priority 2, 3 of priority 1 and 1 of priority 2 and so far.

I expect the following result:

Before:

[
    'name' => 'John',
    'priority' => 2,
],
[
    'name' => 'Jack',
    'priority' => 1,
],
[
    'name' => 'Jane',
    'priority' => 1,
],
[
    'name' => 'Leo',
    'priority' => 1,
],
[
    'name' => 'Mike',
    'priority' => 1,
],
[
    'name' => 'Sarah',
    'priority' => 2,
],
[
    'name' => 'Jody',
    'priority' => 1,
],
[
    'name' => 'Lena',
    'priority' => 2,
],

After:

[
    'name' => 'Jack',
    'priority' => 1,
],
[
    'name' => 'Jane',
    'priority' => 1,
],
[
    'name' => 'John',
    'priority' => 2,
],
[
    'name' => 'Leo',
    'priority' => 1,
],
[
    'name' => 'Mike',
    'priority' => 1,
],
[
    'name' => 'Sarah',
    'priority' => 2,
],
[
    'name' => 'Jody',
    'priority' => 1,
],
[
    'name' => 'Lena',
    'priority' => 2,
],

Do you have any idea how to achieve this? Thank you very much!

23rd January, 2017

bart started a new conversation Pass Javascript Variable As Property • 8 months ago

Hey guys,

sometimes you stuck like I currently do. I created a vue component and want to pass an object as property. I don't know how to do that :(

<script>
let my_prop = {firstname: 'Jack', lastname: 'Bauer'}
</script>

<my-component user="my_prop"></my-component>

I tried everything from :user="my_prop" until user="{{ my_prop }}".

Do you have any idea what's wrong here? Thanks!

17th January, 2017

bart left a reply on [Flexbox] How To Use Full Width • 9 months ago

Solved it... omg sorry. Simply use flex:1 on that darker grey box,

bart started a new conversation [Flexbox] How To Use Full Width • 9 months ago

Hey guys,

I'm playing around with flexbox and asking myself how use the full width in a navbar. I created a simple fiddle here: https://jsfiddle.net/egvcw7cx/

I want to achieve that the darker box on the right side fills the whole space between the lighter grey box. Do you have any idea how to solve this?

Thanks a lot!!

3rd October, 2016

bart left a reply on Pass Data From Listener To Event • 1 year ago

Well, thank you so much @belisar. That will solve the problem imho. I will give it a further read but I think that's exactly what I've looked for. I'm a bit confused, that I never heard of the pipeline design pattern. But hey, we never stop learning.

bart left a reply on Pass Data From Listener To Event • 1 year ago

Hey @belisar and thanks a lot for your detailed explanation. As I wrote above I'm trying to manipulate data from listener to listener and want to remember something I called "rejects". In the and (in the last listener) I like to send one email that contains all rejects from all listeners.

bart left a reply on Pass Data From Listener To Event • 1 year ago

Well I thought about it but in my case it does make sense. I do different steps (different listeners for one event) and collect rejects during this process. In the end I want to send one email with collected information about the rejects. That is not possible if I would fire a single event from each listener.

bart started a new conversation Pass Data From Listener To Event • 1 year ago

Hey everybody,

I'm using events on my current project and like to pass data from one listener to another by pushing it to the event. But it won't work. Maybe because the listeners are queued. Do you have any idea? Here I go with some code:

// Event service provider
protected $listen = [
        'App\Events\HasBeenUpdated' => [
            'App\Listeners\Action1',
            'App\Listeners\Action2',
        ],
    ];

// HasBeenUpdated.php
public $rejects;

public function __construct()
{
        $this->rejects = 0;
}

// Action1.php
public function handle(HasBeenUpdated $event)
{
        $event->rejects = 1;
}

// Action2.php
public function handle(AreaUpdated $event)
{
        dd($event->rejects); // Result is 0 but I expected it to be 1
}

Thanks for ya help!

22nd September, 2016

bart left a reply on How To Install CKeditor On Laravel 5.2 • 1 year ago

Hey everybody,

I want to use CKEditor for a content project, but I don't get it working using elixir. Sure, I can use composer, copy the files via mix.copy to a public directory and include the JS and CSS files into my template but that's not what I want. I'm using lots of different components like jQuery plugins, leaflet.js etc. everything included and bundled into one single bundle.js via elixir.

What I want now is to add CKEditor the same way. I know there is an npm package out here, but it's not possible for me to use it because you have to copy the files into a public directory again.

Any idea how to solve this?

8th September, 2016

bart left a reply on Pass Config Array As Prop To A Component • 1 year ago

Hehe maybe it works on Vues side, but not on the Laravel side. When I try to pass an array I'm getting the htmlentities() error message in the blade template. Or should I try {{{ }}} instead of {{ }} ?

7th September, 2016

bart left a reply on Pass Config Array As Prop To A Component • 1 year ago

I think it won't work without braces, right? And when I use them I'm getting the htmlentities() error again.

6th September, 2016

bart started a new conversation VueJS Select2 Input Model Binding • 1 year ago

Hey everybody,

I have something like this:

''' ...

new Vue({ el: '#app',

data: {
    selection: ''
},

methods: {
    checkMe() {
         console.log(this.selection)
    }
}

} '''

I expected an array of selected items here but I'm getting the empty string logged to console. Do you have any idea what I can do here? I think the problem is, that selectize won't update the "ghost" element, but some child elements it creates on the fly, right?

Thanks a lot!

bart left a reply on Pass Config Array As Prop To A Component • 1 year ago

Okay I think I can answer this question on my own. You NEED to pass the data by json_encode() them. It's a simple HTML field so nothing else makes any sense here.

bart left a reply on Clear Log File Using Laravel Method ? • 1 year ago

Do you mean an artisan command?

bart started a new conversation Pass Config Array As Prop To A Component • 1 year ago

Hey everybody,

I want to implement a scope selection using VueJS components via Vueify. We have some basic configuration in a config/acme.php file stored as an array like 'available_scopes' => ['foo', 'bar']. I do want to show these available scope in a dropdown using a VueJS component but I don't know how to pass an array to the component props. Is this possible without JSON encode and decode?

// template.blade.php
<scope-selector scopes="{{ config('wave.content_api.destinations') }}"></scope-selector>

// component.vue
<script>
    export default {
        props: [scopes'],
        ready() {
            console.log(this.scopes);
        }
    }
</script>

When doing this I'm getting "htmlentities() expects parameter 1 to be string, array given", sure. I could json_encode() the config array but it feels bad to me encoding this into JSON and decode it in the component. Do you have any suggestions what I could do here?

Thanks a lot!

7th July, 2016

bart left a reply on Can't Run Composer Command Because Of An Error • 1 year ago

Did you check file and folder permissions?

bart started a new conversation [Issue] Caching With Array Driver • 1 year ago

Hey everybody,

I'm using the entrust package to handle roles and permissions. This package forced me to switch the cache driver to something else than file or database. In most threads I read about using array as cache driver.

When using this driver I'm not able to cache data anymore. Simple example in my routes.php:

Route::get('test', function() {
    $data = Cache::remember('foo', 5, function() {
        return 'bar';
    });

    return $data;
});

When I hit the route, change return 'bar'; to return 'foo'; "foo" gets returned. But imo "bar" should be stored in the cache for 5 minutes instead. When changing the cache driver to file it works like expected. Do you have any idea what causes the issue here?

Thanks a lot.

30th June, 2016

bart left a reply on Envoyer.io And Elixir? • 1 year ago

I'm currently having the same problem here. Your solution sounds good, but what if I add additional node modules to the package.json file? So with that in mind I do have to run npm install on every deploy when I want to compile everything on the server, right?

24th June, 2016

bart left a reply on Composer: Command Not Found • 1 year ago

Okay, it seems like I have to install all the dependencies on my own like some php extensions, composer itself and so far. But then it works.

bart left a reply on Composer: Command Not Found • 1 year ago

Well what I don't understand is, that I deployed the server using forge as well. So it's not a custom one. So imho when I create a new server via forge it should all required dependencies, shouldn't it?

bart started a new conversation Composer: Command Not Found • 1 year ago

Hey everybody,

I'm currently playing around with forge but getting the following error when trying to deploy my gitlab repository:

# gitlab.com:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1
# gitlab.com:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1
# gitlab.com:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1
Cloning into 'default'...
/home/forge/.forge/provision-5426039.sh: line 30: composer: command not found

Do you have any idea what's wring here?

Thanks a lot.

20th June, 2016

bart left a reply on Scaling With Laravel And Forge • 1 year ago

+1

15th June, 2016

bart left a reply on Class Is Not A Constructor • 1 year ago

Thanks @d3xt3r! Using import Map from './modules/Map.js'; did the trick. Great!

14th June, 2016

bart left a reply on Class Is Not A Constructor • 1 year ago

Hey, thanks for your quick answer. It hasn't to do anything with VueJS, so it doesn't feel the right way imo. I'm trying to understand the problem here. Is it an ES6 issue?

bart started a new conversation Class Is Not A Constructor • 1 year ago

Hey everybody,

I'm trying to dive into the great world of JS, ES6 and browserify and did follow this tutorial: https://laracasts.com/series/laravel-5-and-the-front-end/episodes/8

I'm using a fresh 5.2 installation of Laravel and create these files:

// resources/js/main.js
var Counter = require('./modules/Counter');
new Counter();

// resources/js/modules/Counter.js
export default class Counter {
    constructor(){
        console.log('init..');
    }
}

// gulpfile.js
mix.browserify('main.js');

But when I load my view that includes the processed main.js file I'm getting: "main.js:5 Uncaught TypeError: Counter is not a constructor"

Do you have any idea what I'm doing wrong here?? Thanks a lot!

5th February, 2016

bart left a reply on Auto Scaling L5 Project • 1 year ago

Hey @jimmy.puckett and thanks for sharing the main idea behind ya stack. I did some resourcing during the last couple of days and in my opinion I found a good and simple way to deploy Laravel apps on AWS EB. Due to the .ebextensions folder it's pretty simple to customize the deployment process, running commands like artisan migrate, setting environment variables, loading files from S3, installing additional packages and so far. You could create different environments which run an own stack of instances each. In that way you can achieve different deployment states like testing, staging and production. What do you think? Does it sound like a good idea?

30th January, 2016

bart left a reply on Auto Scaling L5 Project • 1 year ago

Hey @fideloper,

thanks a lot for your answer! Yes, I meant Forge. As you wrote it is possible to create multiple EC2 instances, deploy my code and shut all than one down. But what if I want to deploy a new version to each instance. I have to start all instances, deploy my code, and shut them down again.

So I think Forge isn't a good solution for this. Maybe Docker would be a better approach. I could install Homestead and pull my repo from Github. But what about the .env file? What about different environments (staging, testing etc.) and what about deploying different branches than master?

Do you have some articles about this topic on serversforhackers.com?

Thanks a lot! Maybe we can start a new project here which simplifies all of this stuff?

29th January, 2016

bart left a reply on Disable Fast-forward In PHPStorm • 1 year ago

I think thats what I tried there by "setting the no-ff option in .git/config". phpstorm ignores these setting IMO. Did you try it?

28th January, 2016

bart started a new conversation Auto Scaling L5 Project • 1 year ago

Hey everybody,

I have some questions about scaling Laravel applications and maybe you can help me. I did a lot of research but can't find any tutorials or stuff like that.

Let's assume I have a web application built with Laravel and want to scale it up which means I get more organic and non-organic traffic on my side. I have TV and/or radio spots and so on. So during some hours I calculate with some peaks.

I love the simple server management forge provides and using envoyer for deployment is amazing. The question here is, if this is also possible with AWS. I think Amazon's cloud solution gives you the most possibilities concerning auto scaling and load balancing, as well as code deployment, storage and distributed content delivery.

But the question is: How can I manage and scale my homestead instances there. What about having different environments (testing, staging, production) on one machine. How to deploy a new version to all instances, where not all instances are running.

I could use Elastic Beanstalk, OpsWorks, Code Deploy etc. But I don't have any experience with any of these services so I need your know how. Did you ever scaled a Laravel application? How do you dpeloy your code in this scenario? Do you use AWS as well?

Thanks you so much. I'm really interested about your ideas or references like blogs, tutorials, videos etc.

Edit Your Profile
Update

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