Nospoon

Experience

19,495

0 Best Reply Awards

  • Member Since 3 Years Ago
  • 322 Lessons Completed
  • 0 Favorites

21st June, 2018

Nospoon left a reply on "The Expected [App\Jobs\ChargeBox] Job Was Not Pushed." • 1 day ago

I'm having the same problem when trying to test queue jobs.

Nospoon left a reply on Queue::assertPushed() Not Working • 1 day ago

Sorry, can't post the surrounding code here, but it is irrelevant to the issue either way. I've actually stumbled across the same exact problem wit \Mail::fake() today, I can verify code inside a mailable is being executed but \Mail::assertSent claims it was sent 0 times.

14th June, 2018

Nospoon left a reply on Parse String To View • 1 week ago

Most of the comments here are totally useless. You just keep saying there's no benefit to it and why would he ever want to do this, etc. Can we just assume he really needs/wants to do this and propose actual solutions rather than just throwing the same useless comments around on and on?

Nospoon started a new conversation Queue::assertPushed() Not Working • 1 week ago

I have a job that's being dispatched with SendFax::dispatchNow($fax);, i can confirm it being dispatched by running dd() from inside the job, however when I try to test it with Queue:fake() and then \Queue::assertPushed(SendFax::class);, it claims it didn't push, the test fails with The expected [App\Jobs\SendFax] job was not pushed. I tried changing dispatchNow() to dispatch() also but that didn't help. Any ideas what could be wrong?

3rd May, 2018

Nospoon left a reply on SqLite "no Such Table" Error In Unit Tests With Migrations • 1 month ago

I'm having the same problem with the new project I started recently. Funny thing is, I have this working perfectly in another project, but can't get it working on the new one.

1st February, 2018

Nospoon started a new conversation Refresh Config Instance On Running Process • 4 months ago

Is it possible to reload Config instance on a daemon process without terminating it? I have a config value that's resolved from a method call and what I need is for it to be updated each time a method in my queue handler is called, rather than fetched from the existing Config instance.

26th January, 2018

Nospoon left a reply on No Concat Method On Collection • 4 months ago

Updating composer dependencies helped. I'm guessing laravel/framework (v5.4.23 => v5.4.36) is what fixed it.

Nospoon left a reply on No Concat Method On Collection • 4 months ago

I'd really love to, but the site blocks all of my attempts to post any code whatsoever.

It is really simple though, I just instantiate a new Illuminate\Support\Collection and then try to run a concat on it, with a result set from elasticsearch query.

Nospoon started a new conversation No Concat Method On Collection • 4 months ago

The documentation for L 5.4, which is what I'm using, lists the concat method being available on collections. However when I try to use it, I get an error, as the method doesn't exist.

6th December, 2017

Nospoon left a reply on Eloquent Help: Generating Attribute Values Before Creating Record • 6 months ago

Ah, nevermind, I forgot to set the attributes array.

5th December, 2017

Nospoon left a reply on Eloquent Help: Generating Attribute Values Before Creating Record • 6 months ago

I'm trying to do something similar, where I'm generating an api key and secret for the user upon creation, however for some reason the fields are not being persisted to the database. They're there when the object is created, but when I grab a fresh instance from db they're gone. Any ideas?

28th June, 2017

Nospoon left a reply on [5.4] Contextual Binding Not Working • 11 months ago

Ok I figured it out. The problem was that the contextual binding only works with interfaces and I was trying to to use it on a concrete SmsMessageService class. I had to have the class implement an interface and inject that in my controller instead. I'm not too happy about having to implement an interface that's only ever used once in that class, but at least that solves the problem.

27th June, 2017

Nospoon started a new conversation [5.4] Contextual Binding Not Working • 11 months ago

I'm trying to use contextual binding for one of my services, but just can't get it work. I tried everything, injecting inside controller's constructor as well as using app() or resolve(). In the register method on my service provider I have something like this:

\App::when(SmsController::class)
    ->needs(SmsMessageService::class)
    ->give(function () {
        return new SmsMessageService(new SmsMessageParser(new SmsUdh()));
});
\App::when(VcardController::class)
    ->needs(SmsMessageService::class)
    ->give(function () {
        return new SmsMessageService(new SmsMessageParser(new VcardUdh()));
});

No matter what I do, it always resolves with the wrong dependency in the VcardController

Nospoon started a new conversation Container Instance Override Not Working • 11 months ago

I have a SmsMessageParser class which accepts a dependency of either SmsUdh or VcardUdh class the default being SmsUdh. I'm trying to override a DI instance inside my controller like so:

$udh = new VcardUdh();
$messageParser = new SmsMessageParser($udh);
\App::instance('sms_message_parser', $messageParser);

But when I dd(\App::make('sms_message_parser')); it always returns the SmsMessageParser with SmsUdh instead of VcardUdh.

