4 Best Reply Awards

  • Member Since 3 Years Ago
  • 716 Lessons Completed
  • 14 Favorites

20th July, 2018

Roni left a reply on Inaccurate Mentions On Forum • 1 day 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 • 1 day 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 • 1 week 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 • 1 week 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 • 1 week 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 • 3 weeks 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 • 4 weeks 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 • 4 weeks ago

Roni started a new conversation Wip And Nah Shell Command Aliases • 4 weeks 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 • 1 month ago

Crap, how did I miss this before ...

Roni started a new conversation Return Markdown In A Laravel View • 1 month 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? • 1 month 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 • 2 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? • 2 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 • 2 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 • 2 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. • 2 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 • 6 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 • 6 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 • 6 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 • 6 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 • 6 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 • 6 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 • 6 months ago

any solution?

Roni left a reply on Phpstorm Command Line Hack • 6 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 • 6 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 • 7 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. • 7 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? • 7 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? • 7 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? • 7 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? • 7 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. • 7 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

22nd November, 2017

Roni started a new conversation Anyone Know How To Set Up Laravel Mix To Utilize Subdomains? • 8 months ago

I have a project where we have a section like, and I've been trying to figure out how to get laravel mix and browsersync to let me do something like admin.localhost or

Any help would be appreciated.

10th November, 2017

Roni left a reply on Is There A Way To Make Private Images? • 8 months ago

Thanks @CJJ, I was about to check out digital ocean spaces for production, but I'm pretty sure the interface is identical. If you can throw up a code example, I'll switch over best answer to you.

Roni left a reply on Is There A Way To Make Private Images? • 8 months ago

Found this online, and it still works.

Move images that require interception and authentication/authorization or whatever guards you want into storage or any other path.

Then once it's out of public you can cane make a route to it, I chose "sigs" in my storage directory, you can choose anything:

Route::get('sigs/{filename}','[email protected]');

Then you can apply middleware on the route itself or in the controller, and finally, return the image

return response()->download(storage_path('/sigs/'.$filename), null, [], null);

now my secure image src is simply sigs/filename and it's secured with my guard of choice.

Cheers hope this helps someone.

Here is the link where I found the solution:

Roni left a reply on Is There A Way To Make Private Images? • 8 months ago

This doesn't work, it will intercept anything that is not a valid image and send you to authenticate. However, if you do get the actual file name it will just serve it and the middleware will never trigger :(

Roni started a new conversation Praetorian • 8 months ago

Is it just my pre-coffee delusional state or is there a little "pi" symbol on a button on the laracasts site in the bottom right corner!! Reminds me of an old movie "the net". Have we all been hacked!?!?!

Roni started a new conversation Is There A Way To Make Private Images? • 8 months ago

I'm looking at adding peoples signatures to an app during agreements or deliveries online, through any touch device. That's working fine. However right now, in our test phase the images are stored in the public directory which seems off.

Is there a way to store them privately, like in storage or assets, yet still show them in internal staff reports? Any time I point I seem to just get a blank image.

Alternatively can I put a guard on a public directory? for example Make a route

Route::get('/public/img/signatures/{slug}','[email protected]')->middleware('auth:staff');

then just return the image in the controller?

Any feedback appreciated.

1st November, 2017

Roni left a reply on Axios Without CSRF And Requested With Headers • 8 months ago

@theUnforgiven thanks also, I'm sure that method will work, I haven't attempted it yet, I don't know what the best practise is in these cases. I just saw the code snippet and it worked, so I committed and moved on. But I'll give it a try at some point when the pressure lets up. Cheers.

Roni left a reply on Axios Without CSRF And Requested With Headers • 8 months ago

Thanks for that, honestly I'm not sure and perhaps I'm misusing nomenclature. But I was using axios internally just for some easy for manipulation magic just to make the user interfaces a little more automatic for the users. Getting data as they respond to specific questions.

At some points I need to access API's externally, perhaps to get a list of JSON objects from a different service, both use cases used axios.get.

When I removed the headers the external just worked, however your solution allows me to do both.

