bart

Experience

54,830

28 Best Reply Awards

  • Member Since 2 Years Ago
  • 458 Lessons Completed
  • 46 Favorites

14th March, 2017

bart left a reply on OOP Question • 1 week 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 • 1 week 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 • 1 week 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 • 1 month 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 • 2 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 • 2 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 • 2 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 • 5 months 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 • 5 months 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 • 5 months 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 • 5 months 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 • 6 months 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 • 6 months 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 • 6 months 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 • 6 months 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 • 6 months 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 ? • 6 months ago

Do you mean an artisan command?

bart started a new conversation Pass Config Array As Prop To A Component • 6 months 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 • 8 months ago

Did you check file and folder permissions?

bart started a new conversation [Issue] Caching With Array Driver • 8 months 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? • 8 months 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 • 9 months 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 • 9 months 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 • 9 months 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 • 9 months ago

+1

15th June, 2016

bart left a reply on Class Is Not A Constructor • 9 months 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 • 9 months 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 • 9 months 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.

22nd December, 2015

bart left a reply on Strange Guzzle / Curl Question • 1 year ago

Okay I found a solution after trying different things. It seems like the API doesn't work with JSON headers the 'json' key generates. Instead I need to use the 'form_params' key.

bart started a new conversation Strange Guzzle / Curl Question • 1 year ago

Hey everybody,

I'm using Guzzle to fire some calls to a third party API. One feature the API offers is checking a CSR (certificate signing request). When I send the request with curl everything works fine. But when I send the exact same request with guzzle I'm getting "The CSR cannot be decoded".

I think there is a little difference between curl and Guzzle how they send and process JSON data. I checked the headers, everything is the same. Do you guys have any idea how to solve this issue? Maybe you had such a problem, too?

$payload = [
            'AuthRequest' => [
                'PartnerCode' => getenv('SSL_STORE_PARTNER_CODE'),
                'AuthToken' => getenv('SSL_STORE_TOKEN'),
            ],
            'ProductCode' => 'rapidssl',
            'CSR' => '-----BEGIN NEW CERTIFICATE REQUEST-----
MIID3TCCAsUCAQAweTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCk5ldyBNZXhpY28x
FDASBgNVBAcMC0FsYnVxdWVycXVlMRAwDgYDVQQKDAdJbmtTb2Z0MRIwEAYDVQQL
DAlNYXJrZXRpbmcxGTAXBgNVBAMMEGRlbW8uaW5rc29mdC5jb20wggEiMA0GCSqG
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZxMc4eqWM/JgQuH2cE9bDEDkxLN79JIwQ
SlQ5dw1rhlQl9u7cZwt1rlvXh9AcydjF8BJpmzOnL9tyqpto2ba4smC5A0eY1Tkp
03piVVxqapwKyo93oYAcy1mEqw13NeFHeUhclBZQ10mJz55JLkZ0sJYt5OyYA1fV
WFdeJxOSJQi0c8qocFUb4wjh0ghgp+E57d5LARO369eZTik5JABsBaPcYuXP72wy
bzoqhoigiIMx7aPR/+Blrl+STLruz3JiVEhfZGIVWc1U2D4RknGFABDp6w5b9Hw7
FhStFXEkWdTTSvY5iATCfGBBd8AKUw/1RlaI1/8z/JXJNub+CUbhAgMBAAGgggEd
MBoGCisGAQQBgjcNAgMxDBYKNi4xLjc2MDEuMjA/BgkrBgEEAYI3FRQxMjAwAgEF
DA9BUFAyLmlua3NvZnQudXMMEElOS1NPRlRcc3lzYWRtaW4MCHczd3AuZXhlMFYG
CSqGSIb3DQEJDjFJMEcwDgYDVR0PAQH/BAQDAgTwMBYGA1UdJQQPMA0GC2CGSAGG
/W4BBxcBMB0GA1UdDgQWBBTex9WLR+kVyFSBENnT7R/qYg/jgDBmBgorBgEEAYI3
DQICMVgwVgIBAR5OAE0AaQBjAHIAbwBzAG8AZgB0ACAAUwB0AHIAbwBuAGcAIABD
AHIAeQBwAHQAbwBnAHIAYQBwAGgAaQBjACAAUAByAG8AdgBpAGQAZQByAwEAMA0G
CSqGSIb3DQEBCwUAA4IBAQCCRHG7ek7oiaTGzhbhYxdpZZeFwZTejuJbO7mbPOkJ
wSkiIy5qgHgm0Uxuw+l3eBEZu9OOT6J61RQmAx+OUbKKIB8usHWUZiLInAdnOGHn
Ax0Hsf4XVU3cuOD3xnFQnUTwHplhBwCrZPwXq7fWzm3B6FdPVnrSuyMxdQ+GnIie
TF5qXHU8SaQ8GgjNQZdZU2tKhUdjQr8THxvpZ2xJqZ/a+gRf3Uwc4b+Em3qKHimP
rpmBjsKEXSyN+7dPNliZUuA1MqFlsrLeBY4j9f9hgq2FydqgJAjnrhlvFyB4I3YZ
j04caH1WgRsRYrL3+J6w6jNFyXtUXbHKk3oT+vL+4kx+
-----END NEW CERTIFICATE REQUEST-----',
        ];

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://sandbox-api.myprovider.com/rest/csr');
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
        curl_setopt($ch,CURLOPT_HTTPHEADER, ['Content-Type: application/json; charset=utf-8']);
        $curlResponse = curl_exec($ch);

        $client = new Client();
        $guzzleResponse = $client->request('post', 'https://sandbox-api.myprovider.com/rest/csr', ['json' => $payload, 'verify' => false])->getBody()->getContents();
        dd($curlResponse, $guzzleResponse);

