bobbybouwmann

bobbybouwmann

Member Since 4 Years Ago

Apeldoorn, The Netherlands

Developer at Enrise

Experience Points 1,295,765
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 1463
Lessons
Completed
Best Reply Awards 1578
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

19 Apr
1 day ago

bobbybouwmann left a reply on How To Manually (terminal Command) Delete Queue Workers

You have to kill the processes yourself on the server. So if you run top on the command line you can see all processes that are running. Then find the process you want to kill and find the id of that process in the table you get from top. It's called the PID. If you have the correct PID you can then run this

kill -9 1234

Source: https://www.booleanworld.com/kill-process-linux/

18 Apr
2 days ago

bobbybouwmann left a reply on How To Include Screenshot In Your Question

Here you go: https://github.github.com/gfm/#images

You need to point to an url and use the correct syntax ![image altt](https://example.com/image/url)

17 Apr
3 days ago

bobbybouwmann left a reply on Unit Testing The Logic Behind An Artisan Command

In general testing the command can be done like so: https://laravel.com/docs/5.8/console-tests

However that doesn't really test what's behind that on unit level. The above approach is more on functional level. If you want to do this on unit level you would use a service class that would perform the action you want. This way you can unit test your service class ;)

Let me know if that makes sense to you!

bobbybouwmann left a reply on Speeding Up Mail Queue

Well that is what a queue does. It works of jobs whenever it has nothing to do. In this case it's sending 1 mail at a time, so technically you have 1500 jobs that needs to be processed. To make this faster you can for example add 1 job to the queue that will loop over all the accounts and send the emails in that loop. This way you only have to process one job. This job might take a bit longer, but that is fine.

You might hit certain limits if you run all 1500 at a time. You can for example also create a job for every 200 emails as an example.

bobbybouwmann left a reply on Guzzle Http Not Logging In Laravel With Monolog

MMh, I think you need to use an existing log channel to make this work

$handlerStack = HandlerStack::create();

$logChannel = $app->get('log')->channel('my-custom-channel');

$handlerStack->push(
    Middleware::log(
        $logChannel,
        new MessageFormatter('{req_body} - {res_body}')
    )
);

Let me know if that works for you!

bobbybouwmann left a reply on Data Isn't Showing On Page

How do you include the component? Did you compile your javascript?

bobbybouwmann left a reply on How To Store Download File Path In Variable ?

Dude, stop asking the same question...

bobbybouwmann left a reply on HasManyThrough 3 Table .

You can chain relationships

$users = User::with('campus.university');

But I'm not really sure what you want to achieve here!

This might be useful to read: https://laravel.com/docs/5.8/eloquent-relationships#querying-relations

bobbybouwmann left a reply on Extending ConsoleMakeCommand

@vkronlein For any help you need in a professional way you can contact me here: https://www.codementor.io/bobbybouwmann

bobbybouwmann left a reply on How To Store Excel Download File Path

Instead of download you should use one of the other export methods. You can find all the details here: https://docs.laravel-excel.com/3.1/exports/store.html

16 Apr
4 days ago

bobbybouwmann left a reply on Date Serialization

@neeonline Mmh, if you add any casts in your model it will override the global setup so that is a good thing to check!

bobbybouwmann left a reply on Date Serialization

Mmh, SQLite shouldn't make a difference as far as I know. Are you on the latest Laravel version?

bobbybouwmann left a reply on Modify Email "from" In Laravel 5.1

@jonjie Yeah, like @dipakrataniagile said if you use smtp with gmail you can't set the from email. You need to use a third party email provider like sendgrid, mailgun, etc!

15 Apr
5 days ago

bobbybouwmann left a reply on How To Move Laravel User Model Inside App\Models Namespace?

The namespace in the config/auth.php file should be App\Models\User::class,, however you also need to update the namespace of the class itself

// app/Models/User.php

<?php

namespace App\Models;

class User extends Model
{
    // The rest of the class
}

In every other place where App\User is used, you need to replace it with App\Model\User. You can for example do a search and replace on your codebase or use an IDE like PHPStorm to refactor this.

bobbybouwmann left a reply on Date Serialization

