bobbybouwmann

Developer at Enrise

Experience

845,465

1021 Best Reply Awards

  • Member Since 2 Years Ago
  • 921 Lessons Completed
  • 12 Favorites

29th March, 2017

bobbybouwmann left a reply on Form Validation Combination Of Fields Must Be Unique • 22 hours ago

@douglas_quaid This exactly the reason why you should create a new question ;) Anyway, glad you found my response :D

28th March, 2017

bobbybouwmann left a reply on Mark A Value As "Seen" • 1 day ago

I would pick the pivot table solution. This way you can also save the state of the video (maybe the user watched 2 minutes of the 5 minutes) and so on.

However another solution would be using a json field. This way you can keep an array (json column type) on your user table with all the videos the user has watched so far.

bobbybouwmann left a reply on Nexmo Laravel Package For Sms-notifications Not Working • 1 day ago

Your to is wrong here. It should be this

'to' => $request->phone, // Without the single quotes!

27th March, 2017

bobbybouwmann left a reply on Use Throttle As Metered Paywall • 2 days ago

You want to do more than just throttle the requests right? Currently you can set the throttling only per minute and not per day/week/month. If you want that you need to build your own middleware!

25th March, 2017

bobbybouwmann left a reply on Nexmo Laravel Package For Sms-notifications Not Working • 4 days ago

Can you show some code? Not really sure why you would get above error.

Also have you tried to create the config file yourself?

bobbybouwmann left a reply on Use Throttle As Metered Paywall • 4 days ago

It sounds like you need a new custom middleware for this. The build in throttle mechanism is only a simple implementation for api restrictions. If you want to do more, I suggest you build your own ;)

bobbybouwmann left a reply on Push To Deploy Disabled On WordPress Installs? • 4 days ago

Forge is not made for deploying WordPress sites. You can install a WordPress repository, but that's it. If you want to update stuff you need to do that yourself.

If you want to deploy a wordpress site you simply need to create a new site (not a WordPress site) and deploy that. That also means that you need to have the whole WordPress in version control. So make sure you don't update WordPress or plugins online, otherwise you will have code conflicts.

24th March, 2017

bobbybouwmann left a reply on Validating Date And Time Fields • 5 days ago

It looks like you are better of with a custom validation rule. Check out this answer to give you an idea on how to set it up: https://laracasts.com/discuss/channels/laravel/form-validation-combination-of-fields-must-be-unique/replies/72987

Let me know if you need more help with the implementation ;)

bobbybouwmann left a reply on Form Validation Combination Of Fields Must Be Unique • 5 days ago

Laravel has since my answer changed a bit. It will now throw an exception when the validation fails. See: https://github.com/laravel/framework/blob/5.4/src/Illuminate/Validation/Validator.php#L281

However you can catch this exception of course.

// In your controller

