jgravois

Technical Manager at Universal Asset Management

Experience

81,695

2 Best Reply Awards

  • Member Since 3 Years Ago
  • 892 Lessons Completed
  • 18 Favorites

22nd September, 2017

jgravois started a new conversation "Dynamic" Store Properties • 1 day ago

is there a way to create “dynamic properties” in a Vuex store? I have a task counter that I need to save state with across many components as well as many devices … there could be 1 or 100 active timers … so when I start a timers, I need something like timer_task20087 in the store … I don’t know how to programmatically add a property to the store.

14th September, 2017

jgravois left a reply on So Very, Very Lost In A Polymorphic Relationship • 1 week ago

never mind, the return in the call was screwing with the response

since the api to use will be

if($user->isAvailable('2017-09-15 08:00', 2880)) {
    $user->assign('2017-09-15 08:00', 2880);
}

this is PERFECT!

Thank you @martinbean and @36864

jgravois left a reply on So Very, Very Lost In A Polymorphic Relationship • 1 week ago

BTW, I am calling it like this

return $user->isAvailable('2017-09-15 08:00', 2880);

jgravois left a reply on So Very, Very Lost In A Polymorphic Relationship • 1 week ago

OK, I added this to the trait

public function isAvailable($date, $minutes)
    {
        $date = Carbon::createFromFormat('Y-m-d H:i', $date);
        $date_end = $date->copy()->addMinutes($minutes);
        return $this->assignments()
            ->orWhereBetween('assign_date', [$date, $date_end])
            ->orWhereBetween('assign_end_date', [$date, $date_end])
            ->exists();
    }

and I get

UnexpectedValueException in Response.php line 450: The Response content must be a string or object implementing __toString(), "boolean" given.

BUT I WANT AN EFFIN BOOLEAN .... arrggggg

jgravois left a reply on So Very, Very Lost In A Polymorphic Relationship • 1 week ago

BUT before I can do that ... I have to make sure that user and that forklift and that metal pallet are available during that time

jgravois left a reply on So Very, Very Lost In A Polymorphic Relationship • 1 week ago

LOL, don''t assume you misunderstood anything ... I am positive any ignorance is totally on my part.