This only works if you use the correct Carbon namespace

use Illuminate\Support\Carbon;

Also note that this only happens for content that is being parsed to JSON. Not for arrays and other kind of objects.

bobbybouwmann left a reply on Laravel OrderBy

Like I said, it's an example. You should check the docs ;)

bobbybouwmann left a reply on CKEditor/ClassicEditor Not Working On IPad

@FREDEMAGI - Cool! Let me know if everything works out for you :D

bobbybouwmann left a reply on Laravel OrderBy

So in Laravel you can't sort the result set by the relationship. It's not possible because Laravel will do two queries underwater and therefor the sorting is not working.

To make this work you can use a join instead

$clips = Clip::with(['artist'])
    ->leftJoin('artists', 'artists.id', '=', 'clips.artist_id')
    ->orderBy('artists.name_' . $locale)
    ->paginate($this->perPage);

Note: I believe this is the syntax, but it should point you in the right direction

Documentation: https://laravel.com/docs/5.8/queries#joins

bobbybouwmann left a reply on Modify Email "from" In Laravel 5.1

That indeed is strange, this should work out of the box! Are you on the latest 5.1.* version of Laravel?

bobbybouwmann left a reply on CKEditor/ClassicEditor Not Working On IPad

@fredemagi Did that bring you any further?

14 Apr
6 days ago

bobbybouwmann left a reply on Storing Single Content In Database

It sounds like you want to show some contact details on a page, but you don't have to edit them everytime right? I would just put them in a config file or hard code it in the templates.

bobbybouwmann left a reply on How To OrderBy And Paginate Posts With Its Comments List

What do you want to order? The comments or the posts? Or do you want to order the posts by the comments?

bobbybouwmann left a reply on Append Attribute To Model If Exists In Pivot?

I think your looking for the updateExistingPivot method. However you have to do this check yourself if the relationship exists or not

Documentation: https://laravel.com/docs/5.8/eloquent-relationships#updating-many-to-many-relationships

bobbybouwmann left a reply on How To Export Laravel Blade To Word Document

You can't convert a blade file to word with this package. It's simply not possible, because the api of the package doesn't allow for that. You can only build up word files and then export them.

Alternatively you can build a PDF of your blade file and convert the PDF to a Word document, but that might be to much work for you.

@konrms From your initial question there is no information on what you've tried or what the problem is. I only see a blade file and a composer install...

bobbybouwmann left a reply on Accept Only Ajax Request On Api Routes In Laravel

In your api request you would send a header with the request and you would check for that in your middleware

So let's say your application is called MyApp

curl --header "X-MyApp: 123" www.example.com/api/some/route

// In your middleware
public function handle($request, \Closure $next)
{   
    if (!$request->ajax() || !$request->headers->contains('X-MyApp')) {
        return response('Forbidden.', 403);
    }

    return $next($request);
}

Note: The string can be anything. Could be the id of user or a company id for example. You can use that to check that as well. However you don't have to do anything with that header. In my example I also don't check for the value, just if the header exists.

Let me know if this makes any sense!

bobbybouwmann left a reply on How To Export Laravel Blade To Word Document

What have you tried so far? You only installed a package, but that is just like starting up your computer and then asking us what you need to type to get paid. Have you read the information of the package? Have googled for any tutorials?

Anyway, try this tutorial: https://itsolutionstuff.com/post/laravel-5-create-word-document-file-using-phpoffice-phpword-packageexample.html

bobbybouwmann left a reply on Two User Tables Or One

I don't think there is a default validation rule for that. However you can use the unique rule for that

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

In your case probably something like this

'email' => [
    'required',
    'email',
        Rule::unique('users')->where(function ($query) {
        return $query->where('type', 'admin');
    }),
],

Let me know if that works for you :D

bobbybouwmann left a reply on How To Update/sync Table Data For Each Row From Input Field Array ?

Yeah, it's very strange! How do you create the table?

bobbybouwmann left a reply on Registration Redirect

Awesome :D

bobbybouwmann left a reply on Laravel Array To String Conversion On Multiple Records

