corbosman

corbosman

Member Since 4 Years Ago

Amsterdam

Technology Evangelist at XS4ALL

Experience Points 69,560
Experience Level 14

440 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 703
Lessons
Completed
Best Reply Awards 8
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.

14 Jul
6 days ago

corbosman left a reply on Multiple Server Workers For A Queue

Probably your only option is to deploy multiple installations of your app to multiple servers and run queue workers on them. It seems like the easiest solution anyways. For docker I do something similar, except it's not multiple worker servers but containers running different parts of laravel (one for queue, one for horizon, etc). It would be trivial to tell docker to simply scale up the queue worker containers.

13 Jul
1 week ago

corbosman left a reply on Laravel Passport Create Token And Refresh Token

How do you make the token for your user/password method? Can't you do it the exact same way?

17 Jun
1 month ago

corbosman left a reply on How Would You Handle Delay/conditionnal Notifications ?

Can't you just create the notification the moment the article is actually published? You could even make that automatic with an event listener.

14 Jun
1 month ago

corbosman left a reply on Model Inheritance

Without knowing why you'd want to do it that way, let me give an alternative. Just have a 'public_transport" table, and then a second table 'types', where each type of public transport has an entry. So $transport->type->name would be 'bus' or however you'd want to do it.

corbosman left a reply on Multiple People Working On The Same Form, How To Prevent Conflicts?

How you implement this in vue is all up to you. What websockets does is allow you to communicate from a backend (laravel) to a frontend (vue) in realtime. So if a user modifies a form, laravel will broadcast an event to all other vue clients. Those vue clients will receive the event, and can do whatever you want to do with it. That's all up to you.

corbosman left a reply on How Do You Structure (Folders) Your Project?

I use the same structure as laravel provides out of the box. I make 2 changes.

  1. I dont put models into the app/ folder. In larger apps I think this is very confusing. So generally I make a subfolder under app for models. I happen to call them "Repositories", but you can name it whatever.

  2. I have a Lib folder for functionality that I create in the app but isnt really a core part of the app. In an ideal world id move those to its own composer packages but I dont always get around to it.

corbosman left a reply on Multiple People Working On The Same Form, How To Prevent Conflicts?

The best way would be to use websockets, which in laravel could be Laravel Echo. You would need a websockets service though. In the past I've used pusher.com, but now I use this repo: https://github.com/beyondcode/laravel-websockets

It's a bit of a learning curve to get things working, but if you want the kind of functionality you're after this is the best approach.

10 Jun
1 month ago

corbosman left a reply on How To Work Cron Job

Unless your hosting provider provides some kind of UI for it, you don't. If you want to use cron, you need to be able to add those cron jobs to the system.

corbosman left a reply on How Passport Generate Tokens?

This is done deep in passport and phpleague/oauth2-server. It is not easy to get to. The JWT token is made in oauth2-server here: https://github.com/thephpleague/oauth2-server/blob/master/src/Entities/Traits/AccessTokenTrait.php

Im not sure what you mean with sign a request, but you could absolutely make your own token and pass that around. You could add claims to the token as well. I use this factory class.

<?php

namespace App\Auth;

use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Key;
use Laravel\Passport\Passport;
use Lcobucci\JWT\Signer\Rsa\Sha256;

class ApiToken
{
    public function make($user)
    {
        return (new Builder())
            ->setId(bin2hex(random_bytes(40)), true)
            ->setIssuedAt(time())
            ->setNotBefore(time())
            ->setExpiration(now()->addDay()->format('X'))
            ->setSubject($user->username)
            ->set('client', $user->token()->client->name)
            ->sign(new Sha256(), new Key('file://'.Passport::keyPath('oauth-private.key'), app('encrypter')->getKey()))
            ->getToken()
            ->getPayload();
    }
}

corbosman left a reply on Picking Up Implicit Model In Middleware

Assuming your route has {thread}, it will be available as

$request->thread

corbosman left a reply on How To Use Save() Method In Observer?

Try using something like:

$model->unsetEventDispatcher();
22 May
1 month ago

corbosman left a reply on Subscribe To Private Channels Pusher

First of all, why not use laravel Echo? It can talk to pusher. https://laravel.com/docs/5.8/broadcasting#installing-laravel-echo.

The csrf token you can pass to JS like so. In the section of your html put this:

<meta name="csrf-token" content="{{ csrf_token() }}">

Then in javascript you can do this.

let token = document.head.querySelector('meta[name="csrf-token"]')

corbosman left a reply on What Will Be The Future Of Php And Also Laravel In Front Of Node And Other Backend Technologies.

Predicting the future is notoriously uncertain. I wouldn't think about it too much. Things will happen as they happen, just be prepared to go with the flow. When vue first appeared we started using it for small parts of our projects, now we have some apps that are fully run in vue with a laravel api backend. Who knows what tomorrow will bring.

19 Apr
3 months ago

corbosman left a reply on Issue With Laravel-mix And Bootstrap

You dont .version() your css, could you perhaps have an old cache css file in your browser cache?

