bobbybouwmann

bobbybouwmann

Member Since 4 Years Ago

Apeldoorn, The Netherlands

Developer at Enrise

Experience Points 1,439,685
Experience Level 50

0 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 1509
Lessons
Completed
Best Reply Awards 1801
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

20 Aug
21 hours ago

bobbybouwmann left a reply on 'appointedd_appid' => 'required_if: Isbooking_enabled,1' Does Not Gives Validation Error Message

You can customize the messages in the resources/lang/en/validation.php file.

'custom' => [
    'appointedd_appid' => [
        'required_if' => 'You custom message here',
    ],
],

Documentation: https://laravel.com/docs/5.8/validation#custom-error-messages

bobbybouwmann left a reply on Reusing Database Connection Calls On The Fly

@punksolid is correct, middleware is the best place to do this!

bobbybouwmann left a reply on Need To Adapt My Function Index() In Laravel

You can probably just do this

->when($request->has('search'), function (Builder $query) use ($request) {
    $query->join('eleves', 'retours.fk_eleve', '=', 'eleves.id')->orderBy('eleves.nom', 'asc')->select('retours.*');
})
->paginate(5);

If you want to see the actual query, you can replace paginate(5) by toSql(). It will then output the sql query, so that might be useful for debugging purposes ;)

bobbybouwmann left a reply on Where To Put Backend Socket Connection Code?

I would probably create a directory called Services in my app directory and then add the classes for that kind of communication in there. This way it's isolated from the rest, but also reusable on different places.

bobbybouwmann left a reply on Attempt To Assign Property 'debug' Of Non-object

It seems that the error comes from the mlanin/laravel-api-debugger package. Have you tried removing or disabling it to check if your controller works correctly?

Also your response in your ajax call should be key value based. So someting like this

return response()->json([
    'domains' => $client->domains,
    'projects' => $client->projects,
], 200);

It could be that this already throws an error and that the laravel-api-debugger can't handle that error and throws an error as well :P

19 Aug
1 day ago

bobbybouwmann left a reply on Wrong Laravel Version

You're probably running an old PHP version. If you run php -v on the command line you get the current installed PHP version. I expect you're running something like PHP 5.5.

If you upgrade to at least PHP 7.2 and you run composer create-project again it should install Laravel 5.8.x

Let me know if that works for you!

bobbybouwmann left a reply on Stuck With Testing

I think the issue here is that you call make on the factory and not create. When you do make you get a Cat model, but without an ID. It won't be saved in the database. So updating it to this should put you in the right direction

$cat = factory(Cat::class)->create();

bobbybouwmann left a reply on Or Method Not Working

The or helper method has been removed since Laravel 5.7 as you can read here in the upgrade guide: https://laravel.com/docs/5.7/upgrade

Instead you can use the native php function for that

{{ $status ?? 'Unknown' }}

This is called the "null coalesce" operator. Let me know if that works for you!

bobbybouwmann left a reply on Multiple Counts

Assuming again that you've setup your relations correctly you can do something like this

$cat = Cat::withCount(['shows', 'attributes'])->first();

$cat->shows_count;
$cat->attributes_count;

bobbybouwmann left a reply on Vue And Axios: Not Updating As Expected

Your code looks correct to me. Are you sure the javascript is compiled?

Also I would change the v-for to something like this instead

<li v-for="category in categories" v-bind:key="category.id">
    {{ category.title }}
</li>

bobbybouwmann left a reply on Only Show Own Created Categories

Assuming that you've setup the correct relationships between user and category, basically user_id column in the categories table, you can do something like this

$categories = Auth::user()->categories()->orderBy('updated_at', 'desc')->paginate(30);

Let me know if that works for you!

bobbybouwmann left a reply on 'appointedd_appid' => 'required_if: Isbooking_enabled,1' Does Not Gives Validation Error Message

You need to use required_with when using checkboxes

return [
    'isbooking_enabled' => 'sometimes',
    'appointedd_appid' => 'required_with:isbooking_enabled,on',
];

bobbybouwmann left a reply on Laravel 5 Localized Date Validation

You can probably split the incoming string by each space and validate each parts separately using Carbon. It's not ideal, but it's something!

bobbybouwmann left a reply on Using Passport To Authenticate Other Applications

Awesome! Let me know if you have more questions, I might be able to help ;)

bobbybouwmann left a reply on Queue Configuration On Forge, Redis Not Configured

Basically you only need to start horizon. Horizon will make sure that Redis will be connected in Forge.

Check this video: https://laracasts.com/series/learn-laravel-forge/episodes/5

bobbybouwmann left a reply on Using Passport To Authenticate Other Applications

Laravel Passport is build on the thephpleague/oauth2-server package. They have pretty good documentation on oauth and what kind of grant you should pick

Documentation: https://oauth2.thephpleague.com/authorization-server/which-grant/

