bobbybouwmann

Developer at Enrise

Hire Me

Experience

1,087,995

1295 Best Reply Awards

  • Member Since 3 Years Ago
  • 1241 Lessons Completed
  • 14 Favorites

18th June, 2018

bobbybouwmann left a reply on How Use Nestedset Package For Users Binary Tree • 3 hours ago

Have you actually tried the package?

bobbybouwmann left a reply on Relation Between Field Of A Model With A Custom Field Of Pivot Table • 4 hours ago

Did you add the extra field to the relationships?

// User
public function bands()
{
    return $this->belongsToMany('Band\Band')->withPivot('role');
}

// Band
public function users()
{
    return $this->belongsToMany('Band\User')->withPivot('role');
}

bobbybouwmann left a reply on Extending ConsoleMakeCommand • 4 hours ago

Well, that just how PHP works! If you want such a functionality you can of course switch to Java where you can have multiple signature per method! I'm not a big fan of it! I like to define everything as clear as possible!

You can do it with PHP though. There is a way to give unlimited amount of parameters to a method, but not sure if that is the best way to go!

Source: http://php.net/manual/en/functions.arguments.php#example-150

bobbybouwmann left a reply on Relation Between Field Of A Model With A Custom Field Of Pivot Table • 9 hours ago

Well you can do that when creating a new band right?

$user = auth()->user();

$bandData = [
    'name' => 'band name',
    'bio' => 'Lorem Ipsum,
];

$pivotData = [
    'role' => BandUser::ADMIN,
];

$band = $user->bands()->create($bandData, $pivotData);

bobbybouwmann left a reply on How Use Nestedset Package For Users Binary Tree • 12 hours ago

It sounds like you have no idea what you're doing! I can't guide you if you can't get your migration to work! Just one step at the time!

Is your migration working right now?

17th June, 2018

bobbybouwmann left a reply on Make A Post Request To An API Error (Passing In The "body" Request Option As An Array To Send A POST Request Has Been Deprecated. ) • 22 hours ago

So when it's a json api you don't have to json_encode it anymore! Also you need to post to a valid url. So replace /: with /

bobbybouwmann left a reply on Making This API Code Bring Through More Relevant Data? • 23 hours ago

Dude! Did you even read the docs? Come on man! You ask questions here and say that you did everything, but you don't know of some property...

You can find the docs here: https://developers.themoviedb.org/3/discover/movie-discover

Under the section Query String you have the press the link that says ...show 27 more properties

bobbybouwmann left a reply on Make A Post Request To An API Error (Passing In The "body" Request Option As An Array To Send A POST Request Has Been Deprecated. ) • 23 hours ago

That's default behaviour of converting an array to xml! If you don't want that you need to provide a string of XML to the post request! Check the links in my previous messages ;)

bobbybouwmann left a reply on Class App\DataTables\RegistersDataTable Does Not Exist..? • 23 hours ago

Show your file please! Also make sure that the class name is the same as the filename, otherwise the class can't be found by PSR-4!

bobbybouwmann left a reply on Make A Post Request To An API Error (Passing In The "body" Request Option As An Array To Send A POST Request Has Been Deprecated. ) • 23 hours ago

@johnk It's incorrect, because it starts with <root>! It should start with <invoice>!

bobbybouwmann left a reply on Make A Post Request To An API Error (Passing In The "body" Request Option As An Array To Send A POST Request Has Been Deprecated. ) • 23 hours ago

Also note that you need to post XML instead of an array. Right now it will be converted to json before it will be posted to the API. Instead you need to rebuild your array to xml and post that!

Array to XML: https://stackoverflow.com/questions/1397036/how-to-convert-array-to-simplexml

Guzzle post XML: https://stackoverflow.com/questions/34726530/proper-way-to-send-post-xml-with-guzzle-6

I have the feeling that you've never done this before and that we're doing your homework! Try to play with some API's first and see how they work ;)

bobbybouwmann left a reply on Make A Post Request To An API Error (Passing In The "body" Request Option As An Array To Send A POST Request Has Been Deprecated. ) • 23 hours ago

It says expected "invoice"! So you probably miss that key in your request. When you get a 422 http status code, it probably means that the data you submitted is not valid. So either a required field is missing or one of the values is invalid

bobbybouwmann left a reply on Class App\DataTables\RegistersDataTable Does Not Exist..? • 23 hours ago

Are you sure the file is in available here: app/DataTables/RegistersDataTable.php? And that it has the namespace namespace App\DataTables;?

bobbybouwmann left a reply on Making This API Code Bring Through More Relevant Data? • 23 hours ago

Have you tried playing around with the vote_average.gte? And maybe without_genres to remove documentaires and adult stuff and so on!

bobbybouwmann left a reply on How Do You Query Relatable Table (more Than 2 Tables)? • 23 hours ago