public function store(Request $request)
{
    $rules = []; // Put your rules here

    try {
        $this->validate($request, $rules
    } catch (\Illuminate\Validation\ValidationException $exception) {
        // Do something with the validator  
        // For example

        // Get the failed validation rules
        // Returns an array
        $errors = $exception->validator->failed();
    }
}

This is the work around for this. However Laravel is catching this exception automatically for you and creates a global $errors variable for you, which you can access in your view. If you have the \Illuminate\View\Middleware\ShareErrorsFromSession middleware enabled in your app\Http\Kernel.php middleware group.

If you want to do something else with this my example above would be an option.

23rd March, 2017

bobbybouwmann left a reply on Overriding An Illuminate Package With Fork • 6 days ago

Yeah it's possible.

Just require your fork using the repositories option and then replace the Illuminate\Database\DatabaseServiceProvider::class, with your service provider. Just make sure they have a different name, otherwise you have two classes with the same namespace and class name.

bobbybouwmann left a reply on How Can Use Forge With GCE ? • 6 days ago

You can add a custom server connection using Forge. However Forge is build to set up a server for you on one of the third parties. However GCE is doing the same thing for you.

It should be possible to add a custom server using the "custom VPS" option. You need to make sure that you have a user called root. I'm not sure if GCE will provide you with such a user. If that isn't the case it's currently not possible

22nd March, 2017

bobbybouwmann left a reply on How To Solve CURL Error • 1 week ago

Aah it's locally?

There was a big issue with Ubuntu yesterday regarding this issue. Not sure what it could be locally without extra information

bobbybouwmann left a reply on MethodNotAllowedHttpException In RouteCollection.php Laravel 5.4 • 1 week ago

Your route seems to be wrong! This

Route::put('/channel/{channel}/{edit}',[email protected]');

Should be this

Route::put('/channel/{channel}/edit',[email protected]');

bobbybouwmann left a reply on How To Solve CURL Error • 1 week ago

You need to restart php-fpm or just the whole server depending on your usage with libcurl. For most restarting the server should fix everything.

Automatic updates are great! :D

bobbybouwmann left a reply on Populate Dropdown List Using Config Values Without Using Laravel Collective • 1 week ago

Seriously? I just gave you an example and it doesn't work when you copy paste it... You need to keep thinking for yourself!

21st March, 2017

bobbybouwmann left a reply on Reference In Seeders • 1 week ago

It's currently not possible. You can only query already seeded data to reuse it.

However with factories you just create a bunch of objects in each seeder using the relations, this way you can do everything in one seeder for that object. See some more examples here: https://laravel.com/docs/5.4/database-testing#writing-factories

bobbybouwmann left a reply on All CURL Calls Fail With Error 6: Could Not Resolve Host - Suddenly On Production Server Only • 1 week ago

Yeah, AWS is applying security updates automatically. I believe you can turn this option off. It's up to you to do so ;)

bobbybouwmann left a reply on Populate Dropdown List Using Config Values Without Using Laravel Collective • 1 week ago

You can simply do something like this

<select name="store" class="form-control">
    
    @foreach(config('constants.STORES') as $value => $store)

        <option 
            selected="{{ $entity->selected == $value ? 'selected="selected"' : '"
            value="{{ $value }}">
            {{ $store }}
        </option>

    @endforeach

</select>

bobbybouwmann left a reply on All CURL Calls Fail With Error 6: Could Not Resolve Host - Suddenly On Production Server Only • 1 week ago

You need to restart your server. There was a problem with libc and it was patched automatically. To solve it you simply need to restart the server ;)

16th March, 2017

bobbybouwmann left a reply on Database Migration Error • 1 week ago

What is you exact setup?

If you use Homestead (virtual machine) you need to connect to a different IP to connect with the database outside the box. If you run everything locally you should be fine with your current setup.

15th March, 2017

bobbybouwmann left a reply on Queue Questions • 2 weeks ago

Straight from the documentation:

Queue Priorities

Sometimes you may wish to prioritize how your queues are processed. For example, in your config/queue.php you may set the default queue for your redis connection to low. However, occasionally you may wish to push a job to a high priority queue like so:

dispatch((new Job)->onQueue('high'));

To start a worker that verifies that all of the high queue jobs are processed before continuing to any jobs on the low queue, pass a comma-delimited list of queue names to the work command:

php artisan queue:work --queue=high,low

Documentation: https://laravel.com/docs/5.4/queues

So the basic idea is to have two queues. When you run two queues the first queue will always be processed first. So messages like your can be send to the high queue and order processes like emails can be send to the low queue.

14th March, 2017

bobbybouwmann left a reply on Testing Events Using Laravel Dusk • 2 weeks ago

Laravel Dusk is a complete separate package and is completely focused on acceptance tests. So basically browser testing. Spin up the browser and run the javascript and interact with a real database.

If you want to write unit/functional/integration tests you can use the build in Laravel goodies ;)

bobbybouwmann left a reply on Installed Package Adds New Eloquent Relationships • 2 weeks ago

Indeed, what you can do is create a base model in your package and extend that model in your application. This way you have all the functionality that you need by default and you can add or edit methods in your application

// Package

class InvoiceModel extends Eloquent
{
    // SomeMethods
}

// Application

class Invoice extends InvoiceModel
{
    use InvoiceRelationsTrait;

    // Some methods
}

Something like this

bobbybouwmann left a reply on Testing Events Using Laravel Dusk • 2 weeks ago

You can't really test events with Dusk, except for checking the database if something was performed. Instead you should write a unit or functional test for this.

Laravel still offers the basic testing functionality as in 5.3, just plain old application tests instead of the acceptance tests from Dusk.

Documentation: https://laravel.com/docs/master/mocking#event-fake

bobbybouwmann left a reply on Installed Package Adds New Eloquent Relationships • 2 weeks ago

Yeah, so you can reuse the relation in any other project. Note that the package is also the one who is responsible for the migrations.

bobbybouwmann left a reply on Email Unique But Not When It's Users' Own Email And User Tries To Update His Profile • 2 weeks ago

@maxnb I would do this instead

$user = $request->user();

return  [
    'email' => 'required|unique:users,email,' . $user->id,
];

bobbybouwmann left a reply on Laravel 5.4 Session Not Working On Api Routes If Uses Wizard Request • 2 weeks ago

@kipasangin You can see that in your RouteServiceProvider.php file ;)