I also tried using contextual binding for this, but that didn't work either.

25th June, 2017

Nospoon left a reply on Laravel Mix Not Processing Scss • 11 months ago

@bobbybouwmann , you're right in that if I disable the semantic-ui include and use mix.sass it does work. Unfortunately with semantic-ui included it throws an error. Invalid CSS after "r": expected 1 selector or at-rule, was "require('./js/api')"

Nospoon left a reply on Laravel Mix Not Processing Scss • 11 months ago

I can't, If I use sass it will throw an error as the semantic-ui-sass package uses .scss and they're not compatible.

Nospoon started a new conversation Laravel Mix Not Processing Scss • 11 months ago

For some reason webpack doesn't process the scss into css. When I run npm run dev it goes through fine without errors, but it doesn't produce app.css file. I'm using pretty standard setup in my webpack.mix.js:

 mix.js('resources/assets/js/app.js', 'public/js')
    .extract(['vue', 'semantic-ui-sass'])
    .scss('resources/assets/sass/app.scss', 'public/css')
    .version();

And in my main template I'm including it with mix like this: <link href="{{ mix('css/app.css') }}" rel="stylesheet">

4th May, 2017

Nospoon left a reply on Issue With Model Relation • 1 year ago

Solved it. Still I do not understand why it behaved like it did.

It was an issue with the HashedId trait. It contained the following method:

public static function findHashed($hashid)
    {
        $decoded = \Hashids::decode($hashid);

        if (!$decoded) {
            return null;
        }

        return self::find($decoded);
    }

The first line should be $decoded = \Hashids::decode($hashid)[0];.

It returned an array with single value, which was then being passed to application()->associate(Application::findHashed($request->get('application_id'))), causing it to create a collection of related entities, even though there was only one.

I still do not understand though why it was returning the collection when requesting $message->application_id, which should just return the value of database row and why was $message->application returning null.

Nospoon started a new conversation Issue With Model Relation • 1 year ago

I'm experiencing a very weird issue with one of my relations. I have a Message model which has an application_id foreign key.

In my Message model I have a relation declared like so:

public function application()
    {
        return $this->belongsTo(Application::class);
    }

However whenever I request $message->application_id, which should just give me the plain ID value, it returns the whole Application object instead.

Weirdly enough, $message->application()->associate($application); seems to work, but $message->application gives me null.

I've double and triple checked everything and can't figure out what the hell is wrong with it. I've never seen anything like this with any of my other models.

28th April, 2017

Nospoon left a reply on Routes And Url • 1 year ago

The only thing that comes to my mind is that the route name could be clashing with the actual bare url. Try renaming the route to something like shop.index and see what happens.

Nospoon left a reply on Validate Attribute Contains The Value Of Another Attribute • 1 year ago

I don't think this is what I'm looking for.

I need both fields to be required, but additionally the expected value in second field is dynamic, depending on what the user puts in first field. So it could be %some_key%, $differentone or #whateveryoufancy. Also the second field would contain some additional text, so it's not a simple 1 to 1 check.

Nospoon left a reply on Routes And Url • 1 year ago

Can you show how are you rendering the urls in your views?

I'm guessing you're using relative urls without preceding /. Try using absolute ones with url() method or name your routes and use route() method in your hrefs.

Nospoon started a new conversation Validate Attribute Contains The Value Of Another Attribute • 1 year ago

I have this specific requirement for validation, I need to check that a value specified in one input attribute is present in another attribute.

For example: Say we have two inputs, keyword and message. If the keyword attribute has a value of %some_key%, I want to verify that a message attribute's value is something like Hello, your key is %some_key%. and I want it to fail if it doesn't contain the %some_key% keyword.

How would I best approach that?

Nospoon left a reply on What To Test In A RESTful API • 1 year ago

It all depends. I'd say if you know you have your auth middleware applied on the whole group, testing it on every single endpoint is redundant.

Depending on what happens in your application, you might sometimes want to have a mix of unit and functional tests for some more complex stuff.

As a general rule - Think about what should happen and what could possibly go wrong and test against that. Think how would you be testing it manually, what would you be looking for.

I always tend to test the return values of each endpoint as well as required parameters if applicable. I also check if resources are saved to database as expected. If it handles the input the way you want it and spills out the output you expect, it's all good.

26th April, 2017

Nospoon left a reply on Route::bind() To Decode Hashid • 1 year ago

I'm facing a similar situation but for me the Route::bind is not working at all. What I have is:

Route::bind('application', function ($id, $route) {
                return \Hashids::decode($id)[0];
            });

But it's still passing through hashed id. It makes absolutely no difference whether I disable or enable the binding block.

23rd February, 2017

Nospoon left a reply on Eloquent Results As Array Instead Of Object • 1 year ago