Yeah eager loading is a good starting point! If you want to pull lots of data and you find Eloquent to slow you can either fetch the data using a raw query or use caching instead ;)

Raw queries: https://laravel.com/docs/5.6/queries#selects

Caching: https://laravel.com/docs/5.6/cache#cache-usage

bobbybouwmann left a reply on Make A Post Request To An API Error (Passing In The "body" Request Option As An Array To Send A POST Request Has Been Deprecated. ) • 23 hours ago

Instead of body you need to use form_params as the error message suggests!

bobbybouwmann left a reply on Sticky Database Name Across Environments • 1 day ago

No problem ;)

bobbybouwmann left a reply on Laravel Api Best Practice • 1 day ago

Well it depends on your needs of course! However when your application grows you will see that a sub-admin might requires more fields, or needs different roles and so on. If you all put that in the same user resource you might get methods with a lot of if statements or extra code blocks that makes your code unreadable.

My advice would be to split them up in to two resources. It's ok that they both handle the same kind of model, but in your business logic they are two complete different things right?!

Let me know if that helps ;)

bobbybouwmann left a reply on Sticky Database Name Across Environments • 1 day ago

What value is set to the DB_CONNECTION field in the phpunit.xml file? That should be testing in your case!

bobbybouwmann left a reply on How Use Nestedset Package For Users Binary Tree • 1 day ago

self::PARENT_ID reference to a constant on your migration class called const PARENT_ID = ''; It looks like you don't have that!

Instead you can replace it with a string like parent_id and everything should work just fine ;) This is basic PHP!

Also this self::PARENT_ID part is not in the documentation of the package so you added it yourself! If you mean to grab it from one of the models you created you need to use the model class instead

$table->unsignedInteger(SomeModel::PARENT_ID)->nullable();

bobbybouwmann left a reply on Sticky Database Name Across Environments • 1 day ago

How do you run the tests?

Also did you run php artisan config:clear! It would be cached somehow!

bobbybouwmann left a reply on How Do You Query Relatable Table (more Than 2 Tables)? • 1 day ago

In Laravel you either use relationships to fetch relatable tables or you can fetch them one by one! If you want to know how Laravel is doing that you can start by reading the docs here: https://laravel.com/docs/5.6

Just read the docs and find out how the things work a bit! The concept is still the same, where you have a controller that fetches data and returns that to the view ;)

bobbybouwmann left a reply on Spatie MediaLibrary Default Storage Depending On The Model • 1 day ago

The "custom folder struture" part is the only way to actually rename the folders!

You can really easily create a new class that extends that interface and return some path for your models

class CustomPathGenerator implements PathGenerator
{
    public function getPath(Media $media) : string
    {
        if ($media instanceof Post) {
            return 'posts/' . $media->id;
        }

        if ($media instanceof Product) {
            return 'products/' . $media->id;
        }
    }

    public function getPathForConversions(Media $media) : string
    {
        return $this->getPath($media) . 'conversions/';
    }

    public function getPathForResponsiveImages(Media $media): string
    {
        return $this->getPath($media) . 'responsive/';
    }
}

Don't forget to update the config and point to the class

'path_generator' => CustomPathGenerator::class,

bobbybouwmann left a reply on (errno: 150 "Foreign Key Constraint Is Incorrectly Formed") • 1 day ago

I agree with @Cronix! It makes things a lot easier when you work with Laravel! However you're still free to do whatever you want, it's just a suggestion ;)

bobbybouwmann left a reply on (errno: 150 "Foreign Key Constraint Is Incorrectly Formed") • 1 day ago

Run migrate:fresh. It will remove all tables and migrate everything again!

You cannot run one table migration at the time. You can only undo a batch of migrations at a time. However if you drop everything you will only have on batch.

bobbybouwmann left a reply on (errno: 150 "Foreign Key Constraint Is Incorrectly Formed") • 1 day ago

Not sure, but maybe you can't set the foreign key on a column with the same name as the column of the other table. They both are called user_id right now! Not sure if that is the problem though!

bobbybouwmann left a reply on (errno: 150 "Foreign Key Constraint Is Incorrectly Formed") • 1 day ago

@Cronix user_id should be correct, as you can see in his migration of the users table.

@jwillz21 Are you sure the users table is already migrated?

bobbybouwmann left a reply on Best Practice Loading Vue • 1 day ago

Great search for that bug! Well glad you know what it is right now :D

bobbybouwmann left a reply on Get Loged User Laravel 5.3 Boot Method Model • 1 day ago

I see nothing strange here!

bobbybouwmann left a reply on Making This API Code Bring Through More Relevant Data? • 1 day ago

They probably used a lot of parameters for a random movie on the randomlists.com website. I bet they look for a higher rating or based on the year it was created. I think you just need to play around with all the options you can use for the discover api.

bobbybouwmann left a reply on AcceptDialog With Laravel Dusk • 1 day ago