bobbybouwmann left a reply on Email Unique But Not When It's Users' Own Email And User Tries To Update His Profile • 2 weeks ago

So you can add extra options to the unique validation rule to prevent the id and the current email being checked

Documentation: https://laravel.com/docs/master/validation#rule-unique

Let me know if you need an example, the documentation should already give you enough information though ;)

bobbybouwmann left a reply on Installed Package Adds New Eloquent Relationships • 2 weeks ago

The easiest way to handle this is using a trait. You can simply use the trait in your application model which includes the relations for you.

I once created an authorization (roles/permissions) package for Laravel (before we had it build in) which had the same concept.

You can find the code here: https://github.com/bobbybouwmann/entry

So in this package the example is that you add a trait to the User model and now you have methods like below available

// src/Entry/Traits/EntryUserTrait.php
public function role()
{
    return $this->belongsTo('App\Role');
}

13th March, 2017

bobbybouwmann left a reply on How To Define An Accessor For A Pivot Table Attribute? • 2 weeks ago

@orkhanahmadov Use a different name for them?

public function getParentXNameAttribute() {}
public function getParentYNameAttribute() {}

8th March, 2017

bobbybouwmann left a reply on How To Code Continuously? • 3 weeks ago

Make the features smaller. It sounds to me that your features are way too big to handle at once. Try to keep them ultra small. Maybe you can do 300 features a day, but you can then finish them one by one which gives you a really good feeling ;)

bobbybouwmann left a reply on Laravel 5.4 Session Not Working On Api Routes If Uses Wizard Request • 3 weeks ago

If you use the laravel api middleware group you won't have sessions. If you open your app/Middleware/Kernel.php you can see what middleware is registered per middleware group.

bobbybouwmann left a reply on Retrun Value In 'getFacadeAccessor' Method • 3 weeks ago

The return value of the method should match the name of the binding in your ServiceProvider

// Service Provider
public function register()
{
    $this->app->bind('someFacade',function(){
        return new \Some\Namespace\Facade();
    });
}

// Facade

public static function getFacadeAccessor()
{
    return 'someFacade';
}

bobbybouwmann left a reply on SQL Command In Laravel • 3 weeks ago

What have you tried so far?

bobbybouwmann left a reply on Removing An Item From Vue JS Data • 3 weeks ago

@inilabs If the variable is binded, so it's in the data array, you can simply assign an empty array to the variable and it will be empty ;)

bobbybouwmann left a reply on Cant Validate Otf Format • 3 weeks ago

