D9705996

D9705996

MaaS Technical Lead at Sabio Ltd

Glasgow

Member Since 3 Years Ago

Experience Points 212,610
Experience
Level
Lessons Completed 1199
Lessons
Completed
Best Reply Awards 142
Best Answer
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.

12 Nov
2 days ago

D9705996 left a reply on Laravel Where('user_id') Seems Completely Ignored

Look at the bindings. This will show you what is replacing the question marks

11 Nov
3 days ago

D9705996 left a reply on Package Or Macro To Always Return Arrays From Eloquent

You could try overriding the newCollection method on your model.

https://laravel.com/docs/5.7/eloquent-collections#custom-collections

Not sure if it will work returning an array but worth trying.

    public function newCollection(array $models = [])
    {
        return $models;
    }

Only other thing I can think of would be to chunk the results to reduce memory and push each model to an Array

$modelArray = [];

Model::chunk(200, function ($models) use ($modelArray) {
    foreach ($models as $model) {
        array_push($modelArray,$model);
   }
});

10 Nov
4 days ago

D9705996 left a reply on Google Gmail SMTP

What is the error message?

D9705996 left a reply on Nova Currency Field Question

@chriss39 - can you share your solution

D9705996 left a reply on Broadcast Just Added Model Data

You have an array of data so need to look round it in your vue

D9705996 left a reply on A Facade Root Has Not Been Set

@biniyam20 - awesome. Glad you got your issues sorted. Reach out if you need z hand!

D9705996 left a reply on Copy Html Code Of A Component

The lesson your looking for is

https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/99

You will still Have The challenge of interpolating your tokens

D9705996 left a reply on All Problems With The New Laracasts Design

@cronix - I raised modal issues in this thread

https://laracasts.com/discuss/channels/site-improvements/new-layout-polite-suggestions

I dropped Jeff a support request so hopefully gets some attention as it's a major ux isdue

D9705996 left a reply on Get Preview Of Guzzle Post For Debug Pourposes

In your test you could do

use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;

$container = [];
$history = Middleware::history($container);

$stack = HandlerStack::create();
$stack->push($history);

$client = new Client(['handler' => $stack]);

$client->post($this->getTokenUrl(), [
        'headers' => ['Accept' => 'application/json'],
        'form_params' => [
            'grant_type' => 'authorization_code',
            'client_secret' => $this->clientSecret,
            'client_id' => $this->clientId,
            'redirect_uri' => $this->redirectUrl,
            'code' => $code
        ]
    ]);

  dd($container):

Not tried it myself so YMMV

D9705996 left a reply on Roles, Permissions And Scopes: Laravel Passport

Awesome. Glad you got your issue sorted. Can you please mark the discussion as resolved

D9705996 left a reply on Console.log(partners) On Presence Channel Not Working

You are calling this.getPartners(); in your vue but your function is in you php. This won't work and suspect will be causing errors if you look in your dev tools

I would watch this series as it covers the basics

https://laracasts.com/series/get-real-with-laravel-echo

D9705996 left a reply on Session Not Flashing Data Immediately.

What shared hosting are you using?

D9705996 left a reply on Token Based Authentication In Laravel With Out Laravel Passport

@takdw- can you mark the discussion as solved if your problem has been resolved

D9705996 left a reply on Roles, Permissions And Scopes: Laravel Passport

Ah wait you have an array for scopes. Change it to

->middleware('scopes:do-anything');

D9705996 left a reply on Roles, Permissions And Scopes: Laravel Passport

What you have should work without your custom middleware. Do you see anything useful In storage/logs/laravel.log

D9705996 left a reply on Error Install Laravel 5.7.13

It seems like a permission issue, probably with your storage directory, try

chown www-data:www-data storage -R

Replace www-data with the username/group

D9705996 left a reply on Broadcast Just Added Model Data

You can load your relations in the constructor

public function __construct(Card $card) {
    $this->card = $card->load('club');
}

D9705996 left a reply on Catch Console Error On Running Task In Laravel/envoy And Stop Execution

It looks like you can use @error

@error
   echo $task;
   exit; /*Or Do any other processing*/
@enderror

https://stackoverflow.com/questions/33657987/laravel-envoy-abort-on-error

D9705996 left a reply on Show Data In View Depending On Existence Of Other Data