What I get in response is this:

// $curlResponse
"{"AuthResponse":{"InvokingPartnerCode":"82913873","Message":null,"ReplayToken":null,"Timestamp":"12\/22\/2015 3:50:58 PM","isError":false},"Country":"United States","DNSNames":[""],"DomainName":"demo.inksoft.com","DominName":"demo.inksoft.com","Email":"","Locality":"Albuquerque","MD5Hash":"C0B7F7CD372CAD7917FC448CDB1441A5","OrganisationUnit":"Marketing","Organization":"InkSoft","OrganizationUnit":"Marketing","RegionSpecificOrderIndicator":null,"SHA1Hash":"166B219470716E6EA581157E4A0997FB4DA8ACAB","SignatureAlgorithm":"sha256WithRSAEncryption","State":"New Mexico","hasBadExtensions":false,"isValidDomainName":true,"isWildcardCSR":false}"

// $guzzleResponse
"{"AuthResponse":{"InvokingPartnerCode":"82913873","Message":["ErrorCode:-9009|Message:Vendor returns error:The CSR cannot be decoded!"],"ReplayToken":null,"Timestamp":"12\/22\/2015 3:51:00 PM","isError":true},"Country":null,"DNSNames":null,"DomainName":null,"DominName":null,"Email":null,"Locality":null,"MD5Hash":null,"OrganisationUnit":null,"Organization":null,"OrganizationUnit":null,"RegionSpecificOrderIndicator":null,"SHA1Hash":null,"SignatureAlgorithm":null,"State":null,"hasBadExtensions":false,"isValidDomainName":false,"isWildcardCSR":false}"

It would be great if you could help me. Thanks a lot!!

7th December, 2015

bart left a reply on [Composer] Autoload Braintree Package • 1 year ago

Amazing, that really did the trick. Thanks you so much @skylerkatz!

6th December, 2015

bart started a new conversation [Composer] Autoload Braintree Package • 1 year ago

Hey everybody,

I'm having problems calling any Braintree methods from inside my project. I've added the package using composer like described here: https://developers.braintreepayments.com/start/hello-server/php

But classes like Braintree_Transaction are undefined. I'm getting Class 'App\Http\Controllers\Braintree_Transaction' not found. I think it's an issue with my (default) Laravel 5 PSR-4 autoloading configuration in composer.json, isn't it? Do you guys have any idea how to solve this?

Thanks a lot!

17th November, 2015

bart left a reply on Multiple Components • 1 year ago

Hey @vitorarjol,

thanks a lot for your information! A really simple solution, I'm such an idiot! OMG :D

16th November, 2015

bart left a reply on Multiple Components • 1 year ago

+1

bart started a new conversation Multiple Components • 1 year ago

Hey everybody,

I like to use multiple single components on my page. I've created a single JS files for each component. Each of them contains sth like this:

Vue.component('my-nth-component', {
    // Component data and logic goes here
});

var vue = new Vue({
    el: 'body'
});

The problem now is, that when I print out the vue object in Chrome dev toolbar, I just get a vue object which contains one component instead of multiple ones. Sure, I am creating a new vue object for each component.