Going through that complete documentation is definitely worth it!

bobbybouwmann left a reply on Anyone Can Please Share The Sample Code For Dynamic Dropdown In Larvel Using Foreign Key And Without Using Jquery Or Ajax

You need javascript to make this work. Even if you put all the possible options in the HTML you still need a way to display them!

Also doing an ajax call is a good practise for this use case!

bobbybouwmann left a reply on Soft Deleted Model Returned In Queue. Should Throw An Exception

It seems that this was added in 5.5: https://github.com/laravel/framework/pull/22119

Anyway, instead of returning early in your job you can check if the model has been soft deleted or not and than return early! Checking on the deleted_at column is perfectly fine ;)

if ($model->trashed()) {
    return;
}

bobbybouwmann left a reply on Page Does Not Load When I Add Field Name In Form:checkbox

It probably doesn't work in create because it's empty!

Also looking at the form, first you pass in $data which is probably an array, but in the other example you pass in a boolean. So it seems that you're using two types of data here. You need to make sure that the types are the same.

For example for create view you could just pass in false.

18 Aug
2 days ago

bobbybouwmann left a reply on Resourceful Controller/Views -- Some Ambiguity

Well in this case your TimesheetsController should only have index method which displays a list of the given resource. So for example a list of posts or in your case a list of different kind of timesheets.

Then for each timesheet you can create a specific controller. For example CurrentMonthTimesheetController which only has a show method.

Another solution is using the __invoke method for each controller that you have. This way you don't have to specify a index or show method. You will only have the __invoke method that will return the correct result in each controller.

Documentation: https://laravel.com/docs/5.8/controllers#single-action-controllers

So in your example you would have something like this

Route::get('timesheets', TimesheetsController::class)->name('timesheets.overview');
Route::get('timesheets/current-month', CurrentMonthTimesheetController::class)->name('timesheets.current-month');
Route::get('timesheets/last-month', LastMonthTimesheetController::class)->name('timesheets.last-month');

Let me know if that is a valid solution for you!

bobbybouwmann left a reply on Calculate Birthdate

@bugsysha I do this daily ;) Fast fingers!

bobbybouwmann left a reply on Project To PHP 7.1

Object itself is not a valid keyword in PHP. You do have the lower key version for that though: object. Anyway, with PHP the return type should match the actual class, otherwise strict typing wouldn't make sense!

So you should update it to this

use Illuminate\View\View;

class ComputersController extends Controller
{
    public function index(): View
    {
        $computers = Computer::all();

        return view('computers.index', compact('computers'));
    }
}

Let me know if that makes sense to you ;)

bobbybouwmann left a reply on Browser Testing

A non PHP alternative might be cypress! It's written in JavaScript and you write your tests in JS, but you will get video recording support and it's a lot faster than Laravel Dusk as well!

https://www.cypress.io/

bobbybouwmann left a reply on Calculate Birthdate

You can calculate the date by doing a diff between two dates.

$age = Carbon::parse($patient->dateOfBirth)
    ->diff(Carbon::now())
    ->format('%y years %m months  %d days');

bobbybouwmann left a reply on XML Not Displaying Results

Do you get any errors? Does your database return results?

Also you're using mysqli in your view, this is a really bad solution in PHP. mysqli is not supported anymore, Laravels internal database query class can help you with this!

bobbybouwmann left a reply on Dinamically Generate Gates For Permission Control

The internals of Laravel is doing the exact same thing for policies and using the Gate facade as well. This is perfectly fine ;)

You can do one more improvement and that is adding caching for the permission queries. If you get a lot of permissions the pages might load a bit slower ;)

bobbybouwmann left a reply on Duplicacy Of Dates

Have you looked into the the groupBy or mapToGroups method of the collection class?

Documentation: https://laravel.com/docs/5.8/collections#method-groupby

bobbybouwmann left a reply on Is There A Way To Restrict Users From Accessing A Page?

Check this part of Laravel: https://github.com/laravel/framework/blob/5.8/src/Illuminate/Foundation/Exceptions/Handler.php#L190

As you can see here Laravel checks if it should give back a normal or json response. So if your request has the correct headers, it will respond with json.

You can then throw any exception or use abort for example to deny access.

bobbybouwmann left a reply on XML Not Displaying Anything

I don't see any xml...

bobbybouwmann left a reply on Laracast Forum Tech Stack

Laravel and Vue indeed ;)

Jeffrey also uses algolia for the search functionality, I'm not sure if that is in combination with Laravel Scout.

bobbybouwmann left a reply on Displaying Only Unique Values

Another solution is grouping the results by the user using the collection methods, but that is all up to you ;)

Documentation: https://laravel.com/docs/5.8/collections#method-groupby

17 Aug
3 days ago

bobbybouwmann left a reply on How Do I Add A Colum To My Database Table Without Losing My Database Entrys

