phpMick

phpMick

Member Since 3 Years Ago

Experience Points 53,480
Experience
Level
Lessons Completed 137
Lessons
Completed
Best Reply Awards 33
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.

17 Aug
2 months ago

phpMick left a reply on Is There Any Drag-and-drop Studio/builder For Laravel?

Sound to me like you are not a coder, +1 for Wordpress.

phpMick left a reply on Best Datatable Plugin For Laravel ?

Yes, this is brilliant, I use it in every project:

https://datatables.net/

16 Aug
2 months ago

phpMick left a reply on Code Cached In EventSubscriber?

Stopped and started the queue worker, looks like that does it.

phpMick started a new conversation Code Cached In EventSubscriber?

Hi,

Can anyone see how the code would be cached in an Event Subscriber?

I am adding Logging and it is not appearing. Did a reboot (laptop and Homestead) and it started working.

I did also try a cache:clear and dump-autoload but it didn't work.

Am I going mad(der)?

Mick

09 Aug
3 months ago

phpMick started a new conversation Event Subscribers

Hi,

I am currently trying to use an Event Subscriber instead of separate Listeners.

Can I use ShouldQueue in there?

Cheers,

Mick

08 Aug
3 months ago

phpMick left a reply on How To Use Dependency Injection In A Class With Static Functions?

Then pass the service to the function?

phpMick left a reply on How To Use Dependency Injection In A Class With Static Functions?

Yeah, the class is never instantiated, so the constructor will never fire and $this->service will never be set.

What are you trying to achieve?

phpMick left a reply on How To Use Dependency Injection In A Class With Static Functions?

Surely $this does not exist, because you haven't created an instance?

07 Aug
3 months ago

phpMick left a reply on Pluck From A Collection Of StdClass

Actually, this is better:

‌‌$results->implode('id',',');

phpMick left a reply on Pluck From A Collection Of StdClass

Muppet:

$results->pluck('id')

phpMick started a new conversation Pluck From A Collection Of StdClass

I am trying to do this without iteration:

I have a collection of standard classes:

$results = {Illuminate\Support\Collection} [3]
 items = {array} [2]
  0 = {stdClass} [2]
    id = 1
    name = "home"
  1 = {stdClass} [2]
    id = 2
    name = "other"

I just want a comma separate string, containing all the ids of the stdClasses?

Thanks,

Mick

phpMick left a reply on Developing Without A Local VM.

No, I am using a company laptop.

It would be easy if it was mine and I may end up buying my own laptop but I'm trying to avoid that.

phpMick left a reply on Developing Without A Local VM.

Thanks @martinbean

This is what they have suggested, but I'm remote and don't want to be constantly connected to a VPN.

I love having a local development environment and that I don't need to be on a network.

phpMick started a new conversation Developing Without A Local VM.

Hi,

I am currently developing using Homestead but is looking like I will have to move away from this because I can no longer have local VMs (company policy).

What is the best alternative? I really like the ability to develop locally, without being on a network.

Cheers,

Mick

phpMick left a reply on Private Method Injection In A Trait

And, is there actually any benefit of doing this over:

$optimus = new Optimus;

phpMick left a reply on Private Method Injection In A Trait

What I want to do is this (just like you would in a controller):

namespace App\Traits;

use Jenssegers\Optimus\Optimus;

trait myTrait{

public function getRouteKey()
    {
        return $this->encodeId();
    }


private function encodeId(Optimus $optimus)
    {
        $encoded = $optimus->encode($this->getKey());

        return $encoded;

    }

}

That doesn't work, so instead I am doing this:

$optimus = app()->make('Optimus');

Is there a better way to do this?

Mick

06 Aug
3 months ago

phpMick left a reply on Private Method Injection In A Trait

I don't see that you need anything else.

I just need to know if it possible to get the $thing created automatically like this.

The code that calls it is:

 public function getRouteKey()
    {
        return $this->doit();
    }

This would work OK for a controller method, it is just not working because it is in a trait.

Thing is actually Optimus:

https://github.com/jenssegers/optimus

I have created a service provide, exactly as they describe (the only difference being that their method is in a controller):

<?php

namespace App\Providers;

use Jenssegers\Optimus\Optimus;
use Illuminate\Support\ServiceProvider;

class OptimusServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(Optimus::class, function ($app) {
            return new Optimus(1580030173, 59260789, 1163945558);
        });
    }
}

Mick

phpMick started a new conversation Private Method Injection In A Trait

Can I do this in a trait? If so how?

This is what I want to do:

private function doIt(Thing $thing)

