phpMick

Experience

52,930

32 Best Reply Awards

  • Member Since 2 Years Ago
  • 137 Lessons Completed
  • 2 Favorites

17th August, 2018

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

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

phpMick left a reply on Best Datatable Plugin For Laravel ? • 1 month ago

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

https://datatables.net/

16th August, 2018

phpMick left a reply on Code Cached In EventSubscriber? • 1 month ago

@crnkovic

Event subscribers, as in the docs: https://laravel.com/docs/5.6/events#event-subscribers

What code?

phpMick left a reply on Code Cached In EventSubscriber? • 1 month ago

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

phpMick started a new conversation Code Cached In EventSubscriber? • 1 month ago

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

9th August, 2018

phpMick started a new conversation Event Subscribers • 1 month ago

Hi,

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

Can I use ShouldQueue in there?

Cheers,

Mick

8th August, 2018

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

Then pass the service to the function?

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

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? • 1 month ago

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

7th August, 2018

phpMick left a reply on Pluck From A Collection Of StdClass • 1 month ago

Actually, this is better:

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

phpMick left a reply on Pluck From A Collection Of StdClass • 1 month ago

Muppet:

$results->pluck('id')

phpMick started a new conversation Pluck From A Collection Of StdClass • 1 month ago

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. • 1 month ago

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. • 1 month ago

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. • 1 month ago

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 • 1 month ago

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

$optimus = new Optimus;

phpMick left a reply on Private Method Injection In A Trait • 1 month ago

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

6th August, 2018

phpMick left a reply on Private Method Injection In A Trait • 1 month ago

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 • 1 month ago

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. • 1 month ago

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

27th July, 2018

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

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

<template>
    <div>

        ///existing code in here

    </div>
</template>

25th July, 2018

phpMick left a reply on Manually Populate Old() Array. • 1 month ago

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. • 1 month ago

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. • 1 month ago

@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. • 1 month ago

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

phpMick started a new conversation Manually Populate Old() Array. • 1 month ago

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

18th July, 2018

phpMick left a reply on How To Pass An Array As A Prop? • 2 months ago

nope:

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

phpMick started a new conversation How To Pass An Array As A Prop? • 2 months ago

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

12th July, 2018

phpMick left a reply on Communication Between Components. • 2 months ago

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. • 2 months ago

Hi Team,

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

Cheers,

Mick

6th July, 2018

phpMick left a reply on Key Value Pair Editor. • 2 months ago

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. • 2 months ago

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. • 2 months ago

Hi,

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

Cheers,

Mick

28th June, 2018

phpMick left a reply on Homestead: "ETXTBSY: Text File Is Busy" • 2 months ago

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 • 2 months ago

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

26th June, 2018

phpMick left a reply on Laravel Mix On Docker Container. • 2 months ago

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. • 2 months ago

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.

22nd June, 2018

phpMick started a new conversation Laravel Mix On Docker Container. • 2 months ago

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

19th June, 2018

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

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

12th June, 2018

phpMick started a new conversation Phpunit.xml Is Ignored After Moving To Docker. • 3 months ago

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. • 3 months ago

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

29th May, 2018

phpMick started a new conversation Running Tests On Laradock. • 3 months ago

Hi,

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

How do I install PHPUnit?

Thanks,

Mick

25th May, 2018

phpMick left a reply on New Deployment, Can't Login. • 3 months ago

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

24th May, 2018

phpMick started a new conversation New Deployment, Can't Login. • 3 months ago

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

21st May, 2018

phpMick started a new conversation Laravel, Docker And Windows • 3 months ago

Hi,

Is anyone developing on Windows using Docker?

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

Mick

14th May, 2018

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

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. • 4 months ago

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

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.