bobbybouwmann

Developer at Enrise

Experience

879,785

1043 Best Reply Awards

  • Member Since 2 Years Ago
  • 1066 Lessons Completed
  • 14 Favorites

17th August, 2017

bobbybouwmann left a reply on Invalid Argument Supplied For Foreach() • 10 hours ago

$i is the key of the previous array, which means it's not an array. You can only look over iteratables like arrays in a foreach loop

Can you tell us what you are trying to do? This looks really messy!

6th August, 2017

bobbybouwmann left a reply on Logs General Question • 1 week ago

@shez1983 Indeed, you can also use services like Sentry to do this kind of stuff ;)

bobbybouwmann left a reply on Logs General Question • 1 week ago

It's currently not an option but you could create a PR for it ;)

Also a log file can get pretty big in one day. The daily option is a good option for you ;)

bobbybouwmann left a reply on Laravel Can't Find Database Directory • 1 week ago

You have a string somewhere wrong. Could be your composer.json file. Can you search your codebase on the string atabase? You should find the mistake somehow!

bobbybouwmann left a reply on Logs General Question • 1 week ago

It depends on the config of your log. You have multiple options for this. You can find all of this in the documentation

Documentation: https://laravel.com/docs/5.4/errors#log-storage

31st July, 2017

bobbybouwmann left a reply on Using The Putfile Method To Save A Social Media Profile Image, Returning File Does Not Exist • 2 weeks ago

Did you import the correct File class? I can't see that from your code example!

bobbybouwmann left a reply on Config:cache Makes Functions In Config/helper.php Not Available • 2 weeks ago

Yes it is. When you cache your config, everything fill be parsed and compiled to one single file. This file can only be read by the framework and not executed, like your methods are.

This improves a lot of the speed, since it only needs to read one file instead of all your config files.

So if you want your helpers to be available you need to place them somewhere else.

What is the exact use case of using functions in your config files? I never had the need for that and could always use a helper.php file with separate functions in for example the app directory.

28th July, 2017

bobbybouwmann left a reply on Plucking Attributes When Counting Related Models • 2 weeks ago

Pluck doesn't work like that. You should use only here.

])->get()->only(['name', 'absence_count', 'currentabsence_count'])->toArray();

Pluck works best when you want to retrieve a name and an id for example for a select list

$list->pluck('name', 'id');

array:4 [
    12 => 'Donald Duck',
    14 => 'Dagobert Duck,
    // etc
]

24th July, 2017

bobbybouwmann left a reply on Trying To Update From 5.1.46 - 5.2.0 • 3 weeks ago

Did you read the error message? It looks like you are including two different versions of one dependency!

23rd July, 2017

bobbybouwmann left a reply on Laravel Mix Compiles In A Duplicate Path? • 3 weeks ago

Yeah you have to do that. I don't have any experience running a custom vagrant box which wasn't able to compile everything!

bobbybouwmann left a reply on Middleware Being Ignored On Api Controller • 3 weeks ago

Are you sure that middleware is hit? Have you tried turning off all other middlewares for that route so only that middleware is used? It could be that the request is already returned before it hits your middleware!

bobbybouwmann left a reply on I Cannot Publish Post After Adding TinyMCE Editor • 3 weeks ago

What error do you get? Show your controller as well!

bobbybouwmann left a reply on Laravel Forge Scheduler • 3 weeks ago

@amirhazz By running it every minute you can easily add any schedule calls to your application without changing the cronjob every time. You of course don't have to do that, but it's a low action for the server, if it can't find any jobs it will simply stop. No performance issues!

bobbybouwmann left a reply on Where Not? Exists This Method? Any Other Approach? • 3 weeks ago

where not is not a valid mysql call. You can use methods like whereNotIn($field, $values), but that is probably not what you want.

So instead of using where not you can use the opposite of it. Something like this.

$results = User::whereNot(function($query) use ($column) {
    $query->whereIsNull($column)
});

What is the exact query you want to perform?

bobbybouwmann left a reply on Laravel Mix Compiles In A Duplicate Path? • 3 weeks ago

Are you compiling it in your vagrant(Homestead) box? It looks like that is the problem. You can also compile it outside your box on your host machine. This is also a lot faster ;)

bobbybouwmann left a reply on TypeError: Cannot Read Property 'hasOwnProperty' • 3 weeks ago

Did you read the error message

Cannot read property 'hasOwnProperty' of undefined

This means that this.errors is not defined. Are you sure this.errors has a value? Or a default value?

bobbybouwmann left a reply on Trying To Update From 5.1.46 - 5.2.0 • 3 weeks ago

Well the error is pretty clear

laravelcollective/html v5.1.10 requires illuminate/support 5.1.* -> satisfiable by laravel/framework[v5.1.46]

This means when you update Laravel 5.1 to Larafvel 5.2 that you also need to update the laravelcollective/html package to 5.2!

13th July, 2017