@Mittensoff , It's more of a unique case this one so I probably wouldn't want this to be the default. Is it possible to set it on runtime?

@cipsas , toArray() on collection only converts the collection, not underlying objects.

I could use (array) conversion on every object, but it doesn't really solve the performance problem as it is still being hydrated as an object in the first place, so it's just an additional step on top.

Nospoon started a new conversation Eloquent Results As Array Instead Of Object • 1 year ago

Is it possible to return a collection of arrays rather than objects from Eloquent query?

I am performing a raw query and for performance reasons would like the results not to be hydrated into objects (huge amounts of data being parsed) but returned as arrays inside the collection. So far I couldn't find a way around this, even with raw query it always returns instances of StdObject.

17th February, 2017

Nospoon left a reply on [L5] Nice Names Attributes - Validation • 1 year ago

Is it actually possible to disable the automatic underscore removal? When working on an API this is not a good thing.

3rd February, 2017

Nospoon left a reply on Valet V1.1.2 Update: Just Keep Getting The 'It Works' • 1 year ago

I'm using Valet 2.0.3 and nothing of the above seems to be working. I had it working for some time but now suddenly all I can get i "It works!". Even after I stop apache this page is still displayed. Neither restarting nor completely removing and reinstalling Valet helps.

7th January, 2017

Nospoon left a reply on Handling Authorize() Fails By Redirecting To A Specific Page • 1 year ago

I have the same problem. I want to redirect users to login page if they hot a page that requires them to be logged in to see it. I tried overwriting the deny method on my custom policy to do a redirect instead of throwing an exception, but it didn't work.

21st May, 2016

Nospoon left a reply on Auth Session Killed After Redirect | Laravel 5.2 • 2 years ago

It's also important to pass the request parameter in the controller action (the one you're redirecting to after login), otherwise it will not see the session. Just something I learned today when facing the same issue.

27th August, 2015

Nospoon left a reply on L5.1 - Issues With Blade's Nesting And Includes • 2 years ago

Just as a quick note, since this error appeared for me again when using phpUnit. It seems to be an issue when using xdebug. It can be setting xdebug.max_nesting_level to a higher value in php.ini or module config file.

Nospoon left a reply on L5.1 - Issues With Blade's Nesting And Includes • 2 years ago

I thought I got rid of this error but there it is again this time when running phpUnit test. Fatal error: Maximum function nesting level of '100' reached, aborting!

23rd August, 2015

Nospoon left a reply on L5.1 - Issues With Blade's Nesting And Includes • 2 years ago

Now here's a weird thing. Today I fired it up just as I left it yesterday without doing anything and it doesn't throw an error. Somehow it automagically fixed itself, I assume that restarting apache did this but not sure why that would be the case.

Btw, navbar and footer are just simple html chunks so I doubt they would be causing the issue. Also they worked fine in two level nested views, just not with three levels.

And yes, the () after @endsection was a typo on my end.

22nd August, 2015

Nospoon started a new conversation L5.1 - Issues With Blade's Nesting And Includes • 2 years ago

So I've stumbled across an issue today. I have a structure of views like this: base -> view.base -> view, where the first base file also includes some partials like navbar and footer.

Thing is, when going into third level of inheritance, I get an exception: Maximum function nesting level of '100' reached, aborting!

It appears that the reason for this error are the includes in first parent view. If I remove those it all renders fine.

Does anyone know a way around it or have a better idea for organizing this?

Here's a bit more of how my views look like:

...
<body id="body">
    <header>
        @include('partials.navbar')
    </header>
    <main>
        @yield('body')
    </main>
    <footer>
        @include('partials.footer')
    </footer>
    @yield('scripts')
</body>
...
@extends('base')

@section('title', 'Overview')

@section('body')
    <div class="row">
        <div class="medium-2 columns">
            @yield('sidebar')
        </div>
        <div class="medium-10 columns">
            @yield('content')
        </div>
    </div>
@endsection()
@extends('panel.base')

@section('title', 'Overview')

@section('sidebar')
    <nav class="side-nav sidebar">
    ...
    </nav>
@endsection

@section('content')
    <div class="row">
        <div class="large-6 columns">
            ...
        </div>
    </div>
@endsection

9th August, 2015

Nospoon left a reply on Laravel 5.1 - Can't Get Facade To Work • 2 years ago

@usman clear-compiled didn't help as well. Still getting Class address_finder does not exist.

Nospoon left a reply on Laravel 5.1 - Can't Get Facade To Work • 2 years ago

Ok so the only way I've managed to get this working is by: in register() method of service provider referencing full class name:

$this->app->singleton('App\Services\AddressFinder', function () {
            return new AddressFinder('idealpostcodes');
        });

in facade

protected static function getFacadeAccessor()
    {
        return 'App\Services\AddressFinder';
    }

However this is not how it's done with all other service providers...