Do you guys have a solution for this? How can I add a component to a vue object in case it already exists?

15th November, 2015

bart left a reply on OrWhere Problem • 1 year ago

Thanks for your reply @Snapey. I did get it working now by storing the orWheres in case the upcoming conjunction is an "or" as long as the next one is an "and". Then I create a nested orWhere clause and everything works fine. Thanks for ya support guys!

bart left a reply on OrWhere Problem • 1 year ago

Unfortunately my idea didn't solve the problem. So maybe you guys have any solution for it?

14th November, 2015

bart left a reply on OrWhere Problem • 1 year ago

Guys, as I wrote several times, the snippet from above is really just an example!!! I have a query which starts with an "and" conjunction, so this is not the point. The problem is to dynamically add orWhere brackets as long as the current item from the array has an "or" conjunction . But I think I have an idea how to solve it. I let you know if it works.

bart left a reply on OrWhere Problem • 1 year ago

Haha yep, as I told you it is just a simple example. In my real project I have an and statement before. But nevertheless no brackets will be generated. And thats pretty clear, because no nested where has been added. I think I need to iterate through the final query wheres property and generate the nesting, don't I?

bart left a reply on OrWhere Problem • 1 year ago

I know the docs very well @jlrdw , thanks ;) The order of the if-statement doesn't matter. What it does is clear, isn't it? As I wrote in my post nested queries are the way Laravel Query Builder adds brackets and that is what you copied from the docs. But in my case it is not possible this way, because I don't now the next "where" from the array. I iterate from item to item and only have the current one. I need something like "as long as I have an and conjunction add a nested orWhere query". But how to do it?

bart left a reply on OrWhere Problem • 1 year ago

This is just a code example, not my real code because mine is a way more complex. The logic is simple, isn't it? I iterate through an array of "wheres" and create my query from it. What I need to do is set the brackets inside my query correctly and I don't know how to do that in the dynamic way from above, because I don't know if the next conjunction is an "and" or an "or".

bart left a reply on OrWhere Problem • 1 year ago

What do you mean @jlrdw ? In case conjunction is "and" I like to add a where statement. In case conjunction is "or" I like to add a orWhere clause. My problem is the bracket. As I wrote it is a dynamic array so it is also possible to have all conditions being combined with an "or". What can I do? Any ideas?

bart left a reply on OrWhere Problem • 1 year ago

Do you have an idea?

bart started a new conversation OrWhere Problem • 1 year ago

Hey everybody,

I really don't know how to solve this problem. I'm having an array like this from which I like to build a query:

$queryArray = [
    [
        'field' => 'name',
        'operator' => 'LIKE',
        'argument' => 'J%',
        'conjunction' => 'and',
    ],
    [
        'field' => 'age',
        'operator' => '>',
        'argument' => '20',
        'conjunction' => 'and',
    ],
    [
        'field' => 'memberSince',
        'operator' => '>',
        'argument' => '2010-01-01',
        'conjunction' => 'or',
    ],
    [
        'field' => 'registered',
        'operator' => '=',
        'argument' => '1',
        'conjunction' => 'and',
    ],
]

I can do stuff like this to generate the query:

$query = DB::table('members');
foreach($queryArray as $item) {
    if ($where['conjunction'] == 'and') {
        $query->where($item['field'], $item['operator'], $item['argument']);
    } else {
        $query->orWhere($item['field'], $item['operator'], $item['argument']);
    }
}

The problem with this approach is that I don't get the right query. The brackets are wrong. What I expected is something like:

SELECT * FROM members WHERE name LIKE "J%" AND (age > 20 OR memberSince > '2010-01-01') AND registered = '1'

But what I get is this (without any brackets):

SELECT * FROM members WHERE name LIKE "J%" AND age > 20 OR memberSince > '2010-01-01' AND registered = '1'

Do you have any idea how to solve this problem? Dynamic or-where clauses are really complicate stuff in my opinion.

Thanks!

12th November, 2015

bart left a reply on Looking For A German Guy Who Give Me Payed Teach Lessons • 1 year ago

As I told you @BamiGorengo please feel free to ask as many questions as you have! The Laravel community is awesome and from my point of view one of the best in the world. Last but not least I'm German, too.

10th November, 2015

bart left a reply on Laracasts New Layout Is Awesome. • 1 year ago

I really like it, too! Amazing re-design, pretty clean! Love the skill idea!

Edit Your Profile
Update

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