bobbybouwmann left a reply on Delete Request Using Guzzle In Laravel Not Working • 1 month ago

What is the error?

11th July, 2017

bobbybouwmann left a reply on Uh-Oh Declined • 1 month ago

Dude seriously? Did you try to contact Jeffrey via de contact page? He usually responds within 48 hours!

9th July, 2017

bobbybouwmann left a reply on Order By • 1 month ago

Please show me what you already tried.

bobbybouwmann left a reply on Getting Null Instead Of Original String From Database. • 1 month ago

Is the activation_token column fillable in your User model?

bobbybouwmann left a reply on Order By • 1 month ago

I can tell you how to do it, but you are not gonna learn from it! Did you watch the following FREE series?

https://laracasts.com/series/laravel-from-scratch-2017

bobbybouwmann left a reply on How To Break Method Chaining? • 1 month ago

Yes, Exactly! Very good example as well!

bobbybouwmann left a reply on Checking If File Exists • 1 month ago

The Storage facade uses the storage that is active in your config files (config/filesystems.php). Note that this defaults to local. The root path is set for each storage option. In the case of local it's pointing to storage/app out of my head.

So it's not possible to retrieve a file with Storage that is not in your project without weird hacks!

bobbybouwmann left a reply on Order By • 1 month ago

This is what you need to do

// routes
Route::get('shop/{category_url}', [email protected]');
// in your view use this url
example.com/shop/{category_url}?sort="asc"
example.com/shop/{category_url}?sort="desc"

The way you display the sorting urls depends on how you have setup your project, that is up to you!

bobbybouwmann left a reply on How To Break Method Chaining? • 1 month ago

Yes, and they are called exceptions! Instead of letting your code throw random errors you should control your own errors.

Something like this should do

// app/UpdateItem.php

public function checkIfSalesvalueEqual()
{
    // Do your thing here
    // If this fails throw a new exception
    throw new App\Exceptions\SalesNotEqualException();
}

// app/Exceptions/SalesNotEqualException.php
<?php

namespace App\Exceptions\NavigationService;

use Exception;

class SalesNotEqualException extends Exception
{
    // This class can be empty
}

// app/Http/Controllers/UpdateItemController.php

public function updateItem($id)
{
    try {
        return UpdateItem::perform()
            ->setFoundation($this->item, $this->order)
            ->getSaleById($id)
            ->validateRequest()
            ->mould()
            ->checkIfSalesvalueEqual()
            ->resetAndResubmit()
            ->response();
    } catch (App\Exceptions\SalesNotEqualException $e) {
        // Do what you want to do here
        // In your case:
        
        return back();
    }
}

bobbybouwmann left a reply on Prevent Show Duplicate Value In V-for • 1 month ago

It's not an error right? It's just displaying the item twice because it exists multiple times in the data.

In VueJS you can simply filter the results using a computed property

// Sample.Vue

<template>

    <div>

        <p v-for="comment in comments" v-text="comment"></p>

    </div>

</template>

<script>
    export {
        data() {
            return {
                comments: [
                    'test comment',
                    'test comment 2',
                    'test comment',
                ],
            }
        },

        computed: {
            sortedComments() {
                return = this.comments.filter(function(comment, position) {
                    return this.comments.indexOf(comment)  == position; 
                });
            }
        }
    }
</script>

bobbybouwmann left a reply on Making Route With "?" Arguments In $_GET Array • 1 month ago

You can simply create a route and pass data to it. Based on the key values it will either match the route parameters or add them as a query string

Route::get('/posts')->name('posts.index');

$url = route('posts.index', ['param1' => 1, 'param2' => 2];
// example.com/posts?param1=1&param2=2

7th July, 2017

bobbybouwmann left a reply on Orderby Issue • 1 month ago

You can also take this a bit further and make the field changeable. Checkout this video: https://laracasts.com/lessons/sorting-tabular-data

bobbybouwmann left a reply on Orderby Issue • 1 month ago

You url should look like this

<a href="http://localhost/myshop/public/shop/{{$category['url']}}?sort=asc">
    low to high
</a> 

Now you can simply get the request value and sort by the value in your url

 $sort = $request->get('sort', null);

$products = Product::when($sort, function ($Squery) use ($sort) {
    $Squery->orderBy('price', $sort);
})->get();

bobbybouwmann left a reply on Uh-Oh Declined • 1 month ago

If you have problems you can send a support ticket on this page: https://laracasts.com/contact

bobbybouwmann left a reply on Update Pivot Table Once Again • 1 month ago

Aah yeah of course I mean findOrFail, I typed it wrong in my first reply, but in my second reply it was correct. Sorry for the confusion!

bobbybouwmann left a reply on Laravel 5 Form Partials - Disable Field Only On Edit • 1 month ago

You need to but a dollar sign ($) before the variable name!

@if ($disabled)
    {!! Form::text('myField', ['disabled' => 'disabled']) !!} 
@else
    {!! Form::text('myField') !!} 
@endif 

5th July, 2017

bobbybouwmann left a reply on Route Model Binding And Destroy Action • 1 month ago

This is actually a typo, you need to call the method delete()!

bobbybouwmann left a reply on How Would You Best Authorize User Actions? • 1 month ago

You can use a middleware for this. Using a middleware makes it a bit harder to use the authorize method but I think it should be possible.

bobbybouwmann left a reply on A Way To Use 'route' Command From Laravel In Vue File. • 1 month ago

It's not possible, unless you render the route on before hand but then you might have issues with variable route parameters.

De routes generated with route('home') in Laravel are done on the PHP end. However Vue doesn't know anything about PHP. It only understands the data that you give it or what it retrieves from an API endpoint.

Anyway, for best practices your front-end shouldn't know anything about your backend and visa versa. This way you can simply replace your front end with another frontend. Your PHP application only provides an API and not the way how your frontend should be handling API calls.

bobbybouwmann left a reply on Update Pivot Table Once Again • 1 month ago

@baguus It's not a typo, it's the easiest way to safely retrieve a user from the database. See the documentation: https://laravel.com/docs/5.4/eloquent#retrieving-single-models

bobbybouwmann left a reply on Using ._sortedUniqueBy • 1 month ago

You might even do something like this

uniqNotifications() {
    return _.groupBy(this.notifications, 'link');
}

bobbybouwmann left a reply on Using ._sortedUniqueBy • 1 month ago

Instead of sorting you should be looking at grouping. I think that something like this should do:

uniqNotifications() {
    return _.groupBy(this.notifications, function (notification) {
        return notification.link;
    });
}

Source: http://underscorejs.org/#groupBy

Note: You can probably also do this grouping in the database, assuming the notifications come from the database. If not then you can forget this ;)

bobbybouwmann left a reply on <div Class="count Red"> <?php Echo E($total['class']); ?> </div> • 1 month ago

Well the error is pretty clear, the variable $total can not be found. Are you sure you are passing it to your view in your controller? Can you show us your controller?

bobbybouwmann left a reply on Question About Queue • 1 month ago

  1. The jobs are runned in the order that they are placed on the queue, so I don't think you would have a real problem here since the first job (SetProperties) is run first in all cases

  2. They will probably fail as well, but I think you need to add a fail save to it just to be sure. There is probably a way in your code to check if the SetProperties job succeeded at all.

bobbybouwmann left a reply on How I Undo Php Artisan Storage:link • 1 month ago

You can simply remove the the storage directory/link in your public directory. Something like this should do

// Assuming you are at the root of your project
rm -rf public/storage

Note: The storage link is linked to the storage/app/public directory, so you won't be throwing away anything since it's just a simlink ;)