18 Apr
3 months ago

corbosman left a reply on Using Carbon2

Just found the magic incantation I guess..

DateFactory::use(CarbonImmutable::class);

corbosman left a reply on Using Carbon2

On twitter Taylor just said this made it into 5.8, but i guess it's really well hidden.

corbosman started a new conversation Using Carbon2

A few months ago Taylor announced that 5.8 would allow you to use Carbon2 for datetime fields. I cant really find much about it in the docs. Anyone know if this actually made it into 5.8, and if so, how do you use Carbon2?

Im especially interested in it because of the localization changes.

05 Aug
11 months ago

corbosman left a reply on Scale Queue Workers In Response To Workload

Have you tried Laravel Horizon? It has an auto scaling feature.

corbosman left a reply on What Relationship For This Particular Case?

In your Pairs model you can use belongsTo

    public function mother()
    {
        return $this->belongsTo(Peoples::class, 'mother_id');
    }

    public function father()
    {
        return $this->belongsTo(Peoples::class, 'father_id');
    }

The reverse i think is not possible using laravel relations because you basically want to match on 2 ids. You could just use a normal function like:

    public function pairs()
    {
        return Pair::all();
    }

corbosman left a reply on Homestead Upgrade Workflows

Same here, i ended up never upgrading because of this. I eventually switched to Valet which works pretty decently on OSX. Only downside is that all your projects are now locked on 1 php version.

If id start over now id probably use docker.

14 Mar
1 year ago

corbosman left a reply on Certificate Problems With Valet

I resolved it by extending guzzle and allowing me to set the secure flag to false for development. But i didnt notice the fixes so I may try that instead.

05 Jan
1 year ago

corbosman left a reply on Model Observers Not Working When Using Model Factories?

Doh, i made a silly mistake. I created the wrong model. (they differ with 1 letter. I stared at this for like 10 minutes and never noticed). It's working. Thanks, your response made me look again :)

corbosman started a new conversation Model Observers Not Working When Using Model Factories?

Hi all, i have a model observer that populates a table column with a value on created(). This works fine in normal use, but when I run tests using a model factory the observed events dont seem to be fired. Is this intentional?

28 Nov
1 year ago

corbosman left a reply on Certificate Problems With Valet

Was your issue that curl on a valet site trying to connect to ssl api on another valet site doesnt work?

corbosman left a reply on Certificate Problems With Valet

No, i opened an issue on github for it but I guess not many people use valet on High Sierra...

https://github.com/laravel/valet/issues/460

20 Oct
1 year ago

corbosman started a new conversation Certificate Problems With Valet

I recently upgraded to OSX High Sierra, and also updated all my brew recipes. Ever since I get certificate errors in my Laravel Passport guzzle/curl:

"cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html"

I have no idea which action caused this problem unfortunately. I tried supplying php with an updated cacert.pem but that didnt seem to help. Anyone have an idea? This is currently preventing me from doing any development.

08 May
3 years ago

corbosman started a new conversation Mock/prevent Redirect To Remote Api

Hi all, im trying to test an oauth based login, without actually going to the remote oauth server endpoint. In my login screen I have a button that links to an OAuthController@login method

    public function login()
    {
        $url = $this->provider->getAuthorizationUrl();
        return redirect()->to($url);
    }

In my test, I dont want to actually redirect to this remote url. Is there a way to mock this? All I want to know is IF there was a redirect to a specific url. Right now im (obviously) getting a http request error as the authorization url is fake.

I did try using the facade instead (although id prefer to avoid it), but that gives me an error as well.