Anyway, if I understand your question, the assignments table lists each (and is assigned via the assign method on the trait ... here is an example of use (still just testing but this works

foreach($tasks as $task) {
    if($task->id == 61) {
        $user->park('2017-09-14 08:00', 4320);
        $user->assign($task, '2017-09-20 08:00', 300);
        $lift->assign($task, '2017-09-20 08:00', 300);
        $pallet->assign($task, '2017-09-20 08:00', 300);
    } // end if
} // end foreach

jgravois left a reply on So Very, Very Lost In A Polymorphic Relationship • 1 week ago

I appreciate your time and ideas .... thanks!

The equipment and tooling is assigned just like staff ... it's not that the staff is using the equipment, the TASK is using the equipment. So, for example, removing the vertical stabilizer requires a rudder lock, 3 Level 4+ Techs and 2 other Techs (no level required - just hands and arms ... LOL)

So since equipment, tooling and staff are assigned in the same manner, wouldn't a polymorphic be the right tool?

jgravois left a reply on So Very, Very Lost In A Polymorphic Relationship • 1 week ago

That was where I began but as it became more complex, I reached for that polymorphic lesson.

There are TASKS that require TECHS of a certain skill level and possibly EQUIPMENT and TOOLING ... the TECHS have to be notified the morning of the TASK as well as have all their TASKS listed when they log in.

To me, it seemed that a polymorphic like Jeff described would all all tasks to be in a single table and would make later processing simpler.

jgravois started a new conversation So Very, Very Lost In A Polymorphic Relationship • 1 week ago

This is my very first attempt at a polymorphic relationship (I followed this lesson: [https://laracasts.com/series/how-do-i/episodes/8]) but I am quite lost.

I have users, equipment and tooling that can be “assigned” to a task so I created a trait for all three to inherit named Assignable.

I am trying to create an isAvailable() method that will return a boolean if the user, equipment or tooling is available during a specific period -- a call like return $user->isAvailable('2017-09-15 08:00', 2880); asking if a user can be assigned a task starting at 8:00 on 9/15 and lasting 2880 minutes. All I can seem to get is an exception of 'Object of class Illuminate\Database\Eloquent\Relations\MorphMany could not be converted to string'.

This is the schema of the table I am querying and the trait I created:

$table->increments('id');
$table->boolean('is_time_off')->default(false);
$table->boolean('was_notified')->default(false);
$table->integer('ws_task_id')->unsigned()->index();
$table->integer('assignable_id')->unsigned()->nullable();
$table->string('assignable_type')->nullable();
$table->dateTime('assign_date')->nullable();
$table->dateTime('assign_end_date')->nullable();
$table->timestamps();
<?php

namespace App\Traits;

use App\Models\AdcWorkscopeTask;
use App\Models\WsAssignedTask;
use Carbon\Carbon;

trait Assignable
{
    public function assignments()
    {
        return $this->morphMany(WsAssignedTask::class, 'assignable');
    } // end function

    public function scopeAssignedOn($query, AdcWorkscopeTask $task)
    {
        return $query->whereHas('assignments', function($query) use ($task) {
            $query->where('task_id', $task->id);
        });
    } // end function

    public function isAssignedOn(AdcWorkscopeTask $task)
    {
        return $this->assignments()->where('task_id', $task->id)->exists();
    } // end function

    public function isAvailable($date, $minutes)
    {
        //return $this->type;
        return $this->id;
    } // end function

    public function assign($task, $assignDate, $minutes)
    {
        $start_date = Carbon::createFromFormat('Y-m-d H:i', $assignDate);
        $end_date = $start_date->copy()->addMinutes($minutes);

        $this->assignments()->save(
            new WsAssignedTask([
                'ws_task_id' => $task->id,
                'is_time_off' => false,
                'was_notified' => false,
                'assign_date' => $start_date,
                'assign_end_date' => $end_date
            ])
        );
    } // end function

    public function park($assignDate, $minutes)
    {
        $start_date = Carbon::createFromFormat('Y-m-d H:i', $assignDate);
        $end_date = $start_date->copy()->addMinutes($minutes);

        $this->assignments()->save(
            new WsAssignedTask([
                'ws_task_id' => ' ',
                'is_time_off' => true,
                'was_notified' => false,
                'assign_date' => $start_date,
                'assign_end_date' => $end_date
            ])
        );
    } // end function
} // end trait

10th September, 2017

jgravois started a new conversation Submitting FormData Via Axios • 1 week ago

I am using vue-form-wizard for a large 5 panel form and the specs are that there are no “additional submit buttons” other than the wizard’s Next button … I have 4 of the 5 panels licked but the last panel is kicking my butt. It is a panel where 6 documents are uploaded. I wrapped just that panel in a form tag (the other panel submit via axios) like this:

<tab-content title="Documents" :before-change="docs_next">
      <form id="frmDocs" @submit.prevent="documentsUpload”>

docs_next is the method that this panel runs when the wizard’s next button is clicked

docs_next() { 
    document.getElementById('frmDocs').submit();
     return true;
 },
 documentsUpload() {
     alert('Form Submitting');
}

This is to test the submit and the alert is not firing. Any suggestions?

4th September, 2017

jgravois started a new conversation Dropdown Of Estimates Returns Null • 2 weeks ago

I need an array to create a dropdown where the values are like this

[ estimate: September 2017 ],
[ estimate: October 2017 ],
[ estimate: November 2017 ],
[ estimate: December 2017 ],
[ estimate: January 2018 ],
[ estimate: February 2018 ]

Always starting with current month and year and providing 5 additional options in mounted(), I have this.estimates = this.createEstimates(); and that method is

createEstimates() {
    let reporter = [];

     for(m=0; m<6; m++) {
         let newbie = {
             estimate: moment().add(m, 'months').format('MMMM YYYY')
         };
        reporter.push(newbie);
      } // end for
     return reporter;
}

however, this.estimates is null

2nd September, 2017

jgravois started a new conversation 'No Tests Found' Using Jest In New Laravel 5.5 Install • 3 weeks ago

I have a fresh install of Laravel 5.5.

I added the dependencies with

npm install --save-dev jest jest-vue-preprocessor babel-jest jsdom vue-server-renderer babel-preset-stage-2 bootstrap-sass

I added the normal snippets to package.json

"test": "./node_modules/.bin/jest"

and

"jest": {
    "transform": {
      "^.+\\.js$": "<rootDir>/node_modules/babel-jest",
      ".*\\.(vue)$": "<rootDir>/node_modules/jest-vue-preprocessor"
    }
  }

I added a .babelrc file at the root containing

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": ["transform-runtime"],
  "env": {
    "test": {
      "presets": ["env", "stage-2"],
      "plugins": ["istanbul"]
    }
  }
}

I added a tests folder to /resources/assets/js and added a test

npm test returns the following and I don't know what to try

No tests found
In /Users/jgravois/code/laravel55
  155 files checked.
  testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 0 matches
  testPathIgnorePatterns: /node_modules/ - 155 matches
Pattern: "" - 0 matches

26th August, 2017

jgravois started a new conversation OnChange Firing When Component Is Displayed Rather Than Changed ... Ugghhhh • 4 weeks ago

I have an @change on a dropdown and it is running when the component is displayed. Unfortunately there are over 400 companies so I have to endure 400 alerts … shouldn’t it only fire when the data is changed?

<div class="field">
    <div class="control">
        <div class="select">
            <select v-model="co.staff_id" @change="assign(co)">
                            <option value="">Please select...</option>
                <option :value="sp.id" v-for="sp in salesforce">
                    {{sp.name}}
                </option>
            </select>
        </div>
    </div>
</div>

and the method (for testing)

assign(obj) {
    alert('Change ' + obj.legal_name + ' to User Id ' + obj.staff_id);
}

21st August, 2017

jgravois started a new conversation Accessor Trying To Get Last Call -- BIG FAIL • 1 month ago

Given the follow relationship

public function calls()
    {
        return $this->hasMany(SalesCompanyTouch::class, 'company_id', 'id');
    } // end function

I need to get the latest record of this relationship so I have this accessor

public function getLastSaleContactAttribute()
    {
        $last_call = collect($this->calls());

        return $last_call->max('touch_date');
    } // end function

However it always returns null.

Any help is apprciated.

12th August, 2017

jgravois started a new conversation Struggling With Child/Parent Communication (in Vue.js That Is) • 1 month ago

I have a table and in each row there are icons for several trade references for each company. Clicking this icon pops up a modal. I really want to make the modal a child component since there is quite a bit of functionality.

<div class="modal" :class="{'is-active': showTraderModal}" @closeModal="toggleTradeModal">
    <tr-modal></tr-modal>
</div>

in the child component I have

toggleTradeModal() {  this.$emit('closeModal’); }

and in the parent

toggleTradeModal() {  this.showTraderModal = !this.showTraderModal; },

However, this never fires and the modal never closes. Is that not correct???

3rd August, 2017

jgravois started a new conversation Stopping The Base Table Already Exists Error After Package Install • 1 month ago

I installed a package yesterday that had its own migration and now when I try to add another migration, I am getting the Base Table already exists error. How can I resolve?

24th July, 2017

jgravois left a reply on Access A JQuery Variable Within A Vue.js Component • 1 month ago

props aren't an option but whether I load a hidden div with the value or store it as a global window object, I can't get the component to re-fetch new data ... meaning I assign to window.master_id and when I click the modal button, vue doesn't know to grab the fresh id ... I tried on created() and mounted() but apparently those are only triggered ONCE and not each time the modal is actually called. so, the first clicked modal is EMPTY and the 2nd, 3rd and 12,345th modal is always the data from the second-clicked row.

I am frustrated!!!!!

jgravois started a new conversation Access A JQuery Variable Within A Vue.js Component • 1 month ago

I have a huge dataset which I am paginating in blade. There is an edit button on each row to trigger an edit modal.

<button  type="link" 
               style="cursor: pointer;" 
               data-toggle="modal" 
               data-target="#editModal" 
               data-id="{{$master['id']}}">
      <i class="fa fa-pencil color-uam-blue"></i>
</button>

In jQuery I can grab the id

$(function() {
     $('#editModal').on("show.bs.modal", function (e) {
          let master_id = $(e.relatedTarget).data('id');
      });
});

The modal body is a custom vue component. My plan was to axios the single record and present an edit form.

I have tried to create a hidden div, fill its text attribute with the id and try to access it from there in the component -- FAIL! I have tried to stuff the id in localStorage and access it from vue there -- FAIL

I don't know what else to try to get the id into the component EACH TIME an edit button is clicked.

Any insight is GREATLY appreciated!!!

19th July, 2017

jgravois started a new conversation Pagination Woes: Losing The $masters->links() Functionality • 2 months ago

I need some pagination help … I have a table of 12,000+ records and without pagination, it is killing RAM. BUT I have to pass each through a transformer to process before loading and when I do the following I lose the $masters->link().

public function master_control()
    {
        $masters = [];
        $parts = EcoComponentMaster::where('description', '!=', 'DISCARDED')
            ->orderBy('model_value', 'desc')
            ->paginate(100);

        foreach($parts as $master) {
            $master = (new EcoComponentMastersTransformer)->transform($master);
            $masters[] = $master;
        } // end foreach

//        return $masters;

        return view('aeroeco.master_control', compact('masters'));
    } // end function

12th July, 2017

jgravois started a new conversation Trying To Grasp Parent-Child Communication • 2 months ago

I am emitting this from the child this.$emit('completed', this.index, rsp.data);

This is the reference in the parent

<single-part v-for="(part, idx) in parts"
            v-show="idx === cntPart"
            :single_part="part" :index="idx"
            @completed="completePart(i, p)"
></single-part>
                                        

The method in the parent

completePart(index, part) {
    alert('Emited index:' + index);
}

index is undefined

30th June, 2017

jgravois started a new conversation Vuex Initiation And Conditional Reload • 2 months ago

I am working on an application with HUGE datasets. I discovered VUEX and thought I could save users long waits so I added the store initialization to the navbar (since it is omnipresent throughout the app). The initial load time for the homepage jumped to 8 minutes.

I was also bothered by the fact that a user wanting to jump online just to reserve a company vehicle had to endure the loading of all of the modeling data ... just not right.

I have been looking all week for the correct way to load data to the store when needed and then used that data wherever appropriate. However, I can solve the means of determining IF the data is in the store or not and it hits the database again every time those pages are loaded.

If anyone has insights or a resource or an example of doing this correctly, I would greatly appreciate the sharing.

Thanks in advance!

20th June, 2017

jgravois started a new conversation Try-Catch Not Stopping CURL Error 60: SSL Certificate Problem: Invalid Certificate Chain Exception • 3 months ago

I am getting an exception in our uptime monitor that is breaking the monitor rather than returning a "false" to trigger a notification and a 'red light' in our dashboard.

I THOUGHT I would handle the exception with the code below but it is not working

public function fetch($path)
    {
        try {
            $response = $this->client->get($path, ['http_errors' => false]);
            return $response->getStatusCode();
        } catch (\GuzzleHttp\Exception\ConnectException $e) {
            Log::error('Received error: ' . $e->getMessage());
            return false;
        } catch (Exception $e) {
            Log::error('Received error: ' . $e->getMessage());
            return false;
        }
    } // end function

Any thoughts?

11th June, 2017

jgravois started a new conversation Laravel 5.4 Testing Using Transactions -- Wrong Database • 3 months ago

We have far too many migrations to use database migrations (because they really slow the testing down and then the developers don't test), so I am trying to move to use database transactions meaning moving from sqlite in :memory: to a sibling mysql database. However using the setup below, I am pulling from our production database rather than the new testing database.

#config/database.php

'mysql' => [
   'driver' => 'mysql',
   'host' => env('DB_HOST', '127.0.0.1'),
   'port' => env('DB_PORT', '3306'),
   'database' => env('DB_DATABASE', 'forge'),
   'username' => env('DB_USERNAME', 'root'),
   'password' => env('DB_PASSWORD', ''),
   'charset' => 'utf8mb4',
   'collation' => 'utf8mb4_unicode_ci',
   'prefix' => '',
   'strict' => true,
   'engine' => null,
 ],

 'mysql2' => [
     'driver' => 'mysql',
     'host' => env('DB2_HOST', '127.0.0.1'),
     'port' => env('DB2_PORT', '3306'),
     'database' => env('DB2_DATABASE', 'forge_test'),
     'username' => env('DB2_USERNAME', 'root'),
     'password' => env('DB2_PASSWORD', ''),
     'charset' => 'utf8mb4',
     'collation' => 'utf8mb4_unicode_ci',
     'prefix' => '',
     'strict' => true,
     'engine' => null,
  ],

#.env file

DB_CONNECTION=mysql
DB_HOST=--mask--
DB_PORT=3306
DB_DATABASE=--mask--
DB_USERNAME=--mask--
DB_PASSWORD=--mask--

#phpunit.xml

<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="mysql2"/>
<env name="DB_DATABASE" value="--mask--_test"/>

So to confirm, I modified the name field in the test database and ran this simple test

/** @test */
public function a_user_can_successfully_log_in()
{
        $this->disableExceptionHandling();
        $this->user = User::find(1);
        echo $this->user->name;

        $this->assertTrue(true);
}

and the output is definitely the version in the production DB

10th June, 2017

jgravois left a reply on A_guest_can_see_nothing_but_login • 3 months ago

@CodebyRay Thanks for the advice but, again, our developer/style guide dictates we apply it by constructor. That "guide" unfortunately was written by the VP of Technology whose only coding experience is with dot.net.nuke.

So, regardless of "a better way," I still need to develop a test that protects us from a repeat of my colleague's plunder.

jgravois left a reply on A_guest_can_see_nothing_but_login • 3 months ago

making progress ...

/** @test */
    function unauthenticated_users_may_not_see_anything_except_login()
    {
        $routeCollection = Route::getRoutes();

        foreach ($routeCollection as $value) {
            $value->withExceptionHandling()
                ->get($value->uri)
                ->assertRedirect('/login');
        }
    }

However, the test FAILS because "Call to undefined method Illuminate\Routing\Route::withExceptionHandling()"

jgravois left a reply on A_guest_can_see_nothing_but_login • 3 months ago

@Snapey excellent idea!!!

however, the execution of the idea may still be above my abilities.

I can't figure out how to loop through them. When I do the following, I get 0

$all_routes = Artisan::call('route:list');
echo $all_routes;

jgravois left a reply on A_guest_can_see_nothing_but_login • 3 months ago

@tjcasner We are using the auth middleware to separate guests from authenticated users and our developer/style guide dictates we apply it by constructor.

@Thyrosis if the colleague forgets to add the routes to the all routes array, we are in the same pickle.

My question was if there was a possible "wildcard" for ALL routes that could be used in testing to prevent a colleague from forgetting to add that in the constructor.

jgravois left a reply on A_guest_can_see_nothing_but_login • 3 months ago

we have run make:auth a while ago

jgravois started a new conversation A_guest_can_see_nothing_but_login • 3 months ago

In working on our Intranet, one of my colleagues forgot to include the auth middleware so for an entire week, we had exposed pages. Without authentication, only the login page should be accessible.

Is there a way to add a test that catches ALL ROUTES EXCEPT login and ensure a redirect? We have a large number of routes and I don't want my weekend to be about writing tests for EACH nor do we want such an omission as above to occur again.

Thanks in advance!

6th June, 2017

jgravois left a reply on Vue-Router Query Not Recognized • 3 months ago

I figured it out ... thanks!

jgravois started a new conversation Vue-Router Query Not Recognized • 3 months ago

I have a large listing of items each with an "expanded" attribute set to false by the model.

If ?id=## is not appended to the path, I need all collapsed -- works! if there is an ?id=##, I need to expand the corresponding row (so the executive know which on to approve (even though there is a filter provided)).

I added the following computed property but all rows remain collapsed

filtered_returns() {
                if(this.returns) {
                    if (this.search && this.search.length === 0) {
                        if(this.$route.query && this.$route.query != undefined) {
                            alert(this.$route.query.id);
                            _.each(this.returns, function(r) {
                                if(r.id == this.$route.query.id) {
                                    r.expanded = true;
                                } //end if
                            });
                            return this.returns;
                        } else {
                            return this.returns;
                        } // end if
                    } else {
                        return this.returns.filter((rma) => {
                            return rma.company_name.toLowerCase().indexOf(this.search.toLowerCase()) !== -1
                        });
                    } //end if
                } // end if
            }

29th May, 2017

jgravois left a reply on Vue 2.0 Filter To Show Elapsed Seconds As 00:00:00 Format • 3 months ago

oops ... 60 * 60 = 3600

jgravois started a new conversation Vue 2.0 Filter To Show Elapsed Seconds As 00:00:00 Format • 3 months ago

I am trying to create a filter for vue 2 that takes elapsed seconds and displays 00:00:00 (hours, mins and seconds). However, the value I am testing is 7200 (which should be 02:00:00) and it is displaying 20:00:00. Any fresh eyes to spot my mistake?

Vue.filter('timeInHours', function(value) {
    let hours =  parseInt(Math.floor(value / 360)); 
    let minutes = parseInt(Math.floor((value - (hours * 360)) / 60)); 
    let seconds= parseInt((value - ((hours * 360) + (minutes * 60))) % 60); 

    let dHours = (hours > 9 ? hours : '0' + hours);
    let dMins = (minutes > 9 ? minutes : '0' + minutes);
    let dSecs = (seconds > 9 ? seconds : '0' + seconds);

    return dHours + ":" + dMins + ":" + dSecs;
});

jgravois left a reply on Can Get Boolean But Can't Get Date From Collection • 3 months ago

@stanb thank you, that is exactly the code needed!

jgravois started a new conversation Can Get Boolean But Can't Get Date From Collection • 3 months ago

I have an indefinite list of certificates that a technician can use. I store them in a pivot table of techs and certs.

I am trying to create a certs attribute on the user. If I just try to return booleans, it works perfectly but if uncomment //$arrCerts[$award['slug']] = $fnd[0]->original['award_date']; and try to return the award date, I get this exception

ErrorException in Collection.php line 1456:
Undefined offset: 0

This is the method

public function getCertsAttribute()
    {
        $arrCerts = [];
        $certs = $this->certificates;

        $awards = EcoTechCertificate::all();

        foreach($awards as $award) {
            if($certs->contains('certificate_id', $award->id)) {
                $fnd = $certs->where('certificate_id', $award->id);
                $arrCerts[$award['slug']] = true;
                //$arrCerts[$award['slug']] = $fnd[0]->original['award_date'];
            } else {
                $arrCerts[$award['slug']] = false;
            } // end if
        } // end foreach

        return collect($arrCerts);
    } // end function

28th May, 2017

jgravois started a new conversation BelongsToMany Is Still A Mystery To Me • 3 months ago

I have a table of master components (eco_component_masters). The components in that table can be found on many different aircraft series (eco_ac_families) so I need a pivot table (eco_ac_component_families).

When I query the pivot table for a count, I get 681 records. This is that model

public function part_count($id)
    {
        return EcoAcComponentFamily::where('family_id', $id)->count();
    } // end function

If the user requests, I have to grab those components so I set up the this relationship in the EcoAcFamily model.

public function masters()
    {
        return $this->belongsToMany(EcoComponentMaster::class, 'eco_ac_component_families', 'component_id', 'family_id');
    } // end function

Now in the controller to return the master components related to a specific family, I have this method

public function parts_by_ata($id)
    {
        $family = EcoAcFamily::with('masters')->whereId($id)->first();

       return $family;
    } // end function

That method return TWO (2) master components not the 681 I expected.

Clearly I have yet to grasp the intricacies of the pivot despite watching all three videos on the subject. Any help is greatly appreciated.

27th May, 2017

jgravois left a reply on Update Nulling All Values In Database • 3 months ago

THANKS!

var_dump showed me what's wrong.

I did this and it works

public function update($id, Request $request)
{
        $data = (object) $request->json()->all();
        $project = AdcProject::whereId($id)->first();
    
    $project->contact->company = $data->contact['company'];
        $project->contact->firstname = $data->contact['firstname'];
        $project->contact->lastname = $data->contact['lastname'];
        $project->contact->title = $data->contact['title'];
        $project->contact->email = $data->contact['email'];
        $project->contact->save();

    $updated = AdcProject::whereId($id)->first();
    return $updated;
}

jgravois left a reply on Update Nulling All Values In Database • 3 months ago

"<script> Sfdump = window.Sfdump || (function (doc) { var refStyle = doc.createElement('style'), rxEsc = /([.*+?^${}()|\[\]\/\\])/g, idRx = /\bsf-dump-\d+-ref[012]\w+\b/, keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl', addEventListener = function (e, n, cb) { e.addEventListener(n, cb, false); }; (doc.documentElement.firstElementChild || doc.documentElement.children[0]).appendChild(refStyle); if (!doc.addEventListener) { addEventListener = function (element, eventName, callback) { element.attachEvent('on' + eventName, function (e) { e.preventDefault = function () {e.returnValue = false;}; e.target = e.srcElement; callback(e); }); }; } function toggle(a, recursive) { var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass; if ('sf-dump-compact' == oldClass) { arrow = '&#9660;'; newClass = 'sf-dump-expanded'; } else if ('sf-dump-expanded' == oldClass) { arrow = '&#9654;'; newClass = 'sf-dump-compact'; } else { return false; } a.lastChild.innerHTML = arrow; s.className = newClass; if (recursive) { try { a = s.querySelectorAll('.'+oldClass); for (s = 0; s < a.length; ++s) { if (a[s].className !== newClass) { a[s].className = newClass; a[s].previousSibling.lastChild.innerHTML = arrow; } } } catch (e) { } } return true; }; return function (root, x) { root = doc.getElementById(root); var indentRx = new RegExp('^('+(root.getAttribute('data-indent-pad') || ' ').replace(rxEsc, '\\$1')+')+', 'm'), options = {"maxDepth":1,"maxStringLength":160,"fileLinkFormat":false}, elt = root.getElementsByTagName('A'), len = elt.length, i = 0, s, h, t = []; while (i < len) t.push(elt[i++]); for (i in x) { options[i] = x[i]; } function a(e, f) { addEventListener(root, e, function (e) { if ('A' == e.target.tagName) { f(e.target, e); } else if ('A' == e.target.parentNode.tagName) { f(e.target.parentNode, e); } else if (e.target.nextElementSibling && 'A' == e.target.nextElementSibling.tagName) { f(e.target.nextElementSibling, e, true); } }); }; function isCtrlKey(e) { return e.ctrlKey || e.metaKey; } addEventListener(root, 'mouseover', function (e) { if ('' != refStyle.innerHTML) { refStyle.innerHTML = ''; } }); a('mouseover', function (a, e, c) { if (c) { e.target.style.cursor = "pointer"; } else if (a = idRx.exec(a.className)) { try { refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}'; } catch (e) { } } }); a('click', function (a, e, c) { if (/\bsf-dump-toggle\b/.test(a.className)) { e.preventDefault(); if (!toggle(a, isCtrlKey(e))) { var r = doc.getElementById(a.getAttribute('href').substr(1)), s = r.previousSibling, f = r.parentNode, t = a.parentNode; t.replaceChild(r, a); f.replaceChild(a, s); t.insertBefore(s, r); f = f.firstChild.nodeValue.match(indentRx); t = t.firstChild.nodeValue.match(indentRx); if (f && t && f[0] !== t[0]) { r.innerHTML = r.innerHTML.replace(new RegExp('^'+f[0].replace(rxEsc, '\\$1'), 'mg'), t[0]); } if ('sf-dump-compact' == r.className) { toggle(s, isCtrlKey(e)); } } if (c) { } else if (doc.getSelection) { try { doc.getSelection().removeAllRanges(); } catch (e) { doc.getSelection().empty(); } } else { doc.selection.empty(); } } else if (/\bsf-dump-str-toggle\b/.test(a.className)) { e.preventDefault(); e = a.parentNode.parentNode; e.className = e.className.replace(/sf-dump-str-(expand|collapse)/, a.parentNode.className); } }); elt = root.getElementsByTagName('SAMP'); len = elt.length; i = 0; while (i < len) t.push(elt[i++]); len = t.length; for (i = 0; i < len; ++i) { elt = t[i]; if ('SAMP' == elt.tagName) { elt.className = 'sf-dump-expanded'; a = elt.previousSibling || {}; if ('A' != a.tagName) { a = doc.createElement('A'); a.className = 'sf-dump-ref'; elt.parentNode.insertBefore(a, elt); } else { a.innerHTML += ' '; } a.title = (a.title ? a.title+'\n[' : '[')+keyHint+'+click] Expand all children'; a.innerHTML += '<span>&#9660;</span>'; a.className += ' sf-dump-toggle'; x = 1; if ('sf-dump' != elt.parentNode.className) { x += elt.parentNode.getAttribute('data-depth')/1; } elt.setAttribute('data-depth', x); if (x > options.maxDepth) { toggle(a); } } else if ('sf-dump-ref' == elt.className && (a = elt.getAttribute('href'))) { a = a.substr(1); elt.className += ' '+a; if (/[\[{]$/.test(elt.previousSibling.nodeValue)) { a = a != elt.nextSibling.id && doc.getElementById(a); try { s = a.nextSibling; elt.appendChild(a); s.parentNode.insertBefore(a, s); if (/^[@#]/.test(elt.innerHTML)) { elt.innerHTML += ' <span>&#9654;</span>'; } else { elt.innerHTML = '<span>&#9654;</span>'; elt.className = 'sf-dump-ref'; } elt.className += ' sf-dump-toggle'; } catch (e) { if ('&' == elt.innerHTML.charAt(0)) { elt.innerHTML = '&hellip;'; elt.className = 'sf-dump-ref'; } } } } } if (0 >= options.maxStringLength) { return; } try { elt = root.querySelectorAll('.sf-dump-str'); len = elt.length; i = 0; t = []; while (i < len) t.push(elt[i++]); len = t.length; for (i = 0; i < len; ++i) { elt = t[i]; s = elt.innerText || elt.textC…/span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>962</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>963</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>964</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>965</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>966</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>967</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>968</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>969</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>970</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>971</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>972</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>973</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>974</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>975</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>976</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>977</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>978</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>979</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>980</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>981</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>982</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>983</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>984</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>985</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>986</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>987</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>988</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>989</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>990</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>991</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>992</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>993</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>994</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>995</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>996</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>997</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>998</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>999</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1000</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1001</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1002</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1003</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1004</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1005</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1006</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1007</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1008</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1009</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵    <span class=sf-dump-index>1010</span> => <span class=sf-dump-note>array:18</span> [ &hellip;18]↵  </samp>]↵</samp>]↵</pre><script>Sfdump("sf-dump-1240214518")</script>

jgravois left a reply on Update Nulling All Values In Database • 3 months ago

not really sure

It is an axios patch from a vue component

jgravois started a new conversation Update Nulling All Values In Database • 3 months ago

I am patching a payload to an update method and I return request()->all() to see what's hitting the server.

The data looks like this:

data: Object
    contact: Object
        company: "blah"
        title: "blah
        firstname: "blah"
        lastname: "blah"
        email: "blah"

Since it is an object of objects, I am handing it as such

public function update($id)
{
        $project = Project::whereId($id)->first();

    $project->contact->company = request('contact->company');
        $project->contact->firstname = request('contact->firstname');
        $project->contact->lastname = request('contact->lastname');
        $project->contact->title = request('contact->title');
        $project->contact->email = request('contact->email');
        $project->contact->save();

    $updated = Project::whereId($id)->first();
        return $updated;

}

The data patched is not in the database but all fields are null;

Am I not handling the data properly?

19th May, 2017

jgravois left a reply on NPM Dev And NPM Watch GONE After Move To Laravel Valet • 4 months ago

Relieved and Red-Faced

My terminal alias was pointing to the OLD version in the "other" code directory (~/Documents/Code) instead of the "new" code directory (~/code).

npm run works when I am in the RIGHT directory!

jgravois started a new conversation NPM Dev And NPM Watch GONE After Move To Laravel Valet • 4 months ago

Last weekend I finally ditched MAMP PRO and installed Laravel Valet. I couldn't be happier and have worked fine all week until this morning. I tried to run npm run watch and got this message

npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/bin/node" "/Users/jgravois/.npm-packages/bin/npm" "run" "watch"
npm ERR! node v6.10.3
npm ERR! npm  v4.0.2

npm ERR! missing script: watch

I loaded the latest versions of npm and node and updated to the latest version of Laravel Mix.

I then tried to run npm run dev so I could at least see my changes and now I get this

> @ dev /Users/jgravois/Documents/Code/teamsite
> gulp watch

[08:12:32] Using gulpfile ~/Documents/Code/teamsite/gulpfile.js
[08:12:32] Starting 'watch'...
[08:12:32] Starting 'browserify'...

Fetching Browserify Source Files...
   - resources/assets/js/main.js


Saving To...
   - public/js/main.js

[08:12:33] Finished 'browserify' after 597 ms
[08:12:33] Finished 'watch' after 956 ms
[08:12:38] 984952 bytes written (4.24 seconds)
[08:12:38] gulp-notify: [Laravel Elixir] Browserify Compiled!

OMG ... LOL .... I don't HAVE a gulpfile ... I have a webpack.mix.js file. AND I don't have Elixir installed ... I have Mix.

My site in the browser won't load with the following in the console

app.js:101750 Uncaught Error: Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/jgravois/code/teamsite/node_modules/vue2-google-maps"
    at /Users/jgravois/code/teamsite/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19

13th May, 2017

jgravois started a new conversation MAMP To VALET (finally) ... Wrong PHP • 4 months ago

finally made the switch from MAMP PRO to Laravel Valet but I think the php.ini is still using the Mamp version … anyone know how I can check/fix?

30th April, 2017

jgravois started a new conversation Sum Of VERY Nested Relationship • 4 months ago

I have a structure of PHASES hasMany MILESTONES hasMany TASKS hasMany STEPS.

Only in STEPS do I store an est_time field in minutes.

To calculate TOTAL ESTIMATED TIME for each TASK, I added a mutator to the TASK class and return in with a protected $appends

public function getCalculatedTimeEstimateAttribute()
    {
        return $this->subtasks->sum('est_time')/60;
    } // end function

Works fine!

I need to calculate the TOTAL ESTIMATED TIME for MILESTONES as well as PHASES

I don't know the formula to do those to put into the mutators.

23rd April, 2017

jgravois left a reply on InvalidArgumentException In Carbon.php Line 582: Unexpected Data Found. Unexpected Data Found. Trailing Data • 5 months ago

DOB is a date column.

THIS is absolutely elegant.

I dream of the day when I get good enough to "see" this as a solution before I reach for procedural code.

THANK YOU FOR YOUR TIME!!!

22nd April, 2017

jgravois left a reply on InvalidArgumentException In Carbon.php Line 582: Unexpected Data Found. Unexpected Data Found. Trailing Data • 5 months ago

did not know of a way to use where for between dates because it isn't equality (so glad for Carbon's is_birthday)

jgravois left a reply on InvalidArgumentException In Carbon.php Line 582: Unexpected Data Found. Unexpected Data Found. Trailing Data • 5 months ago

I had a getter that sets the date format to 'm/d/y' so this works perfectly when I dump a user from the api

public function getIsBirthdayAttribute()
    {
        if(!$this->dob) {
            return false;
        } else {
            $bd = Carbon::createFromFormat('m/d/Y', $this->dob);
            return $bd->isBirthday(Carbon::today());
        } // end if
    } // end function

HOWEVER,

from the controller (where I am trying to get all users whose birthdays are in the next seven days), I get a NEW error:

Exception in Response.php line 70:
Failed calling Illuminate\Database\Eloquent\Collection::jsonSerialize()

this is in the controller:

foreach($active_users as $u) {
            if($u->dob && $u->dob != NULL) {
                $bd = Carbon::createFromFormat('m/d/Y', $u->dob);
                for($d=1; $d<8; $d++) {
                    if($bd->isBirthday(Carbon::today()->addDays($d))) {
                        $bdays[] = $u;
                    } // end if
                } // end for
            } // end if
        } // end foreach

jgravois left a reply on InvalidArgumentException In Carbon.php Line 582: Unexpected Data Found. Unexpected Data Found. Trailing Data • 5 months ago

I have it in the protected $dates array in the User class and I am specifically casting it with protected $casts = ['dob' => 'date'];.

jgravois started a new conversation InvalidArgumentException In Carbon.php Line 582: Unexpected Data Found. Unexpected Data Found. Trailing Data • 5 months ago

I am trying to append an is_birthday boolean onto my users via an attribute and I am getting this error:

InvalidArgumentException in Carbon.php line 582: 
Unexpected data found. 
Unexpected data found. 
Trailing data

However, I thought I had covered that below -- the format in the database record is 2017-04-22

public function getIsBirthdayAttribute()
    {
        $bd = Carbon::createFromFormat('Y-m-d', $this->dob);
        if($bd->isBirthday(Carbon::today())) {
            return true;
        } else {
            return false;
        }// end if
    } // end function

20th April, 2017

jgravois started a new conversation Marking Dates In Vuejs-datepicker • 5 months ago

The vuejs-datepicker package is the closest package I have found to my needs but it lacks one essential functionality that I am hoping someone can point me to the applicable research to achieve.

I plan on using an inline datepicker so it shows without clicking. I NEED to "mark" dates as they are clicked (axios will save/delete that "event" in the database) because I need to set up an "availability" chart meaning when a date is clicked, that worker is not available for assignment or a previous block is removed.

Is this package the best candidate for this or is there something else I should use.

ANY suggestions are GREATLY appreciated!!!

Edit Your Profile
Update

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