In essence you want to add a condition to your view

@unless (user dxists)
    Create link code
@endunless

However what I would do is look at your controller and only show the form if the user can be created and abort if you cant e.g.

abort_if(User::find($user_id), 422);

D9705996 left a reply on Roles, Permissions And Scopes: Laravel Passport

Why have you written your own middleware to add a scope? Can you not just add the correct scope on the request and use the default scopes middleware?

https://laravel.com/docs/5.7/passport#checking-scopes

You would still have yiur authorization layer in your application to ensure an non admin can't do admin tasks

D9705996 left a reply on A Facade Root Has Not Been Set

/$app->withFacades()';

Is for lumen and not laravel so probably not applicable. I would go back to using the RefreshDatabase trait and not worry about the auto increment. You can do this by not hardcoding your ids in the tests

->get('/mylistings/' . $listing->id)

D9705996 left a reply on Laravel CORS Error After Update Laravel For 5.7.13

What error are you getting?

09 Nov
5 days ago

D9705996 left a reply on My Approved Not Working

sorry should have been ->save not -save e.g.

>>> $u = User::first();
=> App\User {#2923
     id: 1,
     name: "dwalker",
     email: "[email protected]",
     email_verified_at: null,
     created_at: "2018-11-09 22:18:13",
     updated_at: "2018-11-09 22:18:13",
   }
>>> $u->name = "dwalker1";
=> "dwalker1"
>>> $u->save();
=> true
>>> $u = User::first();
=> App\User {#2919
     id: 1,
     name: "dwalker1",
     email: "[email protected]",
     email_verified_at: null,
     created_at: "2018-11-09 22:18:13",
     updated_at: "2018-11-09 22:19:08",
   }

D9705996 left a reply on Choosing Best Reply Leeds To A 404 Page

Your title doesnt help us fix your issue. Can you share your routes, controllers, views,etc

D9705996 left a reply on How Do I Test Login Throttling?

@sergiu17 - statuscode wont help as you would need to simulate the throttle scenario. Again you can do this but assuming your throttling isnt that strict you would need to hit your route enough times to trigger the 429 response.

To be honest I think this is something that should be in the framework for testing. I feel my first PR coming on"

D9705996 left a reply on How To Insert An Extra Boolean In A Many To Many Relation Talbe

@regentix - if I have answered your question can you please mark the discussion as solved.

D9705996 left a reply on UpdateExistingPivot Not Working

You problem I think is coming from the where clause on your relationship

->where('disqualified', 1);

As it only returns items where they have already been disqualified, therefore if they havent been disqualified then you will get null back.

D9705996 left a reply on How Do I Test Login Throttling?

@sergiu17 - IMHO You dont need to test the actual middleware implementation. This is covered by the laravel framework tests. You just need to make sre you have applied the correct middleware to the route as per my example.

There's obliviously no harm in testing like you have nut if the laravel middleware changes e.g the header name changes your test will fail but the actual throttling will still work.

D9705996 left a reply on Observer Column Update IsDirty Or WasChanged

From teh API docs

isDirty

Determine if the model or given attribute(s) have been modified.

    public function isDirty($attributes = null)
    {
        return $this->hasChanges(
            $this->getDirty(), is_array($attributes) ? $attributes : func_get_args()
        );
    }

wasChanged

Determine if the model or given attribute(s) have been modified.

    public function wasChanged($attributes = null)
    {
        return $this->hasChanges(
            $this->getChanges(), is_array($attributes) ? $attributes : func_get_args()
        );
    }

looking at the comments for the above

getChanges - Get the attributes that were changed. getDirty - Get the attributes that have been changed since last sync.

So the difference is related to whether the attributes have been synced or not

D9705996 left a reply on My Approved Not Working

can you manually update the inspector_user_id for a model in tinker? e.g.

php artisan tinker
$r =App\Requisition::find(1);
$r->inspector_user_id = 4;
$r-save();

Does this update you database or give you any errors?

D9705996 left a reply on Homestead IP

192.168.10.1 is your local IP address of your PC/laptop. The 192.168.10.10 is the IP address of the homestead VM.

D9705996 left a reply on My Approved Not Working

Can you share requisition model?

D9705996 left a reply on Broadcast Just Added Model Data

