4 Best Reply Awards

  • Member Since 4 Years Ago
  • 759 Lessons Completed
  • 14 Favorites

20th September, 2018

Roni left a reply on Routing Action Syntax Vs Array Syntax And Route File Splitting • 3 days ago

@cronix if I could award you twice I would

everything just feels so much faster! I'm just looking at exactly what I need. I may have gone overboard and I'll feel it out in a day or so but wow. it was at 450 and constant scrolling and now little slices of heaven.

And each one of those only has between 10-60 routes. Just so much quick to find what I need. Thank again.


if( app()->environment() !== 'production'){
    require_once ('sections/test.php');

require_once ('sections/static.php');
require_once ('sections/products.php');
require_once ('sections/blog.php');
require_once ('sections/staff.php');
require_once ('sections/pdf.php');
require_once ('sections/home.php');

Route::get('/users/logout', 'Auth\[email protected]')->name('user.logout');

Roni left a reply on Routing Action Syntax Vs Array Syntax And Route File Splitting • 4 days ago

Thanks @Cronix, I should have tried that one before I posted.

Roni started a new conversation Routing Action Syntax Vs Array Syntax And Route File Splitting • 4 days ago

while looking at a large routes file, 300+ routes and growing, I frequently find myself annoyed that I can't command click on a route and go to the file or method. If there is a plug in for that on phpstorm any reference would be appreciated. Searching through that large file for your one line seems to be a mentally draining.

But while diving laravel I noticed the action() helper takes both:

 action('[email protected]') 


action( [FooController::class, 'index'] 

and playing with this idea in the routes file works fine too

Route::get('/Foo', [ FooController, 'index'])->name('foo.index'); 

you seem to have to import the controller at the top of routes.php which makes Route::namespace() fail or not work as expected.

Other than the namespace issue not working (you could use a fully Qualified route in it's place, is there a downside to this method I'm missing?Do all the use statements at the top add a massive additional overhead? As it would essentially use every controller.

Another option might be to sort routes into smaller more manageable files anyone separate the web routes into multiple files? Is there an operational cost to this?

Any advice would be appreciated.

15th September, 2018

Roni left a reply on Very Slow PHPUnit Tests Using PHP7.2 Or PHP7.1. • 1 week ago

What I prefer to do is add another group for example @needsPHPINI and test it separately. the -n flag removes the php_ini add ons and though you can enable them selectively, it can slow you down.

Then for my TDD cycles I just exclude the groups, unless i'm working directly on that item, and then i typically run only the one test or one class to keep it clean and fast.

I don't have my coding laptop with me but I realized I didn't leave an annotation example

here is a link from a quick google search on stack exchange

but basically

/** @test @needsPHPINI */
public function a_special_test() {
        // presumably doing something that has some special ini file need   


14th September, 2018

Roni left a reply on Very Slow PHPUnit Tests Using PHP7.2 Or PHP7.1. • 1 week ago

Don't remove x-debug if you need it, thats nuts, just disable it and any other extraneous php_ini add-ons while in unit test. add -n to your flags

here are some aliases to help out from my .bash_profile if you run your commands in the terminal.

alias c='clear'

alias phpspec='c;vendor/bin/phpspec'
alias phpunit='c;vendor/bin/phpunit'
alias p='c;php -n vendor/bin/phpunit --exclude-group external'
alias pf='c;php -n vendor/bin/phpunit --exclude-group external --filter '
alias pext='c;php -n vendor/bin/phpunit'
alias pextf='c;php -n vendor/bin/phpunit --filter '

Use the advice above, I extend DBTestCase a file with RefreshDatabases Trait and a bunch of other macros and hacks I need for testing features, for unit tests just extent regular test case so you don't run migrations when you don't need to.

Add an annotation like @external to tests that can't be rushed, like talking to an external payment gateway when you aren't mocking one out or any external service you can't rush like a fax server etc.. Once you have those running, test them when you need but not when you are doing TDD.

p or pf will run 3-5x faster that phpunit.

if you are using phpstorm, in your Debug Configuration under command line / Interpreter Options: add your -n there too and it should fly again.

HTH Cheers

Roni left a reply on Test If A View Partial Is Loaded In A Phpunit Test • 1 week ago

@click BOOM! Love it! I think this will play a major role in speeding up rapid my development, but the major benefit is going to really shine in change update request and task delegation!

Roni left a reply on Test If A View Partial Is Loaded In A Phpunit Test • 1 week ago

Actully the exists has another sneaky caveat, it will give you a false positive, it's only chekcing for view existance, not restricting it to your open views :(

Roni left a reply on Test If A View Partial Is Loaded In A Phpunit Test • 1 week ago

A+ for effort! You are awesome! However I can't make this work, in your case it's the main view not the view partial that you are checking. like using something from @include('some.partial');

For the main view an easier method is assertViewIs('auth.login'); It's a pre-baked assertion in laravel 5.7 and probably earlier, as the name is available as the last key in the view response.

The thing thats killing me is all the other blade segments or partials are stored there too. I just can't touch them because I can't find an accessor or a way to intercept the data.

I was hopeful on getFactory()->getFinder() they are all stored right there in $views, but there is no way to sneak them out.

Roni left a reply on Test If A View Partial Is Loaded In A Phpunit Test • 1 week ago

@click, thats actually just a buried part of the response object, basically I can find it, I just dont know how to find it :)

meaning for example in a unit test I'm not sure where to hook into it for example

$this->assertContains('some.blade.partial', $response->original->whatGoesHere());

I've been source diving for a couple of hours going through illuminate\Foundation\Response Object and it's symfony http-foundation set. But I can't figure out how to call it.

Roni left a reply on Test If A View Partial Is Loaded In A Phpunit Test • 1 week ago

@Tray2, I use that when I'm the designer, and the developer, but sometimes I've noticed during design updates where I'm not always on point that trying to semantically test on html is breaking, even if the code is fine. But the unit test lost what it was looking for. However, normally no one will change the blade or blade partial names. so I thought this would be a nicer solution.

@click thanks for the pointer, trying it now!

Roni started a new conversation Test If A View Partial Is Loaded In A Phpunit Test • 1 week ago

Is there a way to access a segment of a View response object? I'm trying to test if a view partial has been loaded in a less brittle way than just using see.

when I dd the response object I can find the view list

 #finder: Illuminate\View\FileViewFinder {#120
          #files: Illuminate\Filesystem\Filesystem {#121}
          #paths: array:1 [
            0 => "/Users/roni/code/php/laravel/5.7/munroe/resources/views"
          #views: array:13 [
            "" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/static/new-front.blade.php"
            "" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/front/v2/events/upcomming-conferences.blade.php"
            "segments.front.v2.weight-management" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/front/v2/weight-management.blade.php"
            "" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/front/v2/notifications/sale-free-registration.php"
            "segments.front.v2.compression-therapy" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/front/v2/compression-therapy.blade.php"
            "" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/layouts/new-front-with-nav.blade.php"
            "segments.front.v2.navbar" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/front/v2/navbar.blade.php"
            "" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/front/v2/reviews/div.blade.php"
            "segments.front.v2.newsletter" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/front/v2/newsletter.blade.php"
            "" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/front/map.blade.php"
            "segments.front.v2.footer" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/front/v2/footer.blade.php"
            "segments.scripts.front.v2.navbar" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/scripts/front/v2/navbar.blade.php"
            "segments.scripts.front.v2.newsletter" => "/Users/roni/code/php/laravel/5.7/munroe/resources/views/segments/scripts/front/v2/newsletter.blade.php"
          #hints: array:2 [
            "notifications" => array:1 [
              0 => "/Users/roni/code/php/laravel/5.7/munroe/vendor/laravel/framework/src/Illuminate/Notifications/resources/views"
            "pagination" => array:1 [
              0 => "/Users/roni/code/php/laravel/5.7/munroe/vendor/laravel/framework/src/Illuminate/Pagination/resources/views"

but I can't figure out how to isolate that portion of the view object and test against it. Any advice is welcome.

13th September, 2018

Roni left a reply on Out Of Order Migrations With GIT • 1 week ago

thanks for the quick response, I have an update to push and I was worried about making a crazy amount of extra work coordinating that change.

Roni started a new conversation Out Of Order Migrations With GIT • 1 week ago

As my workflow changes, I notice, I'm using git a bit more often, and more selectively then what I used to "git add ." As I work on feature requests, I can find myself deeply into one branch when a hotfix is required urgently. This has to be a common scenario, but until now, it hasn't had any impact.

If I have migrations on my feature branch that are dated before my hotfix branch, do I need to go and "re-date" all my feature migrations to a date after my hotfix migration to merge it? Or will laravel pick up on migrations that haven't been run and just run them. In this case, they are not dependant on each other.

7th September, 2018

Roni left a reply on Best Practises • 2 weeks ago

Thanks @Cronix

6th September, 2018

Roni started a new conversation Best Practises • 2 weeks ago

As applications grow, is there a best practise on Model and Controller naming and namespacing? Is it bad to end up with 2 of the same model name or controller names in different name spaces?

25th July, 2018

Roni left a reply on SourceMaps Problem With Laravel Mix • 1 month ago

@debiprasad, I'm not sure, I've been battling this all morning, as of laravel 5.6 with mix 2.1.11 sourcemaps are not showing up with dev or watch. but the webpack config did the trick.

20th July, 2018

Roni left a reply on Inaccurate Mentions On Forum • 2 months ago

Entirely possible, but as neither of us can actually know or look it up, I thought I’d pass it on to the only person that can.

Roni started a new conversation Inaccurate Mentions On Forum • 2 months ago

@JeffreyWay , logged in for a moment to sneak in a series when I saw I had a notification that I was mentioned. In the forum. So I went to the post becasue I couldn't remember contributing to that thread, and as it turns out I hadn't someone named @ rony had (one letter off).

Any chance you have Algolia or some fuzzy search running in the background to check mentions? For that specific use case I'd use exact match.

Have a great day.

11th July, 2018

Roni left a reply on Model Factory For A Polymorphic Relationship • 2 months ago

Sure, I’ll put something together on github tonight and post a link. And thanks for all the advice.

Roni left a reply on Model Factory For A Polymorphic Relationship • 2 months ago

Thanks Bobby, I should basically send all my questions directly to you!

I've solved it a bit differently, I think I could benefit from someone with more experience on this issue. Right now, have to keep the segment morph fields nullable, which seems wrong.

and what I've done is add the construction of the segment to the static boot method on the created hook to try and avoid that. but I've found that, it can get bloated, as I also have versions of the quote, which I need to pass through the constructor. I think I may need to rethink this a bit. Are there any paradigms you might suggest to solve this type of problem? Is there a better way to use some form of inheritance? Or just stick with models that don't extend a base and just follow a common external API?

10th July, 2018

Roni started a new conversation Model Factory For A Polymorphic Relationship • 2 months ago

I'm a bit stuck trying something out. Using a Java style inheritance in laravel to get a collection of specialized segments. I'm having a hard time figuring out how to get the model factory working for phpunit, though the code itself works.


$factory->define(Segment::class, function (Faker $faker) {

    return [
        'quote_id' => create(Quote::class)->id,


        'segmentable_id'=> null,
        'segmentable_type'=> '',

        'version' => 1,
        'version_accepted_by_client' => null,
        'version_accepted_by_company' => null,
        'active_version' => 1,
        'company_token' => null,
        'company_token_expiration' => null,
        'client_token' => null,
        'client_token_expiration' => null,



$factory->define(Stone::class, function (Faker $faker) {


    // create a segment class here and find a way to override

    return [

        'product_id' => function() { return create(Product::class)->id; },
        'height' => $faker->numberBetween(6,72),
        'width' => $faker->numberBetween(6,72),
        'grouted' => $faker->boolean,
        'sill_on_top' => $faker->boolean,
        'trim_stones' => $faker->numberBetween(0,6),
        'hearth_stones' => $faker->numberBetween(0,6),
        'light_boxes' => $faker->numberBetween(0,6),
        'power_boxes' => $faker->numberBetween(0,6),


The purpose of this is to delegate the calculation of each versioned segment to it's unique object, while allowing a collection of Segments to reside in a project and quote. There is no specific guarantee that any project will have any specific segment. Yet this creates a completely flexible approach.

In code this is not an issue, as I can enforce the relationship in in the boot creating method of the object, or in the controller. I'm a bit new to TDD and factories, is there a "right way" to do this in the model factory?


29th June, 2018

Roni left a reply on Wip And Nah Shell Command Aliases • 2 months ago

Thanks, my filters somehow blocked these responses sorry for the late award

23rd June, 2018

Roni started a new conversation Setup Aliases For A More TDD Workflow With PHP Storm • 3 months ago

I love PHP storm, however one of the most frustrating aspects of it is syncing. Nothing helps much. Some solutions work for a day and then I'm back to sync(ing) files again.

So here is a gist of my bash aliases I used to get around this problem. Specifically the list command. These commands will create the files via artisan but also instantly set focus on them in the phpstorm ide so you don't have to manually sync to open them.

Hope this saves a few people a ton of hours googling.

This works on mac os 10.13.4 for other platforms I'm not really sure.

export PATH="~/.composer/vendor/bin:$PATH"
export EDITOR='subl -w'

alias ..="cd .."
alias ...="cd ../.."
alias md='mkdir -pv'
alias h='cd ~'
alias c='clear'
alias l='ls -laF'
alias flush-cache='sudo killall -HUP mDNSResponder;say DNS cache has been flushed'

export PS1="\[$(tput bold)\]\[$(tput setaf 2)\]\W \[$(tput setaf 153)\]‣ \[$(tput sgr0)\]\[$(tput sgr0)\]"


alias copy-key='pbcopy < ~/.ssh/'
alias edit-commands='subl ~/.settings/.bash_aliases;'
alias reload-commands='c; source ~/.settings/.bash_aliases; echo "Done."'

alias art='php artisan'

alias tinker='art tinker'
alias yw='c;yarn run watch'
alias dev='c;yarn run development'
alias prod='c;yarn run production'

alias last_file='lastFileFunction(){
    dirname=$(ls -dt * | head -1)
    echo $dirname

    unset -f lastFileFunction

alias gts='git status'
alias gtk='git checkout'
alias gtm='git checkout master'
alias gtc='git commit -a'
alias gtp='git push origin'
alias gta='git add .'
alias gtl='git log --pretty=format:"%h : %an : %ar : %s"'
alias gtrevert='git add -A .;git stash;git stash drop [email protected]{0}'

alias gtep='function __complete_episode(){ 
    echo processing $(($*))
    git add .
    git commit -m "completed episode $*"
    git push origin master


    echo "start working on episode $(($*+1))"
    unset -f __complete_episode
}; __complete_episode'

alias update-npm='c; echo "Updating NPM ..."; npm install [email protected] -g;c;echo "New NPM Version:"; npm -v'

alias list='listFunction(){

    echo "Laravel Helpers List"
    echo "--------------------"
    echo ""
    echo "ft => Feature Test"
    echo "ut => Unit Test"
    echo ""
    echo "pc => Plain Controller"
    echo "rc => Resourcefull Controller"
    echo ""
    echo "pm => Plain Model (Model with migration comming for now mn)"
    echo ""
    echo "pe => Event"
    echo "fr => Form Request"
    echo "mw => Middleware"
    echo "sp => Service Provider"
    echo "mf => Model Factory"
    echo "pr => Rule"
    echo ""
    echo "nv => New View File {path/to/name or or name.blade.php}"
    echo ""
    echo "mn => New Migration, jsut the name of the table create_<posts>_table"
    echo "mp => Plain Migration, mp add_something_to_posts posts"
    echo ""

unset -f listFunction   
}; listFunction'

alias ft='{ f=$(cat -); php artisan make:test ${f}Test; pstorm app/tests/Feature/${f}Test.php;}<<<'
alias ut='{ f=$(cat -); php artisan make:test ${f}Test --unit; pstorm app/tests/Unit/${f}Test.php;}<<<'
alias pc='{ f=$(cat -); php artisan make:controller ${f}Controller; pstorm app/Http/Controllers/${f}Controller.php;}<<<'
alias rc='{ f=$(cat -); php artisan make:controller ${f}Controller -r; app/Http/Controllers/${f}Controller.php;}<<<'
alias pm='{ f=$(cat -); php artisan make:model ${f}; pstorm app/${f}.php;}<<<'
alias pe='{ f=$(cat -); php artisan make:event ${f}; pstorm app/Events/${f}.php;}<<<'
alias fr='{ f=$(cat -); php artisan make:request ${f}Request; pstorm app/Http/Requests/${f}Request.php;}<<<'
alias mw='{ f=$(cat -); php artisan make:middleware ${f}; pstorm app/Http/Middleware/${f}.php;}<<<'
alias sp='{ f=$(cat -); php artisan make:provider ${f}Provider; pstorm app/Providers/${f}Provider.php;}<<<'
alias mf='{ f=$(cat -); php artisan make:factory ${f}Factory; pstorm database/factories/${f}Factory.php;}<<<'
alias pr='{ f=$(cat -); php artisan make:rule ${f}Rule; pstorm database/factories/${f}Rule.php;}<<<'
alias nv='{ f=$(cat -); php artisan make:view ${f};}<<<'

alias mn='function __migrate-new-make(){
    tab=$(php artisan make:migration create_$*_table --create=$* --table=$*); 
    pstorm database/migrations/${tab:19}.php; 
    unset -f __migrate-new-make; 
}; __migrate-new-make'

alias mp='function __migrate-make(){
    tab=$(php artisan make:migration  --table=); 
    pstorm database/migrations/${tab:19}.php; 
    unset -f __migrate-make; 
}; __migrate-make'

alias migrate='php artisan migrate'
alias fresh='redis-cli flushall; php artisan migrate:fresh'
alias rlist='php artisan route:list'

alias cda='composer dump-autoload -o'

alias phpspec='c;vendor/bin/phpspec'
alias phpunit='c;vendor/bin/phpunit'
alias p='c;php -n vendor/bin/phpunit'
alias pf='c;php -n vendor/bin/phpunit --filter '
alias px='phpunit'
alias pfx='phpunit --filter '

This relies on one artisan command for making a view,


namespace App\Console\Commands;

use Illuminate\Console\Command;

class MakeViewCommand extends Command
     * The name and signature of the console command.
     * @var string
    protected $signature = 'make:view 
                        {name : The path to the new view not including /resources/views/}
                        {--force : Overwrite existing file by default}';

     * The console command description.
     * @var string
    protected $description = 'Create empty view in resources views, ';

     * Create a new command instance.
     * @return void
    public function __construct()

     * Execute the console command.
     * @return mixed
    public function handle()
        $name = str_replace('.','/',str_replace('.blade.php','',$this->argument('name')));

        $viewNames = pathinfo($name);

        $this->exportView($viewNames['dirname'], $viewNames['filename']);

        $this->info($name.'.blade.php created successfully.');


    protected function createDirectories($path)
        if (! is_dir($directory = resource_path('views/'.$path))) {
            mkdir($directory, 0755, true);


    protected function exportView($path, $filename)
        if (file_exists($view = resource_path('views/'.$path.'/'.$filename.'.blade.php')) && ! $this->option('force')) {
            if (! $this->confirm("The [{$path}/{$filename}] view already exists. Do you want to replace it?")) {
                $this->error($view.'.blade.php not created!');
                exec("rm $view");
//                unlink($view);

        file_put_contents($view,"@extends('')\n\[email protected]('content')\n\[email protected]");
        exec("pstorm {$view}");

If anyone has something better or awesome to add, or would like to help make this less brittle, please feel free to add it here, or send me a message. Here are the gist links.



22nd June, 2018

Roni left a reply on Wip And Nah Shell Command Aliases • 3 months ago

Roni started a new conversation Wip And Nah Shell Command Aliases • 3 months ago

Hey @JeffreyWay, would you mind sharing a couple of shortcuts and aliases?

Going through the Laravel Forum tutrial I noticed you use wip to try out things in git and nah to revert. If you wouldn't mind posting those aliases thought it would be helpful.


19th June, 2018

Roni left a reply on Return Markdown In A Laravel View • 3 months ago

Crap, how did I miss this before ...

Roni started a new conversation Return Markdown In A Laravel View • 3 months ago

Is there a way to return the markdown of an email mailable as view? Right now, I'm sending it to mailtrap and this has to be the wrong, at least for speed.


Email test section in web.php

Route::prefix('test')->namespace('Test')->group(function() {
    Route::prefix('email')->group(function() {
        Route::prefix('inquiry')->group(function () {
            Route::get('/send', '[email protected]');
            Route::get('/view', '[email protected]');
        Route::prefix('inquiry-confirmation')->group(function () {
            Route::get('/send', '[email protected]');
            Route::get('/view', '[email protected]');

Send Email Controller is fine, all function as expected, I just want to tweak the markdown.

Inquiry Confirmation section in ViewEmailController

    public function inquiryConfirmation(Faker $faker)
        return view('email.your-inquiry-has-been-sent')->with('data',[
            'name' => 'John Doe',
            'email' => '[email protected]',
            'phone' => '2223334444',
            'inquiry' =>  implode($faker->paragraphs(3))

This method works fine, with regular blade emails, but if I want to use the markdown parser, it fails.


    # Order Shipped
    Your order has been shipped!

    @component('mail::button', ['url' => '#'])
        View Order

    {{ config('') }}

I just want to get it on screen to tweak it, without having to send it to Any pointers welcome.

16th June, 2018

Roni left a reply on Possible To Use .htaccess Files Using Valet? • 3 months ago

@marcgaumont Glad it helped. Nothing is more irritating than not being able to start in on something.

16th May, 2018

Roni left a reply on Throwing Exceptions Vs Returning Response • 4 months ago

@skliche I know it's 2 years later. I just somehow needed to read "extend the class and override the method". It's been a 10 hour day and my brain just wasn't going there on it's own. :)

cheers !

10th May, 2018

Roni started a new conversation Is There A Check To Skip A Specific Migration For Unit Tests In A Migration Class? • 4 months ago

For example

 public function up()
        If ( ! <test indicator>){
            // migrate stuff here

Roni left a reply on Auth()->id() Returns Null In Static Trait Boot Function • 4 months ago

1 million dd()'s later it's the seed migration that throws off allt he tests ! ouch! dang it vue for making me need to re-seed!

Roni started a new conversation Auth()->id() Returns Null In Static Trait Boot Function • 4 months ago

Hi, I finally got around to the laravel Forum TDD series, which is a great primer. At some point, auth()->id() stopped working in a trait boot function, and started returning null instead of the authorized user.

I'm using php 7.2.2, and laravel 5.4.15

her is the triat right out of the course, and I'm positive it worked at some point.

trait RecordsActivity
     * Boot the trait.
    protected static function bootRecordsActivity()
        if (auth()->guest()) return; //This returns true instead of false which forces an early return.

        foreach (static::getActivitiesToRecord() as $event) {
            static::$event(function ($model) use ($event) {

        static::deleting(function ($model) {

here is the ActivityTest Class that calls it, again right out of the repo.


namespace Tests\Feature;

use App\Activity;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;

class ActivityTest extends TestCase
    use DatabaseMigrations;

    /** @test */
    public function it_records_activity_when_a_thread_is_created()

        $thread = create('App\Thread');

        $this->assertDatabaseHas('activities', [
            'type' => 'created_thread',
            'user_id' => auth()->id(),
            'subject_id' => $thread->id,
            'subject_type' => 'App\Thread'

        $activity = Activity::first();

        $this->assertEquals($activity->subject->id, $thread->id);

    /** @test */
    function it_records_activity_when_a_reply_is_created()

// if you add dd(auth()->id()) at any point other than the boot method it returns an id

        $reply = create('App\Reply');

        $this->assertEquals(2, Activity::count());

    /** @test */
    function it_fetches_a_feed_for_any_user()

        create('App\Thread', ['user_id' => auth()->id()], 2);

        auth()->user()->activity()->first()->update(['created_at' => Carbon::now()->subWeek()]);

        $feed = Activity::feed(auth()->user(), 50);



Thanks, any advice would be greatly appreciated.

9th May, 2018

Roni left a reply on Refused To Execute Script From ''<js File> Because Its MIME Type ('text/html') Is Not Executable, And Strict MIME Type Checking Is Enabled. • 4 months ago

Hi nate, sorry I haven't looked at that repo in about 8 months, but i can either sneak late tonight or on the weekend after the jets game (go winnipeg)!

18th January, 2018

Roni left a reply on Sort A Collection By A Relationship Value • 8 months ago

Shazam! @jbloomstrom, nice! It just worked! I have to take it apart and see why but thanks. I never thought of transform. @kreierson, I'm not sure I want that in all situations, I've never tried ordering a relationship in that fashion, but I'll try some tests next week and see if it holds. Thank you as well.

Roni left a reply on Sort A Collection By A Relationship Value • 8 months ago

@jbloomstrom, Diving in a little deeper to eloquent, it looks like laravel active record won't work in this way, when it's gathering the records from a relationship, it does a

select from orders (outer object) where exists (then some inner logic)

It then it applies your group by and order offset and limit to the outer loop. So regardless of you inner return order it makes no difference because it's only a boolean existential, connection.

I'm not saying there isn't a way with eloquent, but I don't know it. But you'll need to render a join and cleanup of some sort to have any effect. Hence the reason I was hoping to deal with it at the collection level. Where's @adamwathan when you need him :)

Roni left a reply on Sort A Collection By A Relationship Value • 8 months ago

Another clarification, I can't just use $touches on the order contact note to the relationship, as lots of things update an actual order, so the ordering would be come random as different people go about their tasks.

Roni left a reply on Sort A Collection By A Relationship Value • 8 months ago

@jbloomstrom, I see what you are saying, I'm getting the data, just out of order, but I can't sort in on the collection. or from the DB. let me explain a bit further, to clarify what I'm trying to accomplish.

Basically, I'm using eloquent to get the active model approach, where instead of getting a DB record 1:1 tuple approach of getting the order notes, and then programatically grouping them into orders and displaying them, I'm grabbing the orders with their respective notes, and then displaying the order some basic order information, and then a list of it's notes followed by a place to add a new note.

This way the managers can always see what orders are being worked on and add their own notes. It keeps actively processed orders on the top of their visual interface. Like a facebook post where as people add a comment, the post rises to the top of a timeline, however the comments still stay in chronological order with the earliest on the top and the newest on the bottom.

However, what I'm getting, depending on the collection sort method I use, is sorting by any value specifically on the order, like order->updated_at or order->id. But if I want to sort the orders based on the max created_at value (descending) of the orderContactNote object when it's available, (when it's not available clearly kick it to the bottom of the list). So that if you have a contact with a client and note it, that Order object, bubbles to the top of the page.

The sortByDesc() in the docs leads me to believe it would do the job, but it doesn't seem to be handling it.

Roni left a reply on Sort A Collection By A Relationship Value • 8 months ago

Thanks @bashy, thats helpful, I never checked when before, however it doesn't impact the sorting. But I appreciate the refactor.

Roni started a new conversation Sort A Collection By A Relationship Value • 8 months ago

I have a model Orders, which has a relationship

public function orderContactNotes()
        return $this->hasMany('App\OrderContactNote');

Now Orders get updated all the time, and contact notes as well. I have a view where the requirements need to show orders based on the most recent note. Orders may have many notes.

I thought this would have been simple, but I think I'm missing something in eloquent or the collection sorting

I've tried a number of possibilities both by them selves and in tandem here are some options that don't seem to work

public static function notesByStaffExcept($staff_id, $limit=100, $id=null)
        $list =  self::with(
            ->whereHas('orderContactNotes', function($query) use($staff_id) {
                return $query->where('staff_id','<>',$staff_id)->orderBy('updated_at','desc');

            $list = $list->where('id', $id);
        return $list->limit($limit)->get()->sortByDesc(function ($order,$key){
            return optional($order->orderContactNote)->'created_at';

OR adding a max although I think the scope of the max() is the issue.

public static function notesByStaffExcept($staff_id, $limit=100, $id=null)
        $list =  self::with(
            ->whereHas('orderContactNotes', function($query) use($staff_id) {
                return $query->where('staff_id','<>',$staff_id)->orderBy('updated_at','desc');

            $list = $list->where('id', $id);
        return $list->limit($limit)->get()->sortByDesc(function ($order,$key){
            return optional($order->orderContactNote)->max('created_at');

Any clarification would appreciated.

8th January, 2018

Roni left a reply on Running Headless Chrome On Vagrant Homestead Using Php Shell_exec • 8 months ago

any solution?

Roni left a reply on Phpstorm Command Line Hack • 8 months ago

Thanks @bobbybouwmann, I'll give that a try. Maybe someone has some secret sauce they can share with us.

Roni started a new conversation Phpstorm Command Line Hack • 8 months ago

Just a whim, but does anyone know how to open a file in phpstorm when the ide is already running?

For example, if the ide is closed. From the terminal (iterm2 on macOS high sierra) I can simply write pstorm <path/to/file> much like the sublime text subl <path/to/file>. However, if the ide is running, this command has no effect.

It's just a pet peeve making a migration or controller then navigating to it and syncing the directory (sometimes it takes a minute to auto detect and command + P wont work unless it's indexed) I'd love to add that to my artisan aliases.

18th December, 2017

Roni left a reply on Adding A Data Element Thats Observable. Vue/Axios • 9 months ago

Hi @SyedAbuthahir, thanks, thats actually where both option 2 and 3 are from. I'm still not a JS guru, so I'm sure I'm missing something there, but I think if this was an easy fix someone would have thrown something out, so for posterity's sake, here is the solution I utilized.

Again, many of the solutions I come to come out of a need to not spend more than a half day working on a problem. It's just to expensive and hampers work flow. So my cheat solution was to change my endpoint, and run the data through a php controller sanitizing function.

In php I just created a notes array as an empty array in each collection object. Then returned the sanitized dataset to the original vue problem. Once the notes array was there, there was no need for me to do any further reactive toying around because the array was now reactive.

This won't solve your problem if you can't manipulate endpoints in a project, or you are working in a situation where you are required to solve this in vue, but if you can just deal with it in php beforehand. It's quick and dirt easy.

here is the code $list was the original value, I extracted the notes, and simple made an empty notes collection in each list item, and then populated the notes into that element when it existed.

* Don't use null, it won't render in a vue list v-for directive. * Don't forget to use collection->values() to reset the indices of the to 0,1,2 ... or JS won't consider it a proper array, (that cost me 30 min too)

$col = collect($list)->keyBy('id');

$col->each(function($order) use ($notes){

    $order->notes = collect();

    if($notes->has($order->id)) {

$col = $col->values();

15th December, 2017

Roni started a new conversation Adding A Data Element Thats Observable. • 9 months ago

I have a data element rendering a list. From an axios request. It's getting it's data from a database Query with a collection. In some cases the collection has another notes collection element, in others where there are no notes, there is no notes collection added.

Object 1 > stuff
Object 1 >notes > array[0] > "Lorem"
Object 1 >notes > array[1] > "Ipsum"

Object 2>stuff

Object 3 > stuff
Object 3 >notes > array[0] > "sit"

The all render perfectly on a app with a report. However, if I need to add a note, when I add it via axios.patch on object 1 or object 3 and then push the new data item to the object.notes array, it works perfectly.

However when I need to create the notes array and then add it in object 2, it adds, but it's not reactive and won't get re-rendered.

I've tried several methods of making it observable but I haven;'t been able to figure this one out. Here are some of the code options I've tried.

//there is a tableData: [] in the data section
//this computed section allows a filter on the tableData. I don't think it's relevant but just in case.

computed: {
        filteredData() {

            return this.tableData.filter(row => {
                // console.log(this.searchKey.toLowerCase());
                // console.log(row.user.first_name);

                return > -1




//When I update the form this function is triggered:

postNote(item, order){
        params: {
            api_token: this.api_token,
            staff_id: this.api_user,
            order_id: order,
            note_type_id: this.newNoteType[order],
            note: this.comment[order],
    }).then((response) => {

    //OPTION 1 this works for data that already has a notes array and new notes are added


    //OPTION 2: Looking at the deeper reactivity section from the vue docs I tried this.
    //the data looks perfect on the vue developer tool, but it's not re-rendering.

        if(this.tableData[item].notes == null){
            this.filteredData[item] = Object.assign({},this.tableData[item],{notes:})
            // Vue.set(this.tableData[item].notes,0,;

    //OPTION 3
    //Data also looks perfect but again it won't re-render.

    if(this.tableData[item].notes == null){
            this.tableData[item].notes = [];
        } else{

        //clean up props
        this.newNoteType[order] = undefined;
        this.comment[order] = undefined;

    }).catch((errors) => {

    //end with


in case this helps here is the view layer where the note is rendered

      <article class="media" v-for="(note,index) in props.row.notes">
            <figure class="media-left">
                <p class="image is-64x64">
                    <img :src="getStaffAvatar(note.staff_id)">
            <div class="media-content">
                <div class="content">
                        <strong>@{{ }} @{{ note.staff_id }}</strong>
                        <small>@{{ Date.create(note.created_at).relative() }}</small><br>
                        <strong>@{{ note.description }}</strong>
                        <p v-if="note.note !== null">@{{ note.note }}</p>

Any ideas or solutions welcome, if more code is needed please advise.

Roni left a reply on Is It Worth Javascriptifying The Front-end? • 9 months ago

I haven't watched the series and it definitely adds a layer of complexity, however, in some cases especially a forum like scenario where you may have several layers deep of responses and other responses that are not related, screen refreshes and full reloading often result in distractions. Especially when you are not in control of all the design where you can mitigate those.

I'm feeling the pain of vue as it's not nearly as easy as blade for me ... yet. However, it definitely has a place where re-rendering is even a minor distraction. Try not to think of it as a programmer but rather as a user, who may have to spend several hours a day on your app.

If you can save them small distractions and annoyances that add up to 100x a day, and possibly across 10-100 employees, the extra pains you take pay massive dividends.

29th November, 2017

Roni left a reply on Anyone Know A Way To Get Dd($something) Nicely Formatted In The Network Preview Tab Of Google Chrome? • 9 months ago

Thanks, that did clean it up a bit. Much appreciated.

Roni left a reply on Anyone Know A Way To Get Dd($something) Nicely Formatted In The Network Preview Tab Of Google Chrome? • 9 months ago

Thanks @ejdelmonico, I'm getting the same thing as the dd with that one.

This isn't the worst: dd(print_r($request->all()));

For now, I'm just trying to use it to make sure my requests are sending in the right data and at certain points where Vue is receiving data. It's been a while, but in the back of my head it used to just work.

Again this is only in the network pane of the devtools. In the regular window of chrome 62 it all returns as expected.

Roni started a new conversation Anyone Know A Way To Get Dd($something) Nicely Formatted In The Network Preview Tab Of Google Chrome? • 9 months ago

Been working on a fair amount of vue lately, as as I dd() a few things, in the preview tab I end up with stuff like this:

Sfdump = window.Sfdump || (function (doc) { var refStyle = doc.createElement('style'), rxEsc = /([.*+?^${}()|\[\]\/\\])/g, idRx = /\bsf-dump-\d+-ref[012]\w+\b/, keyHint = 0

23rd November, 2017

Roni started a new conversation Relationship Create Not Working As Expected. • 10 months ago

I'm working on a laravel 5.5 application, and after debugging for an hour I've stumbled across the following issue when building up an object. I can't for the life of me figure this one out, so if someone could point me at why this is happening that would be awesome.


    protected $guarded = [];
    //not a mass assignment issue

     * Get the compression profile record associated with the User.
    public function compressionProfile()
        return $this->hasOne('App\CompressionProfile');

     * Get the family that owns the User.
    public function family()
        return $this->belongsTo('App\Family');


//create a family for the user

            //create compression profile with first step for accidental redirection
            //and add the current compressionProfile onboarding version from env
                'profile_redirect_to' => 'conference.profile.step.2',
                'current_profile_version' => env('APP_VERSION')

Does the eloquent relationship builder create() only work on the hasOne model?

I ended up hacking out this:

$user->family_id = $user->family()->create([])->id

But it feels unclear. Thanks

Edit Your Profile

Want to change your profile photo? We pull from