bobbybouwmann

bobbybouwmann

Member Since 4 Years Ago

Apeldoorn, The Netherlands

Developer at Enrise

Experience Points 1,296,985
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 1580
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.

24 Apr
12 hours ago

bobbybouwmann left a reply on Carbon Date Range / Intervals

@leafman Please create a new thread

bobbybouwmann left a reply on How To Deploye Laravel Api At AWS EC2 Instance?

You need to point the web root to the public directory. RIght now you have to prefix everything with the public directory which is also exposing your .env file to the world.

Checkout this tutorial: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-laravel-tutorial.html

bobbybouwmann left a reply on BelongsTo Object From Member Of BelongsToMany Relationship?

Mmh, not really sure what you're trying to do here. It sounds to me that rates always belong to a certain combination between a location and an Amenity right? Why don't you add the rates fields as extra fields on the pivot table? That was they are always connected and you can just grab the rates from either of the objects.

bobbybouwmann left a reply on Why User::find Method Call User Constructor 3 Times?

Well first of all you call User::find which is already accessing the User class. Then Laravel will do the query on the background and create the user object from the data that is returned from the database. That is already your second time. I'm not sure about the third time. Could be an internal event that is being triggered. My best best would be the retrieved event where it passes the user object to a callback method.

In general you don't have to use the constructor of your model. Can you tell me your use case?

bobbybouwmann left a reply on Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Yajra\DataTables\DataTablesServiceProvider' Not Found

Did you import the correct table?

if you use the facade you need to add this to your file

<?php

use Yajra\DataTables\Facades\DataTables;

// or
use DataTables;

class SomeController extends Controller
{
    // Your code here
}
20 Apr
4 days ago

bobbybouwmann left a reply on Is There A Way To Make The Chain Dynamic?

@chron In this case I would just go for a switch for now. If that gets to big you can always move it to a new class and do the logic there ;)

bobbybouwmann left a reply on Post Request Successful Using Postman But Not Via GuzzleHttp

You might also need to set the `Accept' => 'application/json' header as well.

bobbybouwmann left a reply on Is There A Way To Make The Chain Dynamic?

@sergiu17 ::create on a model already returns the model itself, so you can keep chaining on the model.

@chron I'm not really sure what you want to achieve now anymore. It seems like you want it to be really dynamic which doesn't help in readability of the code!

bobbybouwmann left a reply on Running A Python File In Laravel

Well that only works whenever you have a symlink setup for python3 or if it's your executable path. I see that you use windows and I expect the python3 is not symlinked there by default.

If you can run your script by yourself on the command line in the same directory as your project, it should probably also work in your code ;)

bobbybouwmann left a reply on &#039; When Saved In The Db

If you wrap the output in htmlspecialchars it should display the correct content for you.

if you're using Laravel and the blade syntax this will be done automatically for you. For example this

{{ $data }}

Will be converted to

<?php echo e($data); ?>

This e helper function in Laravel is doing the htmlspecialchars part for you.

For more info see the code of the helper method: https://github.com/laravel/framework/blob/5.7/src/Illuminate/Support/helpers.php#L550

bobbybouwmann left a reply on Is There A Way To Make The Chain Dynamic?

Well in general in PHP if you want to keep on chaining to some element you need to return that specific object that you want to chain on.

So in your case your Account Model should have a method called admin() and return a user object. Note that it always need to return that object, otherwise you can't chain and you get the error you get now!!

19 Apr
5 days 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
6 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
1 week 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
1 week 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
1 week 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
1 week 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!