1) LoginTest::check_if_oauth_is_being_called_when_logging_in
Failed asserting that Illuminate\Http\Response Object (...) is an instance of class "Illuminate\Http\RedirectResponse".
1) LoginTest::check_if_oauth_is_being_called_when_logging_in
A request to [http://localhost/oauth/authorize?state=3YEGPInsMQQLfClun2smGJbdOVPrD%2Bm8&response_type=code&approval_prompt=auto&client_id=xfiles&redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fauth] failed. Received status code [404].
28 Jan
3 years ago

corbosman left a reply on Error On Composer Update

Does it work if you remove the compiled.php from bootstrap/cache? Ive had composer update problems before and they're usually fixed by manually removing the compiled.php.

corbosman left a reply on I Simply Need To Retrieve An Item From A Collection.

Did you try dd($collection) and dd($search_input) to make sure they're correct? Do you manually see $search_input in the collection?

27 Jan
3 years ago

corbosman left a reply on Site Homestead Not Working

@bashy dont know since when, but the facts speak for themselves.

$ dig ns dev.

; <<>> DiG 9.9.5-8~xs4all01-Debian <<>> ns dev.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9168
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;dev.               IN  NS

;; ANSWER SECTION:
dev.            57837   IN  NS  ns-tld4.charlestonroadregistry.com.
dev.            57837   IN  NS  ns-tld3.charlestonroadregistry.com.
dev.            57837   IN  NS  ns-tld1.charlestonroadregistry.com.
dev.            57837   IN  NS  ns-tld5.charlestonroadregistry.com.
dev.            57837   IN  NS  ns-tld2.charlestonroadregistry.com.

;; Query time: 0 msec
;; SERVER: 194.109.6.66#53(194.109.6.66)
;; WHEN: Wed Jan 27 15:03:47 CET 2016
;; MSG SIZE  rcvd: 157

And asking for a random .dev host.

$ dig @ns-tld4.charlestonroadregistry.com. a foobar.dev.

; <<>> DiG 9.9.5-8~xs4all01-Debian <<>> @ns-tld4.charlestonroadregistry.com. a foobar.dev.
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58762
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;foobar.dev.            IN  A

;; ANSWER SECTION:
foobar.dev.     3600    IN  A   127.0.53.53

;; Query time: 34 msec
;; SERVER: 2001:4860:4802:38::69#53(2001:4860:4802:38::69)
;; WHEN: Wed Jan 27 15:04:05 CET 2016
;; MSG SIZE  rcvd: 55
26 Jan
3 years ago

corbosman left a reply on Site Homestead Not Working

If you've been using .dev, make sure it's still in your /etc/hosts. .dev domains actually resolve to an ip number now, which will cause a connection refused because there wont be a homestead there.

corbosman left a reply on Correct Place To Place Global Logic

One way could be to create your own base controller, and extend that base controller from all your controllers. In the base controller you can then place anything you want in the constructor. This is not an uncommon setup.

corbosman left a reply on Using Vendor Class In Test

Dont do that. You need to run the parent setUp method, and what you're currently doing prevents that from happening. Just do this:

/**

  • @before */ public function setUpLimeLight() { $limelight = new Limelight(); }

corbosman left a reply on Using Vendor Class In Test

Actually, it's probably because you're naming your method setUp. Call parent::setUp() in your setUp method, or better, dont call it setUp(). Instead, use an annotation to make sure it gets run before your test.

/**
 * @before
 */

corbosman left a reply on Using Vendor Class In Test

The snippet as you posted it should not cause an error. Is there anything else to this test class? It looks like maybe the TestCase class you're extending has a problem. Does your app generally work except for this test?

corbosman left a reply on Get Off Mamp - Upgrade The Ubuntu Box

Why dont you use homestead? It's an ubuntu box as well, and it's being kept up to date by Taylor so you'll always have the latest software by doing a vagrant box update.

If you dont want homestead, you can get the current version of your box doing: vagrant box list

If you go to the vagrant folder of your VM, you can also do vagrant box outdated to see if there is a newer version. You can use vagrant box update to get a newer version.

corbosman left a reply on Code Mangement

Maybe this could be of use: https://education.github.com/

25 Jan
3 years ago

corbosman left a reply on Gulp Compile Is This Normal Speed Or Unusually Slow?

I run the gulp process from my desktop, not inside homestead. Just install gulp on your desktop and do the compiles there. It's much faster. I think Jeff does that as well.

corbosman left a reply on User Initiated Email And/or Password Change

Hi, there is nothing build into laravel 5 to handle this, but it's not very difficult to make. You can for instance make a settings page where people can change their email and/or password.

For email you can make it as easy or hard as you want. Common practice is to send the user an email and only accept the new email once you've got a response through a link in the email. But if you dont want or need to go that far, just accept a validated email address.

For password changes make sure you ask for their current password during the change, to avoid someone changing it from a screen thats been left open.

corbosman left a reply on Gulp Compile Is This Normal Speed Or Unusually Slow?

The default gulp file compiling bootstrap-sass takes 300ms for me on my very fast macbook pro. On homestead it takes significantly longer because the homestead sync filesystem is very slow. Which gulp version are you using? im on 3.9.

corbosman started a new conversation Vendor Bundle With Browserify

Hi all, has anyone gotten elixer to build both a vendor and an app bundle using browserify with one gulpfile? If so, could you show your gulpfile and maybe package.json?

I have gotten as far as loading external scripts and telling browserify they're external using browserify-shim, but id like to build both bundles from gulp.

16 Jun
4 years ago

corbosman left a reply on How To Make This Testable

Actually, more like this then.

    public function can($permission)
    {
        $ability = app()->make('Portal\Lib\Ability\AbilityContract');   // bound in service provider
        return $ability->can($this->username, $permission);
    }

corbosman left a reply on How To Make This Testable

So you're saying the can() method should just say something like:

public function can($permisson)
{
    return (new Ability)->can($this->username, $permission);
}

And only functional test that?

corbosman started a new conversation How To Make This Testable

Hi all, im building a roles/permission type system for an existing application. I would like to be able to say $user->can('some-permission').

The can() method should use a contract to perform the actual check, mostly because I expect the implementation to change. So I have an additional class and contract to perform the permission check. Lets call that class Ability.php.

Since I cant typehint/inject this Ability class in the User model, and doing a new() isnt that great for testability, how can I make the can(() method properly testable?