Nospoon left a reply on Laravel 5.1 - Can't Get Facade To Work • 2 years ago

Yes I did:

App\Providers\AddressFinderServiceProvider::class,

Nospoon left a reply on Laravel 5.1 - Can't Get Facade To Work • 2 years ago

Well that's kind of the part which I don't exactly understand, how do I make the binding correctly so that it's available by address_finder handle?

Nospoon left a reply on Laravel 5.1 Can't Get Facade To Work • 2 years ago

I've also seen different ways of binding the service, not sure which one is the correct one so I tried them all:

$this->app->singleton('address_finder', function () {
            return new AddressFinder('idealpostcodes');
        });

as well as

$this->app->bind('address_finder', function() {
            return new AddressFinder('idealpostcodes');
        });

Nospoon left a reply on Laravel 5.1 Can't Get Facade To Work • 2 years ago

Yes, multiple times, didn't help.

Nospoon started a new conversation Laravel 5.1 Can't Get Facade To Work • 2 years ago

So, I've looked through every possible documentation and forum thread on service providers and facades and still can't get this to work...

I have a service and a provider:

class AddressFinderServiceProvider extends ServiceProvider
{
    protected $defer = true;

    public function register()
    {
        $this->app->bind('address_finder', function()
        {
            return new AddressFinder('idealpostcodes');
        });
    }
}

And a facade for it:

namespace Flasher\Services\Facades;

use Illuminate\Support\Facades\Facade;

class AddressFinderFacade extends Facade
{
    protected static function getFacadeAccessor()
    {
        return 'address_finder';
    }
}

Now when I try to use AddressFinder::find($postcode); I'm getting

ReflectionException in Container.php line 736:
Class address_finder does not exist

Both the service provider and facade are properly registered in app.php.

If I pass the full class name in getFacadeAccessor() only then it works. As if the facade doesn't even try to resolve it from the service container.

6th March, 2015

Nospoon left a reply on Routing Not Working • 3 years ago

I've actually switched web server to nginx, which solved the problem (I probably would have done so anyways). But I still can't understand why it isn't working on apache, as I have mod_rewrite enabled and it should be working with the .htaccess file provided by default by laravel.

Nospoon left a reply on Routing Not Working • 3 years ago

I'm running CentOS7 with Apache on virtual machine

Nospoon started a new conversation Routing Not Working • 3 years ago

I have a fresh L5 project and from the begining I have a problem with my defined routes not working and raturning 404. I tried using Controller route, static route to controller action, static route with callback, nothing works. I can see the routes get registered using php artisan route:list, but none of them works. I've tried clearing routes catche, didn't help. I thought maybe the files were not updating across to my VM somehow, but when I remove the basic '/' route for welcome page, it throws an error, so this is working fine. Any ides?

8th February, 2015

Nospoon left a reply on PhpUnit Errors When Running From Elixir • 3 years ago

You were right, partially :) I managed to run it from linux VM, but stumbled upon new problem with gulp notifier. Then after some more search I found a clue in this thread. I ran npm cache clear and then npm install (on my host machine). Now gulp tdd works like a charm straight from the host.

Nospoon left a reply on PhpUnit Errors When Running From Elixir • 3 years ago

The path seems to be correct, I can see the file in vendor/bin/phpunit. Is it possible that it has something to do with the fact, that I'm running the commands locally and server is set up on virtual machine? But then still, why is this only happening when fired by gulp?

7th February, 2015

Nospoon started a new conversation PhpUnit Errors When Running From Elixir • 3 years ago

I've just started experimenting with TDD and Elixir in L5 and I've encountered a strange issue. I have phpUnit installed globally and locally in project, but when the tests are run by gulp tdd watcher, it says: [Error: Command failed: '.\vendor\bin\phpunit' is not recognized as an internal or external command, operable program or batch file.

However, when phpunit is called manually from shell, it works as expected. My setup is basically a default one that comes with Laravel5.

6th February, 2015

Nospoon left a reply on Homestead Installation With Composer • 3 years ago

homestead destroy will not work as homestead up failed to create the vm in the first place.

5th February, 2015

Nospoon left a reply on Homestead Installation With Composer • 3 years ago

Unfortunately now when I run homestead up I get the following error on vm startup: D:\Code>homestead up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'laravel/homestead'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'laravel/homestead' is up to date... ==> default: Setting the name of the VM: homestead ==> default: Destroying VM and associated drives... ==> default: Running cleanup tasks for 'file' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... ==> default: Running cleanup tasks for 'shell' provisioner... C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/platform. rb:126:in `each': "\xC4\xD8" followed by "A\x00" on UTF-16LE (Encoding::InvalidB yteSequenceError) from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/u til/platform.rb:126:in `to_a' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/u til/platform.rb:126:in `entries' and so on...

Edit Your Profile
Update

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