bobbybouwmann

Laravel Evangelist at Enrise

Member Since 6 Years Ago

Apeldoorn

Experience Points
2,028,825
Total
Experience

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
1876
Lessons
Completed
Best Reply Awards
2645
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 50
2,028,825 XP
Apr
09
1 week ago
Activity icon

Replied to Maatwebsite/Excel : I Need Some Help With The Map Function

Sure you can run an if-else statement. However, the map function doesn't know anything about the previous item you mapped over. So in this case $lastcar will always be null.

You can however get around this by doing the looping yourself. You return any collection here yourself. This also means you need to retrieve the data yourself.

Documentation: https://docs.laravel-excel.com/3.1/exports/collection.html#using-custom-structures

Activity icon

Replied to Algolia Scout

To make that work you need to associate the data from your relationship to the post you store in Algolio.

Documentation: https://www.algolia.com/doc/framework-integration/laravel/indexing/configure-searchable-data/?client=php

Activity icon

Replied to Laravel Websockets - Multi-Tenancy With Private Channels

I'm not 100% sure, but I think you have to create your own AppProvider to make sure it can determine what app is what. I can imagine that it by default always assumes the same backend.

You can override this behaviour but that requires some work on your side.

Documentation: https://beyondco.de/docs/laravel-websockets/advanced-usage/app-providers

Activity icon

Replied to Allow User To Update A Specific Field With ACL Laravel 6

Well, you should probably create separate permissions or roles for viewing and updating content. This way you can assign the correct permission/role to the correct user.

Apr
08
1 week ago
Activity icon

Replied to Laravel Queue With One Email ID In TO Address

Your job should look like this

public function __construct($email)
{
    $this->email = $email;
}

public function handle()
{ 
    Mail::to($this->email)->send(new SendEmailCircular());
}
Activity icon

Replied to What To Use With Multiple Api Calls Inside A Request

@senty Well, relying on internet is a bad thing in general at all.

I think the web-socket approach is pretty good here. The alternative is a long waiting screen until you collected all the data.

Apr
04
1 week ago
Activity icon

Replied to What To Use With Multiple Api Calls Inside A Request

Well, it depends on the data. Let's say the rates are only updated every hour? Well, in that case, you might be able to cache the results and use a cronjob to retrieve and cache the data again. That way you will have the fastest responses.

If the data changes every minute that a queue and broadcasting sounds like the best solution for this. Especially if you want to make this scale automatically.

Also, the async package should work perfectly fine here. You can use dependency injection inside your class or use the app helper to resolve any dependencies. Check this part of the documentation

Documentation: https://github.com/spatie/async#working-with-tasks

Activity icon

Replied to Unable To Update Per Page Count From The Frontend (Laravel, InertiaJS, VueJS)

Right now your controllers expect an URL that looks like this

example.com/users?per_page=3

It seems that the problem is that you're setting the value of the per_page on the paginated object, but the paginated object is a result of the query. Instead, you need to make sure the code in the backend (laravel) receives the per_page data in some way. This can be updating the URL from your frontend or settings some kind of session instead of using a query value from the URL.

Mar
30
2 weeks ago
Activity icon

Replied to Laravel Sail On Windows

Did you install Docker? Laravel sail runs on Docker, to make it work you need to have Docker installed and running in the background

Activity icon

Replied to Laravel Queue With One Email ID In TO Address

Well, it seems you're using a User model here but you used a value that doesn't exist in the database. Without more code I can' really help you.

Mar
28
2 weeks ago
Activity icon

Replied to Laravel Queue With One Email ID In TO Address

Well, in this case you pass in an array of emails. At least, it seems it happens like that.

Instead, you should send an email for each item in the list.

public function handle()
{
	$mailable = new SendEmailCircular();

	foreach ($this->details['email'] as $email) {
		Mail::to($email)->send($mailable);
	}
}

Here you look over all the emails.

If you have a lot of emails, it might be better to schedule a job for each email. This scales better if you have a database or redis queue.

$emails = User::select('email')->get();

foreach ($emails as $email) {
	dispatch(new SendEmailCircularJob($email));
}

You job will then only send the email to the given email.

Activity icon

Replied to [AskJS] Is It A Problem That JQuery Terminal Use JQuery?

Well, if you're trying to sell something then indeed jQuery is not a hot topic anymore. Then it might be better to use a different name. But if you're building it with jQuery you should at least mention it inside the description.

In general, jQuery is not that bad as a technology. It still has its place in the development community and still serves its purpose.

Mar
26
3 weeks ago
Activity icon

Replied to Associate Multiple Models To Items