4th July, 2017

bobbybouwmann left a reply on Update Pivot Table Once Again • 1 month ago

It depends on what you post in your controller. If you post all current associated roles with the user the easiest way would be using sync

// Assuming you are posting an array of roles!
$user->roles()->sync($request->get('roles'));

Note: DB::table doesn't return a User model object, so instead you should do this

$user = User::firstOrFail($id);
$user->update([
    'first_name' => $request['first_name'],
    'last_name' => $request['last_name'],
    'email' => $request['email'],
    'companies_id' => $request['companies'],
]);

$user->roles()->sync($request->get('roles'));

30th June, 2017

bobbybouwmann left a reply on Dusk Via PHPstorm • 1 month ago

Dusk is simply a command line tool. You can setup your PHPStorm with terminal screens and from there simply run

php artisan dusk

You can open the terminal like so

View > Tool Windows > Terminal

bobbybouwmann left a reply on How To Check If User Already Apply This This Specify Job • 1 month ago

You can use the has method to check if a model has a relation

// Retrieve the user IF it has one or more resume and one or more jobs connected to that resume
$user = User::has('resume.job')->findOrFail($userId);

If $user is nul there is nothing connected to the user.

29th June, 2017

bobbybouwmann left a reply on Create Controller Inside A Subfolder • 1 month ago

I know...

It was first not possible.. Learned something today ;)

27th June, 2017

bobbybouwmann left a reply on Is It Possible To Peform DI In Models Instead Of Using Facades? • 1 month ago

I usually create a helper function or do the storage part in the view or wherever you want to show it. Your model is only responsible for giving back the path that is in the database or maybe add a directory by user id or slug.

How the image is retrieved should not be done by the model and instead should be done on another place. Either in your view or controller for example.

bobbybouwmann left a reply on How To Route To A Custom Html File In Public Folder? • 1 month ago

So you have two options here

The easiest one is creating a new .blade.php file and copy all the content in there and then simply return that view in your controller.

Another option would be putting this file directly in your /public directory and let your nginx or htaccess handle the redirect to the correct file. In this case /SPAindex.html

Edit Your Profile
Update

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