@click Some people update the initial migrations and therefore they lose all there data because they need to remigrate the whole database. Not everyone is known with this approach ;)

bobbybouwmann left a reply on How Do I Add A Colum To My Database Table Without Losing My Database Entrys

If you have a migration that adds one column with a default value, it won't delete the other entries in the database. One important thing is that you set a default value for that column or make it nullable! So your migration will look like this:

public function up()
{
    Schema::table('cars', function (Blueprint $table) {
        $table->integer('seats')->default(5);
    });
}

So you need to create a new migration using php artisan make:migration add_seats_cars_table to be clear! If you run php artisan migrate the column will be added without losing any data ;)

bobbybouwmann left a reply on Tooltip On Badge

It seems that you need to pass the slot="activator" parameter to the badge component

Source: https://github.com/vuetifyjs/vuetify/issues/3178

In the bug report you can also find some links to code examples on codepen

bobbybouwmann left a reply on Displaying Only Unique Values

You can do something like this in your view

@foreach ($job->sub_jobs as $sub_job)

    @if($loop->first)
        {{ $sub_job->user->name }} <br>
    @endif

    // Display the sub_job content here

@endforeach

Documentation: https://laravel.com/docs/5.8/blade#the-loop-variable

bobbybouwmann left a reply on Unable To Access A Json File In The App Root

../ indicates that the file is in the parent directory. So if it's placed in the same file as the .env this shouldn't match right?

Another option is being really specific about the location of the file

putenv('GOOGLE_APPLICATION_CREDENTIALS=/home/user/www/XXXXXXXXa8006b.json');

bobbybouwmann left a reply on Laravel 5.7 | Bootstrap Tabs - Problem With Multiple Tabs Generated From Laravel

Wouldn't it better if you just did this

 <li class="{{ $serv->id == 1 ? 'active' : ''}}">
    <a data-toggle="tab" href="#{{ $serv->id }}">
        {{ $serv->type }}
    </a>
</li>

At this point if you have two services with the same type you get a duplicate tab, like you have right now. To fix this you should already do that in the query process, you don't want all this logic in your view! You should grab all the results you need in the controller and then pass it to the view ;)

bobbybouwmann left a reply on How This Function Works

So what it does is look for any children using children() call on the current query. Then it uses with to get call it's own method called childrenRecursive. Basically you're also loading those relationships on the current object. Now whenever this childrenRecursive is called it will again look for any children and then the childrenRecursive will be loaded again on the query.

It will keep doing this until the children() returns an empty result. After that the childrenRecursive isn't loaded anymore and it will return the final result.

bobbybouwmann left a reply on Varchar Primary Key Empty

You're not using the default primary key, but Laravel doesn't know that! So you need to tell your Invite model that:

class  Invite extends Model
{
    public $incrementing = false;

    protected $keyType = 'string';
}

Let me know if that works for you!

bobbybouwmann left a reply on Access Form Request From Observer

If you use the request() helper or Request:: facade you should be good to go ;) You can't inject a class in the model observer for that.

bobbybouwmann left a reply on Build Wordpress Like CMS

Shortcodes have to be parsed in a later state, after the content has been generated. You can probably build this with a middleware.

However there is very nice package for this! You only need to write the classes that handles the conversion: https://github.com/webwizo/laravel-shortcodes

Let me know if this is what you're looking for!

bobbybouwmann left a reply on I Have A Input Of Start Date, And Input Of Days Also, Then Want Store Expiry Date Without $request->input? And With Using Start Date + Days In Single Submit.

Well you need to do the calculation somewhere right? So you either get the numbers from the request or your have to combine the two in the frontend already. You can for example use momentjs for that.

I'm not sure if I understand your question 100%, can you maybe explain a little bit more about it?

bobbybouwmann left a reply on Noob Here

It seems that you're using the Laravel Collective HTML /Form package. Did you install this package?

Documentation: https://github.com/LaravelCollective/docs/blob/5.6/html.md

It shows how to set it up and how to use it ;)

bobbybouwmann left a reply on Collection Challenge

Yeah you can! You look into mapToGroups ;)

Documentation: https://laravel.com/docs/5.8/collections#method-maptogroups

bobbybouwmann left a reply on How Do You Return Private File From S3 In A Controller?

The fact that it returns file.png is already odd! Have you tried not passing a name for instance? Does it still return the same thing?

bobbybouwmann left a reply on Which Service Have I To Select ?

Yeah the Maps Javascript API is what you need!

bobbybouwmann left a reply on If You Reload The Page While Viewing Your Own Post The "views Counter" Is Incremented

I guess it depends on what your definition of a "view" is. Is a view any page reload than the current implementation is correct. If your definition of a view that each view is connected to a unique user than this is not the correct implementation.

Maybe Jeffrey can share his view on this?