Aah great! Glad you fixed it :D

bobbybouwmann left a reply on Change Laravel Version In An Existing Project • 1 day ago

Yes, that should be it! You can then keep it in your own repository under your own username

bobbybouwmann left a reply on Bootstrap Tabs "#/" Not Appearing And Can't Navigate Directly To Tab • 1 day ago

Mmh, this must be something in the routing part of spark then... I currently have no app running with spark, so I can't really help you with that.

I guess it's using the vue-router plugin and there is an option to turn that on or off! But that's just guessing!

bobbybouwmann left a reply on How Does Your Application Structure Look Like • 1 day ago

For your example case I would probably create a separated Api directory in the Http directory for the routes. After that I would create a directory for Services and maybe even Repositories in the app directory for reusable parts.

You can put everything in a separate directory according to the domain, but that is up to you. It always depends on the size of the application. You can start with this and later migrate to something else!

My Domain directory would only have calls that are important for the domain itself. For example a calculation of something.

My Services directory would contain classes for third party libraries for example. You can also use packages for that, but if they don't exists you create your own abstraction. Your services can then be used in the domain layer ;)

bobbybouwmann left a reply on Retrieving A Small Number Of Fields From A Model Collection, But Keeping Relationships? • 1 day ago

Just remember that you always need to keep the id fields and the foreign key fields. After that you should be able to remove any other field of the model ;)

bobbybouwmann left a reply on Change Laravel Version In An Existing Project • 1 day ago

Yeah, you can create your own repository with a clone of the current repository. Then you can update the composer.json file to make it compatible with Laravel 5.5! You can then either register your own package on composer or use composers vcs option.

Another option is asking the author of the package to update it, but the package hasn't been updated for almost 2 years, so that's likely not going to happen.

Let me know if you have more questions!

bobbybouwmann left a reply on Bootstrap Tabs "#/" Not Appearing And Can't Navigate Directly To Tab • 1 day ago

You need to remove the / from the url here!

This

myapp.com/blog#/posts

Should be this

myapp.com/blog#posts

bobbybouwmann left a reply on AcceptDialog With Laravel Dusk • 1 day ago

I can't find anything that might cause this... Maybe you can try to find out what's happening in the acceptDialog method and see what the alert object holds at that time!

bobbybouwmann left a reply on HasManyThrough Not Returning Any Results • 1 day ago

So what is f_id?

You make it really hard with renaming everything! Did you just write it out for yourself what the relationship should look like?

bobbybouwmann left a reply on 401 Unauthorized Status On Passport Laravel_token • 1 day ago

It must be the configuration! Right now it's using the default api settings from Laravel, but you need to use the passport one!

You can try to run

php artisan cache:clear

bobbybouwmann left a reply on How Does Your Application Structure Look Like • 1 day ago

I normally create a folder called Domain in the app directory for business logic.

If the application is smaller I normally keep everything in the app directory and create an extra folder called Services in the app directory for special calls like API stuff and so on.

Do you have a specific example for brainstorming?

bobbybouwmann left a reply on AcceptDialog With Laravel Dusk • 1 day ago

Your code looks correct! Do you use the latest version of Laravel Dusk?

bobbybouwmann left a reply on 401 Unauthorized Status On Passport Laravel_token • 1 day ago

You need to update the config of your Laravel application to use the correct api driver. Did you follow the full install guide?

Documentation: https://laravel.com/docs/5.6/passport#installation

// config/auth.php

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],

bobbybouwmann left a reply on Extending ConsoleMakeCommand • 1 day ago

Well that's how abstract classes and interfaces work! There is currently no way of doing that!

15th June, 2018

bobbybouwmann left a reply on What Is The Right Way To Do Validation? • 2 days ago

Laravel will catch the ValidationException automatically for you and redirect you back to the previous url with the provided content that was posted.

You're free to catch the exception yourself ;)

bobbybouwmann left a reply on Dropzone.js How To Hide Progress Bar Of Uploaded Files? • 2 days ago

What are you exactly trying to achieve? You only do one thing in the queuecomplete event! If you want to do something for each file you need to do that in that event I guess. Not really sure what you want here! Can you elaborate a bit more?

bobbybouwmann left a reply on Howw To Show Query Results In A Pdf File? (show Each List Item In A Page Of The Pdf) • 2 days ago

If you want the full class name should use this

use Barryvdh\DomPDF\Facade as PDF;

bobbybouwmann left a reply on Get Loged User Laravel 5.3 Boot Method Model • 2 days ago

How does your other model look like?

bobbybouwmann left a reply on Pagination , Filter Lost On Other Pages • 2 days ago

@trogne You can't mark your own answer as the best reply here! @rin4ik gave you the perfect example, you just needed to use the correct fields! He should be the one with the credits for this one!

Edit Your Profile
Update

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