A polymorphic relationship is perfect for this use case!

Documentation: https://laravel.com/docs/8.x/eloquent-relationships#polymorphic-relationships

Here is a tutorial with a great example: https://www.youtube.com/watch?v=rx1DQBE01b0

Mar
25
3 weeks ago
Activity icon

Replied to Error With DigitalOcean Spaces Database Backup

Well, the digital ocean storage system is built on the same protocol as S3. So basically they work the same, but they have a different URL and authentication method behind them.

Make sure to double-check the authentication part of your setup. It seems it's missing some keys here or you're using the wrong keys.

Activity icon

Replied to Create New Project Inside Homestead

Mmh, the idea behind Homestead (or Vagrant) is that it syncs your local machine to the other environment. In general, you work from your main machine and that's it.

I don't really understand why you create a new project inside homestead and then start moving directories. I never done that before and all my projects run perfectly fine...

These are the steps I follow

// Go to my code directory
cd ~/Code

composer create-project laravel/laravel my-project

Now I already have a project with composer and everything you need from Laravel. Now I just edit my homestead file, add the the new site and done.

folders:
    - map: ~/Code
      to: /home/vagrant/Code

sites:
    - map: project.local
      to: /home/vagrant/Code/my-project/public
      php: "7.3"

databases:
    - my-project

The final step is reloading Homestead with provision and you're done.

Activity icon

Replied to Laravel 5.7 419 Status Code In Ajax Request

So the problem here is that you post to a route that requires a CSRF-token. This token is used to protect your forms from being submitted from another website.

In your case, the token is probably expired. On every request, Laravel generates a new CSRF-token to make sure it's unique. Since you do a new request using the ajax call a new token is generated as well. I think this only happens for you if you do multiple ajax calls in a row on the same page.

This page might help you in how to handle this correctly: https://stackoverflow.com/questions/45668337/how-can-i-get-new-csrf-token-in-laravel-by-using-ajax Another solution is actually using an API endpoint and using a token for the authentication. The routes defined inroutes/api.php by default don't check for the CSRF-token. Its up to you to add authentication to it.

Activity icon

Replied to Eager Loading For Authenticated User ?

Instead of using with, you can use load to eager load the data on an existing model. We call this lazy eager loading

$user = Auth::user():

$user->load (['posts', 'likes', 'comments.parent']);

Documentation: https://laravel.com/docs/8.x/eloquent-relationships#lazy-eager-loading

Mar
23
3 weeks ago
Activity icon

Replied to SSH'ing Into Forge Server Timing Out After 20 Seconds

@kyleshepherd I had this once as well with Forge. The support told me to delete the server and create a new server instead. Probably something went wrong during the deployment of the server.

Activity icon

Replied to Create New Project Inside Homestead

So the idea behind Homestead and its configuration is that you have a single file to setup the syncing between your local system and homestead in one place. In general, you can configure a directory (or multiple) with all you projects. Then you only need to map a domain name to the directory and you're done. That is the basic idea behind Homestead.

Anyway, can you show your Homestead.yaml file?

Activity icon

Replied to SQLSTATE[HY000]: General Error: 1364 Field 'username' Doesn't Have A Default Value

The reason you get this error is because you can the $this->follows()->save($user). The save method tries to create a new user and connect it to the followers table.

Instead, you need to use attach here because it's a many-to-many relationship.

public function follow(User $user)
{
	return $this->follows()->attach($user);
}
Activity icon

Replied to Why Using A REST API For Fetching Data From Database ?

Well, it depends on how you need to access the data. If you only have a Laravel project with controllers and blade files there is no need for a REST-API since you can query the database directly.

If you have a frontend app/website and you need to fetch data then it makes sense to create a REST-API. The API itself is also just controllers that query the database directly.

Also if you need to use the same backend for different frontend systems it makes sense to create one API which you can use to collect the data on a single place

Activity icon

Replied to Generate Image When User Click On Generate

Do you want to convert your JSON to an image? Not sure what you mean by that?

Mar
20
4 weeks ago
Activity icon

Awarded Best Reply on Filtering Year / Month / Day With WhereDate() And Error With Carbon ?

What is the value of the date column? I don't see a reason why whereDate wouldn't work here.

You can probably also solve this using a groupBy

Session::whereDateBetween('date', [$date, $date->copy()->addDays(15)])
	->groupBy(DB::raw('DATE(date)'))
	->get();
Mar
19
4 weeks ago
Activity icon

Awarded Best Reply on Checking The Thread Table If It Is Marked As Solved

There are multiple ways to define this.

You can store the best answer comment on the thread like you have now. In that case, you can check based on the ID of the comment and the stored solution on the thread.