On what line do you get this error? As far as I know PaymentTypeProductService::insert($date) could be the problem as well. What is logic is behind there?

bobbybouwmann left a reply on Registration Redirect

Sure, just put that route in there and it should work ;)

Just override this part with your redirect functionality

return $this->registered($request, $user)
    ?: redirect($this->redirectPath());

bobbybouwmann left a reply on Accept Only Ajax Request On Api Routes In Laravel

If you really want it save you can use your own header and require that. So your frontend always needs to send a specific header which is accepted by the middleware.

By default this is just fine, normally you also have authentication on the api right? :D

bobbybouwmann left a reply on Registration Redirect

Basically override this method in your controller and remove the $this->guard()->login($user); line: https://github.com/laravel/framework/blob/e6c8aa0e39d8f91068ad1c299546536e9f25ef63/src/Illuminate/Foundation/Auth/RegistersUsers.php#L23

bobbybouwmann left a reply on Registration Redirect

Yeah, it's always logging in the user. That's part of the default flow. So you have to override the methods in the RegistersUsers that handle this right now!

bobbybouwmann left a reply on Registration Redirect

The RegistersUsers trait is used here. If you open that file you can see how the redirect is working and how the users are logged in.

You can override all the methods in the trait in your controller to perform your own action here!

For redirecting the user to a certain page you can simply set the following property

/**
 * Where to redirect users after registration.
 *
 * @var string
 */
protected $redirectTo = '/admin'; // Whatever you want here

bobbybouwmann left a reply on Count (involving Pivot Table)

Well

$admin = User::withCount('booths')
    ->where('role_id','=','2')->get();

bobbybouwmann left a reply on Error While Creating Database Function In Migration File

@muazzamazaz I don't see anything weird in the syntax, but I don't have your database to test with!

bobbybouwmann left a reply on Laravel Pagination As Load More Button

"It didn't work"? I really can't do anything with that. Do you submit a name field?

I have zero experience with this package, but the examples from the docs are easy to copy and paste. You should be able to get it working from the examples.

bobbybouwmann left a reply on How To Update/sync Table Data For Each Row From Input Field Array ?

@lonerunner That is indeed strange. Shouldn't behave like that... Are you sure you don't do anything with the data?

bobbybouwmann left a reply on Error While Creating Database Function In Migration File

I believe you need to use DB::unprepared('MY QUERY HERE'); to make this work in a migration.

Anyway, it seems there is an error in your mysql. Does this work if you run it directly on the database?

bobbybouwmann left a reply on Extend Date To 3 More Hours Where Post = Today's Post

It's better to do a whereBetween here on the date column. So something like this

$now = Carbon::now();
$start = Carbon::now()->startOfDay();
$end = Carbon::now()->endOfDay();

// We need this to make sure you see the results from the day before until 3AM
// After 3AM it will show the rest of the day.
if ($now->hour < 3) {
    $start->subDay();
    $end->subDay();
}

$reservations = Reservation::whereBetween('reservation_made_on', [$start, $end])->get();

Note that you can also update $start and $end to be a specific date range. Now it's always from 00:00 to 24:00 but I can image you might want it to be 03:00 till 03:00 the next day

$start = Carbon::now()->startOfDay()->addHours(3);
$end = Carbon::now()->endOfDay()->addHours(3);

Let me know if this works for you!

bobbybouwmann left a reply on How To Update/sync Table Data For Each Row From Input Field Array ?

It's allowed to post empty values, they are not being stripped by default. So you can do that check yourself :D

foreach($request->messages as $message) {
    // $message is still an item in the array, just null. So build a check for it
    if ($message === null) {
        continue;
    }

    // Create your message here
}

bobbybouwmann left a reply on Accept Only Ajax Request On Api Routes In Laravel

You can build a middleware for that. In that middleware you can ask if the request is coming from an ajax request.

 public function handle($request, \Closure $next)
{
    if (! $request->ajax()) {
        return response('Forbidden.', 403);
    }

return $next($request);
}

https://github.com/laravel/framework/blob/694d5663fb4a28dfd1a5ad89012f1f64948dee7f/src/Illuminate/Http/Request.php#L228