I keep promising myself I'll dive into vue.js vanilla js and axios when time permits, instead of just backend work. It just seems like time never permits.

Thanks again. that was a life saver.

26th October, 2017

Roni started a new conversation Axios Without CSRF And Requested With Headers • 8 months ago


Using Laravel 5.5 and vue (I'm weak at JS) I'm making some axios requests that run both internally and externally to other content. The internal content is fine and needs CSRF tokens to protect our system. However the same CSRF are applied to external calls.

is there a way to keep using window.axios for internal calls and some other instance of axios kept for external requests?

Right now to get the externals working i've commented out the following:


window.axios = require('axios');

// window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

 * Next we will register the CSRF Token as a common header with Axios so that
 * all outgoing HTTP requests automatically have it attached. This is just
 * a simple convenience so we don't have to attach every token manually.
// let token = document.head.querySelector('meta[name="csrf-token"]');
// if (token) {
//     window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
// } else {
//     console.error('CSRF token not found:');
// }

That solves all the external issues but removes protection on the system.

How can I make something like externalAxios to make external calls while keeping axios for internals?

Thanks in advance for your time.

25th October, 2017

Roni left a reply on Validation - Other Field Has Value • 8 months ago

@JoeDawson , thanks! I was facing a really ugly validating task, looking for some built in solution. Pointing out that it's just a damn array that can be manipulated was such an easy solution that somehow I just ran right by it.

Cheers a year later!

2nd August, 2017

Roni left a reply on Laravel Mix Stylus And Bulma • 11 months ago

Any help would be appreciated, the way I do it I can't use browsersync any more.

Here is an example of my webpack.mix.js

mix.stylus('resources/assets/stylus/front/landing.styl', __dirname + '/tmp/public/build/tmp/css/front/');

//other staging here

mix.copy(__dirname+ '/tmp/public/build/tmp/css/front/landing.css','resources/assets/css/landing.css');

// finish organizing files.

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
        if (fs.existsSync(__dirname + '/public/build')){
            console.log('file exists');
            fs.removeSync(__dirname + '/public/build');
            console.log('file doesn\'t exist');

    proxy: ''

when the promise returns to delete the directory with all the staging files if the watch option is on, it will just keep running in an infinite loop.

My earlier configs seemed to work but now, it seems mix.preprocess "forces" you to use your public directory, instead of allowing you to process stylus to a css file directly in your resource/assets. I can't seem to find a work around where, I can pull in all our stylus core, and still use bulma sass.

Any ideas welcome.

Roni started a new conversation Laravel Mix Stylus And Bulma • 11 months ago

Anyone ever use bulma, but program the overrides in stylus? I got used to stylus, and now I find myself maintaining two variables files and overrides.

I mix stylus down to CSS then import it into sass build so I can override bulma. Is there a better way?

18th July, 2017

Roni left a reply on Is There A Good Tutorial Regarding Pushing Laravel With Vue Components Into Production On Forge • 1 year ago

It wasn't that but you got my brain out of a 4 hour rut.

-Thank you

Roni left a reply on Is There A Good Tutorial Regarding Pushing Laravel With Vue Components Into Production On Forge • 1 year ago

Yes, and extracting them to a vendor library. referencing both manifest and vendor

Roni started a new conversation Is There A Good Tutorial Regarding Pushing Laravel With Vue Components Into Production On Forge • 1 year ago

I'm pretty new to vue.js, and I've started using it in conjunction with axios adding them to my laravel projects.

However, it seems that everything just works locally, but once you move to deployment to work there are a host webpack nightmares waiting out there. I use laravel forge, which I would have thought would be opinionated to work easily with webpack and vue, but it doesn't seem to be.

Are there any good tutorials that take you past development and into deployment? Anyone know the secret sauce of why everything that works perfectly locally may die a painful death in production.

Any advice welcome.

17th July, 2017

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

@jlrdw on the script tags in the component? I've tried application/javascript text/javascript I've torn apart and re-written the code in 20 ways. Always the same. And all of them work perfectly in local development.

I'll open a ticket on forge. Thanks though.

Edit Your Profile

Want to change your profile photo? We pull from