// In your view
@foreach ($thread->comments as $comment)

	@if ($comment->id === $thread->solution)
		Do something extra for the solution
	@endif

@endforeach
Activity icon

Replied to Checking The Thread Table If It Is Marked As Solved

There are multiple ways to define this.

You can store the best answer comment on the thread like you have now. In that case, you can check based on the ID of the comment and the stored solution on the thread.

// In your view
@foreach ($thread->comments as $comment)

	@if ($comment->id === $thread->solution)
		Do something extra for the solution
	@endif

@endforeach
Activity icon

Replied to A Basic, Safe Wysiwyg Editor Recommendations?

I'm personally a really big fan of Froala, but that is a paid option: https://froala.com/wysiwyg-editor/

I'm also a big fan of Quill: https://quilljs.com/

In the end, it depends on the needs to have of course.

Activity icon

Replied to Filtering Year / Month / Day With WhereDate() And Error With Carbon ?

What is the value of the date column? I don't see a reason why whereDate wouldn't work here.

You can probably also solve this using a groupBy

Session::whereDateBetween('date', [$date, $date->copy()->addDays(15)])
	->groupBy(DB::raw('DATE(date)'))
	->get();
Activity icon

Replied to Create Or Update Function

What exactly is not working for you?

Activity icon

Replied to Polymorphic Route Model Binding

What you can do is change the name of the variable and use a custom binding

Route::get('contacts/{contact}/comments/{commentContact}, [ContactCommentController::class, 'show']);

Then inside your RouteServiceProvider you can do something like this:

Route::bind('commentContact', function ($value, $route) {
	Comment::where('id', $value)
		->where('contact_id', $route->parameter('contact')->id);
});

Another solution is implementing the resolveChildRouteBinding method on the model

class Contact extends Model
{
	public function resolveChildRouteBinding($childType, $value, $field)
	{
		// This returns the comments() relationship on the contact.
		$relationship = $this->{Str::plural(Str::camel($childType))}();

		// Field could be defined by using {contact:id}, otherwise we get the primary key
		$field = $field ?: $relationship->getRelated()->getRouteKeyName();

		return $relationship->where($field, $value)->firstOrFail();
	}
}

Code might look complicated but something in this direction should work.It could be I placed the method on the wrong model, but it should put you in the right direction.

Documentation: https://laravel.com/docs/8.x/routing#customizing-the-resolution-logic

Activity icon

Awarded Best Reply on What's The Best Way To Create A Search Engine For My App

A good alternative for ElasticSearch is https://www.meilisearch.com/

Laravel also has a tool for searching called Laravel Scout. This has support of the box for tools like ElasticSearch, Meilisearch, and Algolia.

Documentation: https://laravel.com/docs/8.x/scout

Activity icon

Replied to Filtering Year / Month / Day With WhereDate() And Error With Carbon ?

Create from format only works if the given date is in that format. So passing in 2021-03-15 09:00:00 won't work here. Instead, you need to do this:

$date = Carbon::parse($this->attributes['date']);

Not sure if this is answering your question here. It seems that you're only issue is the data missing thing.

Activity icon

Replied to How To Use Multiple Version Of PHP Xampp On Windows

After googling I found some tutorials but they only seem to be for older PHP versions like 5.6 It seems that Xampp is not really made for this sadly.

It's probably better to search for an alternative of switch PHP version when starting Xampp.

Activity icon

Replied to Blade's Loop Variables To Iterate Through Images

Are you sure this part is correct?

{{ $loop->first ? 'active' : 'hidden', $loop->remaining ? 'active' : 'hidden' }}

This doesn't look like valid PHP to me. Especially the comma after 'hidden' seems to be incorrect. This would probably solve that

{{ $loop->first || $loop->remaining ? 'active' : 'hidden' }}

The javascript looks ok to me, no weird things in there.

Activity icon

Replied to Session Variable Not Fetching In Listener

The listener is not part of the session. You could queue a listener for later execution so you can't rely on the session.

Instead, you should set the timezone for the event. Since this is a Laravel event that's not easily done. Another option is storing the timezone on the user instead.

Activity icon

Replied to What's The Best Way To Create A Search Engine For My App

It's free. You have to install it yourself on your own server.

Mar
18
4 weeks ago
Activity icon

Replied to Insert JSON

There is an extra closing comma. But without more context, I'm not sure if I can help you here

Activity icon

Awarded Best Reply on How To Mock Storage S3 Copy Method

The Storage::fake('s3') call is only used to set up a fake class. It still runs the same methods. However, it will use your local file system instead of s3.

You can see here that it creates a new FileSystem for local usage: https://github.com/laravel/framework/blob/8.x/src/Illuminate/Support/Facades/Storage.php#L50

Activity icon

Replied to Laravel Sail And DockerHub

Well, Laravel Sail is not meant to be running on production. It's really a tool for local development and nothing more.

You can run sail artisan sail:publish which gives you a Dockerfile you can customize to your needs. You can then publish this file on DockerHub using the command line if you wish.

Activity icon

Replied to How To Mock Storage S3 Copy Method

The Storage::fake('s3') call is only used to set up a fake class. It still runs the same methods. However, it will use your local file system instead of s3.

You can see here that it creates a new FileSystem for local usage: https://github.com/laravel/framework/blob/8.x/src/Illuminate/Support/Facades/Storage.php#L50

Activity icon

Replied to What's The Best Way To Create A Search Engine For My App

A good alternative for ElasticSearch is https://www.meilisearch.com/

Laravel also has a tool for searching called Laravel Scout. This has support of the box for tools like ElasticSearch, Meilisearch, and Algolia.

Documentation: https://laravel.com/docs/8.x/scout

Mar
17
1 month ago
Activity icon

Awarded Best Reply on Laravel Excel

Yes, it's an integer. Luckily there is method for it

PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateFromExcel) 