I get this error:

Too few arguments to function App\Models\User::doIt(),

Thanks,

Mick

phpMick started a new conversation How To Modify A Trait In A Composer Package.

Hi,

What is the proper way to do this?

I am using https://github.com/Propaganistas/Laravel-FakeId but I want to modify the trait in it.

Clearly I should not be modifying the package in my vendor directory, how should I be doing this?

Thanks,

Mick

27 Jul
3 months ago

phpMick left a reply on Issue With Vue - Inline-template Components Must Have Exactly One Child Element.

Exactly, you just need to wrap a div around your entire template:

<template>
    <div>

        ///existing code in here

    </div>
</template>

25 Jul
3 months ago

phpMick left a reply on Manually Populate Old() Array.

Hmm in my things create method, I create a new thing, to pass to my view. I reckon I can check the session and populate it with the remembered fields....

phpMick left a reply on Manually Populate Old() Array.

Here is a bit more detail:

1, things.create view - the user presses the + button to add a group. 2, the form is then submitted (POST) to my RedirectController this is where the form fields are placed in the session, then the user is redirected to the groups create page:

public function RedirectWithReturn(Request $request,$redirectTo){

        $previous = URL::previous();

        session(['returnURL' => $previous]);
        session(['savedForm' => $request->all()]);

        return redirect()->route($redirectTo);
    }

I now have in the session, the page which I should return to, after adding a group and the old form data.

3, the user now goes to the groups create page, where they populate a form, which has all the usual validation to store a new model.

4, when the group has been successfully created, the user is redirected back to the create thing page and their old input is used to populate the form fields.

So, I get that withInput() will redirect with the fields but it will get lost somewhere in this process. I need to store the fields manually.

Mick

phpMick left a reply on Manually Populate Old() Array.

@36864 I don't think that will work either. I don't want to redirect with the input, I want to save the input (which I am already doing in the session), then use it, when I come back to the 'things' create page.

phpMick left a reply on Manually Populate Old() Array.

Great, I was hoping for an answer which didn't involve redesigning my entire application.

phpMick started a new conversation Manually Populate Old() Array.

Hi,

1, I have a form (for adding 'things') which has a + button on it, to add a 'group'.

2, When this button is clicked, I wish to redirect to another form, so that the user can add a 'group'.

3, When the 'group' has been added, I redirect back to the 'thing' create form, so that the user can continue. I want the form to remember the fields which they have already populated.

I have got most of this working, by sticking the populated 'thing' fields in the session, now i just need to reload them, when I get back to the create 'things' page.

I was hoping to sneak them into the '''old()''' array, this way my Blade templates will work without making them more complicated.

Does this make sense and does anyone know how I can do it?

Cheers,

Mick

18 Jul
3 months ago

phpMick left a reply on How To Pass An Array As A Prop?

nope:

htmlspecialchars() expects parameter 1 to be string, array given

phpMick started a new conversation How To Pass An Array As A Prop?

Is this correct?:

<agreements-selector 
                                           :selected-agreements='{{ json_encode($groupingRule->agreement_ids)}}'>


I'm sure I have done this before and didn't have to use json_encode?

agreement_ids is cast to an array in the model.

Thanks,

Mick

12 Jul
4 months ago

phpMick left a reply on Communication Between Components.

Cheers,

I think I did option 1 last time and I think it's the best answer for my current application. It's pretty simple and I just want to pass an array from one to the other.

phpMick started a new conversation Communication Between Components.

Hi Team,

What is the best way to communicate between two components on the same level?

Cheers,

Mick

06 Jul
4 months ago

phpMick left a reply on Key Value Pair Editor.

Yes, clearly it can be done in many ways. I was wondering if anyone had done anything similar.

phpMick left a reply on Key Value Pair Editor.

I was wondering more about the user interface, I was thinking maybe create a Vue component.

phpMick started a new conversation Key Value Pair Editor.

Hi,

Has anyone done anything like this? I want the user to be able to enter key value pairs like name=test

Cheers,

Mick

28 Jun
4 months ago

phpMick left a reply on Homestead: "ETXTBSY: Text File Is Busy"

Has anyone resolved this?

I have tried with --no-bin-links and downgrading npm and am still getting the problem.

phpMick started a new conversation Laravel Mix On Docker: ETXTBSY: Text File Is Busy

I am trying to run Laravel Mix on my Docker container.

I have managed to install the latest versions of npm and node (thanks Laradock).

Now when I try and run npm install I get lots of these:

npm WARN rollback Rolling back [email protected] failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/srv/app/node_modules/express/package.json.3619593601'
npm WARN rollback Rolling back [email protected] failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/srv/app/node_modules/express/node_modules/array-fla
tten/package.json.2934324270'

node:v10.5.0

npm:v6.1.0

Windows host.

Guest is: Linux 2369f4b16e52 4.9.93-boot2docker #1 SMP Thu May 10 16:27:54 UTC 2018 x86_64 GNU/Linux

Is anyone else doing this?

Mick

26 Jun
4 months ago

phpMick left a reply on Laravel Mix On Docker Container.

I almost have this working now, but when I try: npm run dev I get:

module.js:549
    throw err;
    ^

Error: Cannot find module '../'

phpMick left a reply on Laravel Mix On Docker Container.

I think I will use a separate image for this task. I can then use one which will use an image which has node already installed.

22 Jun
4 months ago

phpMick started a new conversation Laravel Mix On Docker Container.

Hi,

Does anyone have Mix running on Docker?

I have install Node and NPM but when I try npm run dev I get:

module.js:478
    throw err;
    ^

Error: Cannot find module '../'
    at Function.Module._resolveFilename (module.js:476:15)


Thanks,

Mick

19 Jun
4 months ago

phpMick started a new conversation How To Set Items As Selected In A Multi-select?

I have a multiselect:

<select class="tagSelector" name="useGroups[]"  multiple="multiple">

                        @foreach($userGroups as $userGroup)
                            <option value="{{$userGroup->id}}}" selected>{{$userGroup->name}}</option>
                        @endforeach
                    </select>

I have a collection of items which should be selected. how do I set them?

Thanks,

Mick

12 Jun
5 months ago

phpMick started a new conversation Phpunit.xml Is Ignored After Moving To Docker.

I have just swapped from Homestead to Docker and my phpunit.xml settings are no longer working. The values from my .env are being used instead.

How can I troubleshoot this?

Thanks,

Mick

phpMick started a new conversation Hierarchical Data Structure For Multiple Parents.

Hi,

I was using a nested set (https://github.com/lazychaser/laravel-nestedset) but now we have a new requirement where the nodes may have multiple parents.

Can anyone suggest a data structure (or better still a package!) for this structure.

We are expecting a lot of node so would like to able to retrieve a node and it's descendants as efficiently as possible.

Thanks,

Mick

29 May
5 months ago

phpMick started a new conversation Running Tests On Laradock.

Hi,

Is anyone able to run tests on Laradock (using PhpStorm).

How do I install PHPUnit?

Thanks,

Mick

25 May
5 months ago

phpMick left a reply on New Deployment, Can't Login.

Yes, we weren't using HTTPS. Sorted now.

24 May
5 months ago

phpMick started a new conversation New Deployment, Can't Login.

Hi,

I swear that I have seen this before.

I have just deployed my application and migrated/seeded the db.

I can't login, I just get redirected back to login, without any errors.

Any ideas?

Mick

21 May
5 months ago

phpMick started a new conversation Laravel, Docker And Windows

Hi,

Is anyone developing on Windows using Docker?

I'm just wondering you share your code between your host and container?

Mick

14 May
6 months ago

phpMick started a new conversation Mock An Object That Is Created By A Static Function.

I am trying to unit test a function, in the middle of it is this line:

$authService = AadAuth::interactive();
static public function interactive()
    {
    //do some stuff       
        return $instance;
    }

AadAuth calls an external API, which I want to fake.

I don't see how this is possible.

Mick

phpMick started a new conversation Can't Work Out How To Mock This.

Hi,

How can I mock this?:

$tenantid = $azure_api->ResourceManagement()->getSubscriptionTenantGuid(strtolower($request->guid));

This is what I have:

//mock the MAA
        $MAA = Mockery::mock('App\Connectors\MicrosoftAzureApi');

        //this needs a ResourceManagement
        $ResourceManagement = Mockery::mock('App\Connectors\MicrosoftAzureApi\ResourceManagement');
        //add the functions

        $ResourceManagement->shouldReceive('getSubscriptionTenantGuid')->once()->with($this->subscriptionID)->andReturn($this->tenantID);

//give it to the MAA
        $MAA->ResourceManagement =  $ResourceManagement;

When I try to use it, I get:

Method Mockery_0_App_Connectors_MicrosoftAzureApi::ResourceManagement() does not exist on this mock object

I'm not really sure what is happening here:

$tenantid = $azure_api->ResourceManagement()->getSubscriptionTenantGuid(strtolower($request->guid));

I don't really get how ResourceManagement is instantiated.

Thanks,

Mick