So it seems that the mime types for web-fonts are not really finished yet and they are still changing. I've read about changing the family to font/ttf and so on.

However otf stands for open font type. You can try the following mime type instead for that

'font_file' => 'required|mimes:ttf,opentype'

Reference: http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts

7th March, 2017

bobbybouwmann left a reply on [L5] Change Default Database Connection Dynamically. • 3 weeks ago

@georgek

  1. Click on his account
  2. Click on twitter/Github icon

bobbybouwmann left a reply on Combine Has Many Through And Eager Loading! • 3 weeks ago

What do you mean by filter?

You can always do something like this

$countries->pluck('posts_count', 'country_id');

This will give you an array that looks like this

[
    1 => 23,
    2 => 3,
    3 => 5,
    4 => 17,
]

Note: get always gives you a Collection, see all the available methods here: https://laravel.com/docs/master/collections

bobbybouwmann left a reply on If Contitons Are Not Working After Where Clause In Mysql Store Procedure • 3 weeks ago

@usamamashkoor I think you are trying to do optimizations that are not necessary yet. Just do it the easy way first. If you find out that database is too slow start optimizing.

bobbybouwmann left a reply on Laravel 5 Boilerplate Upgrade/Add A New Model And Relationship Etc. • 3 weeks ago

Have you tried to read the documentation?

if you find Laravel really hard I can recommend you to start reading the documentation or follow a course here on Laracasts

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

bobbybouwmann left a reply on L5.1 Url('/') Points Wrong Address In Remote Host. • 3 weeks ago

/ always means that you point to the root of your project (or what is served on the internet). For Laravel is that the public directory by default.

So if you you are on the page www.domain.com/something/something and you have a link like so

<a href="/">Some link</a>

That means that the link will point to www.domain.com/.

On your local environment you might use Apache instead of nginx on the server or the other way around. You need to make sure that they both to the same thing.

bobbybouwmann left a reply on WhereHas Problem • 3 weeks ago

@Connor-S-Parks The whereHas query is pretty useful if you only want "Tickets" in this case when subtickets exists. If a ticket now has no subticket with product_id = 15 it will not be returned.

bobbybouwmann left a reply on WhereHas Problem • 3 weeks ago

You need to do it like so

$tickets = Ticket::whereHas('subtickets', function ($query) use ($productId) {
    $query->where('product_id', $productId);
})->with('subtickets', function ($query) use ($productId) {
    $query->where('product_id', $productId);
})->get();

To clean things up you can even do something like this

$productId = 15;

$callback = function ($query) use ($productId) {
    $query->where('product_id', $productId);
}

$tickets = Ticket::whereHas('subtickets', $callback)
    ->with('subtickets', $callback)
    ->get();

6th March, 2017

bobbybouwmann left a reply on Combine Has Many Through And Eager Loading! • 3 weeks ago

You can do it like so

$countries = Country::withCount('posts')->get();

@foreach ($countries as $country) 
    {{ $country->id }}
    {{ $country->posts_count }}
@endforeach     

bobbybouwmann left a reply on If Contitons Are Not Working After Where Clause In Mysql Store Procedure • 3 weeks ago

Can I ask you why you want to do this? Why not do these checks in your application before you add something to the database?

bobbybouwmann left a reply on How To Overwrite/update Already Migrated Table With New Columns • 3 weeks ago

@bashy There is no way to stop this...

bobbybouwmann started a new conversation Category On Thread • 3 weeks ago

Hi,

I currently miss the name of the category on the thread page. You can only know the category right now in the discussion overview or in the url. Would it be possible to add this to the thread page as well? With the same color of course ;)

bobbybouwmann left a reply on Combine Has Many Through And Eager Loading! • 3 weeks ago

Have you tried the other way around?

$count = Comment::whereHas('post', function ($query) { // Do some query here that matches your criteria $query->where('date', '<', 'now'); })->count();

Edit Your Profile
Update

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