Here is an example

use PhpOffice\PhpSpreadsheet\Shared\Date;
class DataImport implements ToCollection
{
    public function collection(Collection $rows)
    {
		foreach ($rows as $row) {
			return [
				'date' => Date::excelToDateTimeObject($row[0]) ,
			];
		}
    }
}

'date' is now a DateTime object which you can parse into Carbon to use for calculations.

Mar
15
1 month ago
Activity icon

Awarded Best Reply on Vue3 Disabling Dropdowns In Breeze And Debugbar Dropdowns

@lemmon According to this issue it's possible: https://github.com/alpinejs/alpine/issues/363

However, I would not recommend it. Vue is also just JavaScript so you can basically achieve the exact same things in the end. Although Alpine makes it really easy, you're now building your application based on two different JavaScript frameworks.

Activity icon

Replied to How To Implement PORTO SAP To Laravel

Well, wanting this structure vs needing this structure is a whole different thing.

Anyway, you can probably build this by setting up a base package that contains the base logic and creating multiple laravel projects that only have the functionality they need. This is not the same structure as PROTO is meant, but you can't force that structure on an MVP framework. Laravel simply doesn't run without the core components defined inside the vendor directory.

Activity icon

Replied to Vue3 Disabling Dropdowns In Breeze And Debugbar Dropdowns

@lemmon According to this issue it's possible: https://github.com/alpinejs/alpine/issues/363

However, I would not recommend it. Vue is also just JavaScript so you can basically achieve the exact same things in the end. Although Alpine makes it really easy, you're now building your application based on two different JavaScript frameworks.

Mar
14
1 month ago
Activity icon

Awarded Best Reply on Github Actions Push To Deploy

It looks like you configured the SSH key incorrectly. Did you add a secret for your SSH key? And did you copy in the correct value in there?

You can find some pointers here: https://github.com/appleboy/ssh-action/issues/6

Feb
22
1 month ago
Activity icon

Replied to Laravel Excel

Yes, it's an integer. Luckily there is method for it

PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateFromExcel) 

Here is an example

use PhpOffice\PhpSpreadsheet\Shared\Date;
class DataImport implements ToCollection
{
    public function collection(Collection $rows)
    {
		foreach ($rows as $row) {
			return [
				'date' => Date::excelToDateTimeObject($row[0]) ,
			];
		}
    }
}

'date' is now a DateTime object which you can parse into Carbon to use for calculations.

Activity icon

Replied to Dispatachable Events

The package is great indeed, but the model in the package should fire these events or register them in Laravel. If that is not the case you can't use the $dispatchesEvents.

It's currently not clear to me where this is going wrong. Inside the package or in your own code. What is the value of $created? It seems that this is an error in your code. Let's start there first.

Feb
18
1 month ago
Activity icon

Replied to Like And Dislike Using Ajax In Laravel

Well, on success you just need to change the class of the icon or change the CSS using jQuery. Both options are fine in your case.

Activity icon

Replied to Laravel Echo How To Get Notified When Someone Joins A Public Channel

You need to use a so-called "Presence channel" for this. This will automatically record if people join or leave channels. For each event, you can add your own logic. In your case, that might be sending an API request to the backend.

Documentation: https://laravel.com/docs/8.x/broadcasting#joining-presence-channels

Community Pillar

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