Yes of course it is. You just need to fire a different event e.g. CardUpdatedEvent and listen for it on your client side. You then just need to change you front-end to find the required table row and reset the HTML

Therefore I would add an id to your tag based on the card id

$("#my_table").append("<tr id=card-" + message.card.id + ">..."

then in your new event

$("#my_table").find("#card-" + message.car.id).html("<td>" + message.card.name + ...

I would urge you to have a look at VueJS as it allows you to build up you views based on the data involved rather than manipulating the DOM like your doing with jQuery.

https://vuejs.org/v2/guide/list.html

D9705996 left a reply on How Do I Test Login Throttling?

I would not get into specifics of testing the implementation of the throttle middleware. I would simply test you have throttling applied to a route

$this->assertContains('throttle:5,10', Route::getRoutes()->getByName('home')->gatherMiddleware());

You just need to make sure you test the full name of your middleware and that you name your routes (there might be a way to do this without named routes but I couldn't get it to work). My routes are

Route::get('/', function () {
    return view('welcome');
})->middleware('throttle:5,10')->name('home');

D9705996 left a reply on Customise Output Of Queue:work Command?

@miwal - no problem - happy to help, your regex shouldn't be a performance issue so don't worry. Would appreciate if you can mark the discussion as solved to help others find teh answer if they have the same problem.

D9705996 left a reply on How Do I Test Login Throttling?

Also you wouldn't get to the store method if the throttle middleware has prevented the login so this would never be called.

if ($this->hasTooManyLoginAttempts($request)) {

D9705996 left a reply on How Do I Test Login Throttling?

To be honest I wouldn't be over concerning with testing this as its technically something you don't own. You can put faith that laravel has tested this for you.

With that being said you can look at the framework tests for an example if you want to roll your own

https://github.com/laravel/framework/blob/9f313ce9bb5ad49a06ae78d33fbdd1c92a0e21f6/tests/Integration/Http/ThrottleRequestsTest.php

D9705996 left a reply on New Layout - Polite Suggestions

I have a couple of issues/suggestions with the new redesign that may or may not have been mentioned elsewhere.

  1. When you Post you get Reply to CONVERSATION not Reply to (the actual conversation name)

  2. The lesson search doesn't have an option for "unwatched"

  3. On mobile when adding a post through the modal the modal and virtual keyboard take up the entire screen (I'm using a 10 inch tablet on portrait and landscape) so it is impossible to see the original post.

  4. The modal window is not scrollable so longer posts push the action button outside the viewport so you cannot actually post your reply.

  5. It would be good to allow a posting keyboard shortcut e.g. ctrl +enter

The last one should be simple @keyup.ctrl.enter="" but would be really useful (GitHub and Gitlab provide this).

The main deal breakers for me right now are 3 and 4. For mobile would it be possible to return to the inline form from the old design , with the new styling?

D9705996 left a reply on Can You "embed" A FormRequest Object Within Another FormRequest Object?

@stevemelrose - I'm interested to find out i you solve this as I asked a similar question

https://laracasts.com/discuss/channels/laravel/multiple-form-requests-per-request

There are few options given but I really haven't had a chance to try them out but might give you a pointer.

D9705996 left a reply on It Could Be More Simple To Change The Nova Logo Image

@ccampello - sorry Ive not actually used nova yet so Im not 100% sure, was just going on Marcel's excellent series.

To be honest I would just suck it and see. Create an SVG and if it looks odd chnage the size. It will likely be 32x32, 64x64, etc

D9705996 left a reply on Login Event

you should just be able to fire the event in

if ($this->hasValidCredentials($user, $credentials)) {
  $this->login($user, $remember);
  $this->events->fire(new Events\Authenticated($user)); 
  return true;
}

D9705996 left a reply on Customise Output Of Queue:work Command?

You could use ^ to only match the start of the string in you regex

sed 's/^\[.*\] /''/'

D9705996 left a reply on My Approved Not Working

can you try chnaging

$approved->inspector_user_id = $request->input('inspector_user_id');

to

$approved->inspector_user_id = $request->inspector_user_id;

It shouldnt matter but just in case. Im struggling to see much wrong with your code. You might need to try replicating in php artisan tinker if this doesnt work

D9705996 left a reply on Login Event

And just to be sure - if you take away your customised guard do the evens work?