calebporzio

Web Developer at Tighten Co,

Hire Me

Experience

13,810

4 Best Reply Awards

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

27th January, 2016

calebporzio left a reply on Vue Resource Delete Task • 1 year ago

Before you initialize the Vue instance you need to include this:

Vue.http.headers.common['X-CSRF-TOKEN'] = <?php echo csrf_token(); ?>;

when you submit a standard form and the csrf middleware is enabled, you have to include the csrf token as a hidden input field. When submitting data via the vue-router, you need to include it in the request header using the above code.

Hope that helps.

12th January, 2016

calebporzio left a reply on Simple Full Screen Mode In MacVim • 1 year ago

Thanks @JeffreyWay, worked perfectly.

BTW, a vim mastery tutorial from you especially with your new thoughts after returning from sublime would be amazing. I know there is already a ton out there, but I would love to see your take on things in depth.

calebporzio started a new conversation Simple Full Screen Mode In MacVim • 1 year ago

I have been trying out MacVim because Jeffrey is switching over. I really like his "Make sublime pretty" tutorial where he outlines how to enable simple full screen mode in sublime. I would like this same effect in MacVim (basically full screen but not in a separate workspace).

Anybody have any ideas? Thanks!

16th December, 2015

calebporzio left a reply on Custom Directive Prevent Default For Onclick • 1 year ago

Thanks @thomaskim for the correct response. Worked like a charm.

@bobbybouwmann - I wanted to extract it in a custom directive so I can use it throughout my app to easily restrict actions if a user is not subscribed. Thanks for your help as well.

calebporzio left a reply on Custom Directive Prevent Default For Onclick • 1 year ago

So, is it possible to achieve what I am looking for? I am looking to disable an @click event from a custom directive conditionally.

Thanks for all your help @bobbybouwmann

calebporzio left a reply on Custom Directive Prevent Default For Onclick • 1 year ago

@bobbybouwmann - I tried it in and out of the if statement

calebporzio left a reply on Custom Directive Prevent Default For Onclick • 1 year ago

@bobbybouwmann - thanks for your reply. I tried preventDefault, stopPropagation, and return false to no avail.

None of those options seems to be working. I suppose I should make a quick jsFiddle to further debug.

Any other ideas? Thanks for all the help.

calebporzio started a new conversation Custom Directive Prevent Default For Onclick • 1 year ago

I am trying to create a custom directive to restrict functionality if a user is not subscribed. I have an element like the following:

<button @click="doSomething" v-restrict>Do Something</button>

here's my custom directive:

Vue.directive('restrict', {
    bind: function() {
        this.el.addEventListener('click', function(event) {
            if ( [user is not subscribed] ) {
                event.stopProgagation();
                // do something
            }
        }
    }
});

If I click on the button with the directive, the code within the event listener is executed and then the "@click" function is run. Is there a way to stop the click event from traveling any further after the custom directive? My stopPropagation doesn't seem to do any good.

Hope that made sense, any solutions, thoughts, or ideas?

16th November, 2015

calebporzio started a new conversation HasManyThrough Not Working • 1 year ago

Hey there, I have three eloquent models: opportunities, criteria, and metrics. Here are there relationship functions: opportunity:

public function criteria()
    {
        return $this->hasMany('App\Models\OpportunityCriteria');
    }

criteria:

public function outletMetric()
    {
        return $this->belongsTo('App\Models\Outlets\OutletMetric');
    }

metric:

public function criteria()
    {
        return $this->hasMany('App\Models\OpportunityCriteria');
    }

Does anyone have any idea how I would do a hasManyThrough from OutletMetric to Opportunity. Currently, an OutletMetric has many OpportunityCriteria, and OpportunityCriteria has one Opportunity. How would I relate: OutletMetric has many Opportunities through OpportunityCriteria.

I have tried this and it did not work:

        return $this->hasManyThrough('App\Models\Opportunity', 'App\Models\OpportunityCriteria');

Any help is GREATLY appreciated.

Thanks

calebporzio left a reply on Complicated Validation In Request, Which Isn't For Field Exactly • 1 year ago

@sharrpenized I recently came accross a similar problem. Here is my solution. May not be exactly what your looking for but worked well for me:

Put this in your Controller (the file your controllers extend)

protected function addValidationRule($request, $name, $message, $callback)
    {
        if (! call_user_func($callback)) {
            $this->throwException($request, $name, $message);
        }
    }

    protected function throwException($request, $name, $message)
    {
        throw new HttpResponseException($this->buildFailedValidationResponse(
            $request, [$name => [$message]]
        ));
    }

Then I have a method in my controller like this:

public function validateForm($request, $campaign = null)
    {
        $this->validate($request, [
            'someNormalField' => 'required',
    ]

        $this->additionalRule($request);
    }

public function additionalRule($request)
    {
        $message = 'Some custom error message';

        $this->addValidationRule($request, 'name of error bag key', $message, function() use ($request) {
            if ([you want to pass through]) {
        return true;
        } else {
        return false;
        }
        });
    }

Hope that helps. You can always pass extra objects into the "addValidationRule" closure param to check the request against eloquent models or something.

I like this solution because it just hooks into Laravel's existing error bag thats get sent back via json if its an ajax request and redirects back with input if its not. Good Luck!

14th November, 2015

calebporzio left a reply on Flash Messaging In Vue • 1 year ago

Sweetalert it is! That looks awesome, thanks everyone!

13th November, 2015

calebporzio left a reply on Flash Messaging In Vue • 1 year ago

I don't think you are correct, I just tried adding this code into the controller that handles the ajax request:

session()->flash('status', 'Success Message');
return new JsonResponse($something, 200);

To no avail. Also, I did test the the receiving page would display that flash message 'status'.

calebporzio left a reply on Flash Messaging In Vue • 1 year ago

I am using Laravel, but how would I do that if I am redirecting using javascript for ajaxy form handling.

calebporzio started a new conversation Flash Messaging In Vue • 1 year ago

Hey There,

So, if I am handling a form submission with Vue and upon successful submission via something like: this.$http.post - I redirect to another page on the site showing the results of the submission with a success message. Right now upon success I am doing this:

this.$http.post('/some/route', someData, function(response) {
    location.href = '/some/new/route';
}

How would I pass a success message to be retrieved on the next page for the one request.

Thanks, Caleb

calebporzio left a reply on Eloquent Sync Relations Question • 1 year ago

@ehsanquddusi : Ya, that's what I ended up doing, Its not as elegant as a sync. But that works, thanks!

calebporzio started a new conversation Eloquent Sync Relations Question • 1 year ago

Question on the best way to write this in Eloquent: I have 2 models that are related by one to many (pseudo code):

post->hasMany(comments)
comment->belongsTo(post)

I want have a form where I can add or remove as many model2s as I want. How would I sync them to model1. My understanding is ->sync(ids) is only available for many to many relations. What would be the equivalent rather than me looping through the entered model2s and checking if they are in the database, if they are not insert them, if they are leave them, and if there are some in the database and not in the form destroy them. Seems like a lot of queries for my purposes.

Any help is greatly appreciated. To help I will write something I would like to be able to do:

$comments = $request->input('comments');
$post->comments()->sync($comments->pluck('id'));

Thanks in advance :)

12th November, 2015

calebporzio left a reply on Alias For A URL Route • 1 year ago

  1. You could make it short in the first place, or you could always create another route and redirect like so:
Route::('/short/url', function (){
        return redirect('very/long/URL/and/long/really');
});

Maybe provide the actual use case?

calebporzio left a reply on Laravel Form Validation From Client Side Using Laravel Form Request + Ajax Submit • 1 year ago

Can you post the exact error message?

Also post some info: what laravel version are you on? This package requires at least 5.0.

Thanks, Caleb

calebporzio left a reply on How To Disable A Bootstrap Button In Vue 1.0 • 1 year ago

Found the solution:

<button class="btn" :disabled="someComputedProperty">

if "someComputedProperty" resolves to true, the disabled attr will show up, if false it won't.

Thanks, Caleb

calebporzio left a reply on How To Disable A Bootstrap Button. • 1 year ago

@bobbybouwmann : Thanks for the suggestion, however the "v-attr" directive is not available in Vue 1.0

Thanks, Caleb

calebporzio started a new conversation How To Disable A Bootstrap Button. • 1 year ago

Ok, very simple question here:

How would I get vue to help me do this when a computed property is true:

<button class="btn">

and this when it if false:

<button class="btn">

Seems like such a simple task and I'm sure I've come across this before, help please?

Thanks, Caleb

11th November, 2015

calebporzio left a reply on What Do We Do About Vue Latency? • 1 year ago

Great suggestions, I will start using v-text. I like the look of mustache bindings in the code better but will definitely switch it up.

Now what about retrieving data via this.$http.get vs. rendering it in the html from laravel. This seems like a latency issue others may have encountered, any suggestions? What are people doing?

10th November, 2015

calebporzio left a reply on What Do We Do About Vue Latency? • 1 year ago

Thanks @Bloomanity, that is definitely something to utilize.

Just to make sure, are there any more comprehensive solutions? what are other people using, just v-cloak? v-cloak on the whole page or just the specific part? Any more thoughts on this?

calebporzio started a new conversation What Do We Do About Vue Latency? • 1 year ago

So, I am using vue in a new project and absolutely loving it. Only one complaint (that I'm sure there are sensible answers to):

If I have a title on a page loaded by vue, it takes a split second (sometimes longer depending) to load. So the title will show "@{{ title }}" first and then load the proper title.

How are we to deal with vue latency, especially if you are grabbing resources via vue-resource or something like that. loading sprites everywhere? What are my options.. is this just something we have to deal with?

Thanks, Caleb

calebporzio left a reply on Composer Update On Deployment • 1 year ago

Ok, I think I see now, the composer lock file would be update on the server as well. All good.

Thanks, Caleb

calebporzio left a reply on Composer Update On Deployment • 1 year ago

Thanks for the replies. I think we are on the right track, but If I "composer install" it says nothing to install or remove because it is checking the Lock file. Any thoughts? I can run composer .update and it will re-write the lock file.

Thoughts?

calebporzio started a new conversation Composer Update On Deployment • 1 year ago

So... If I install a package for instance: "laracasts/utilities", I am supposed to add the require line to composer.json and add the service provider to app.php: /Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class

If I add the class to the service provider list and then run the command "composer update" it gives me an error because that class is not found. No problem, comment out that line, install the package, uncomment the line and we are all set.

However, when I deploy the code and run a composer update on the staging / production server it will throw that error and I don't want to have to modify code other than just updating the code with git pull.

I hope that made sense. Kind of a chicken before egg thing, seems someone must have a good solution to this.

Thanks, Caleb

4th November, 2015

calebporzio left a reply on Help With User Authentication • 1 year ago

From what I can tell, you should determine the current user based on the access token in the middleware, then retrieve the current user.

Hope that answered your question. I am a bit unclear on what your are asking.

14th October, 2015

calebporzio left a reply on Vue Is Not Defined! $ Is Not Defined! What Am I Doing Wrong? • 1 year ago

@notanerddev, I can't recall exactly why I added the global to jquery. Probably to make it available for some other jquery plugin I required. Don't really have a good answer. But in your case you could skip that step.

calebporzio left a reply on L5 Polymorphic Relationship - Table Doesn't Exist Error • 1 year ago

Right, of course. I think it is looking for the pivot table described in the docs:

posts
    id - integer
    name - string

videos
    id - integer
    name - string

tags
    id - integer
    name - string

taggables
    tag_id - integer
    taggable_id - integer
    taggable_type - string

calebporzio started a new conversation Testing Multiple Select • 1 year ago

To test a select box, I would typically do this:

$this->select('value', 'inputName');

How would one test a multiple select with an array of inputs? Something like:

$this->select(['value1', 'value2', 'value3'], 'inputName[]');

I know some others have asked similar questions on here but have come up dry, any ideas?

calebporzio left a reply on Vue Is Not Defined! $ Is Not Defined! What Am I Doing Wrong? • 1 year ago

Hey There,

Can you post your app.js file? I ran into these areas early on. Below is my app.js file that solved my issues:

global.jQuery = require('jquery');
var $ = global.jQuery;
window.$ = $;

and for Vue:

var Vue = require('vue');
var validator = require('vue-validator');
var resource = require('vue-resource');
window.Vue = Vue;

Vue.use(validator);
Vue.use(resource);

That should solve your problem, thanks. The problem is that Vue and $ are not available to globally to the browser, they are contained by browserify. Attaching them to the window element makes them available.

calebporzio left a reply on L5 Polymorphic Relationship - Table Doesn't Exist Error • 1 year ago

Hey There,

It looks like you need a

return $this->morphOne('App\Image', 'imageable');

instead of

return $this->morphMany('App\Image', 'imageable');

6th October, 2015

calebporzio left a reply on Help With Database Design • 1 year ago

Hmm.. thank you guys for the input. @martinbean I like your solution, it's simple. As long as thats what is required for each api.

Now another related question while I have your ear. How would you go about storing reports from the apis? have a separate table for each report type: i.e. ga reports, facebook reports, etc.. related to users? Do you see any issues with that? How would you go about it?

Thanks

calebporzio left a reply on Help With Database Design • 1 year ago

Would you mind addressing my concern?

calebporzio started a new conversation Help With Database Design • 1 year ago

I am in the process of building a new application. This application requires users to add "outlets" (any sort of online platform for influence: blog, facebook, twitter, pinterest, etc...). Then we will take these outlets, and generate stats on how popular the user is.

I looking to essentially have a base class: Outlet, with subclasses: FacebookOutlet, TwitterOutlet, etc...

How would you structure your database / eloquent models for a task like this. It seems I am looking for some kind of Database Inheritance. Here are the different options I have come across:

  • STI (single table inheritance ): This seems to be a poor solution given there would be many null fields in each row because there is not a significant amount of field overlap.

  • Polymorphic Relationships: This one seems to probably be the most fitting example, the only problem however is this is not pure mysql with foreign keys. It requires eloquent to query the database properly. This database may be accessed by other services. I am not opposed to this solution, but would just need these problems solved.

  • Multiple Table Inheritance: I have looked into this solution the least and therefore would like more information on if this is the route to go.

Thank you all for all your help!

5th October, 2015

calebporzio left a reply on Model Relationship Issue • 1 year ago

The test basically enters text and clicks the create button on the "create sphere" form. If I dd the sphere entity it exists but the relationship does not (in phpunit of course). I know this is vague and I am hoping someone can point me in the right direction or offer up a cause or solution before I have to paste every bit of code involved and render this thread unreadable.

$this->visit('influencer/settings/sphere/create')
             ->type($sphere->title, 'title')
             ->type($sphere->email, 'email')
             ->type($sphere->description, 'description')
             ->select($sphere->primary_category->id, 'primary_category_id')
             ->press('Create Sphere');

        dd($user->spheres);

calebporzio started a new conversation Model Relationship Issue • 1 year ago

Hey All,

I am struggling with a test I have written for a portion of my laravel app. The test fails, but the actual implementation works.

The code at fault is:

 public function show($id, Request $request)
    {
        // check access
        dd(Auth::user()->spheres);
        $this->authorize('update-sphere', Sphere::find($id));
    [...]

I prematurely dd'd to access a model relationship to the logged in user. If I access in the browser, I receive a dd of a model collection with one entry ( a sphere). If I view in the terminal with phpunit, the dd returns a collection with 0 entries. I hope that made sense.

Does anyone have any idea what would be causing this to work in browser but not through a test? Here is the code assigning the relationship.

$this->user->spheres()->save($sphere);

Thank you for your help.

28th September, 2015

calebporzio started a new conversation Test Text Input Without Name Attribute • 1 year ago

When testing a form in laravel, I would typically type:

$this->type('test@email.com', 'email');

But when testing a Stripe form that is impossible because Stripe doesn't want you to add a "name" attribute to credit card form elements so they don't post to the server. So how would I test and input that looked something like:

<input type="text" data-stripe="credit_card_number">

Thanks, Caleb

10th September, 2015

calebporzio started a new conversation Git Vs. SVN • 2 years ago

Hi Everyone,

It seems the popular opinion is that SVN is antiquated. Our team has used it for years and most prefer it's simplicity. Please weigh in on the benefits of Git as we are thinking of switching for this new project.

I'm looking for distinct, objective advantages. I know this can be a hot topic, so please keep it tame.

Thanks, Caleb

9th September, 2015

calebporzio left a reply on Error: "Vue Is Not Defined" • 2 years ago

Thanks @thomaskim and @jimmck.

I added:

window.Vue = Vue;

to my browserified javascript file to make it accessible globally. Worked like a charm.

calebporzio left a reply on Error: "Vue Is Not Defined" • 2 years ago

@jimmck: the app.js file is loaded before I create the new Vue instance.

This is puzzling me.

It goes:

<script src="app.js"></script>
<script>
    new Vue({ ... });
</script>

Here is end of the app.js file from chrome dev tools:

module.exports = Watcher

}).call(this,require('_process'))
},{"./batcher":8,"./config":14,"./observer/dep":48,"./parsers/expression":52,"./util":63,"_process":1}],68:[function(require,module,exports){
'use strict';

var Vue = require('vue');

},{"vue":66}]},{},[68]);

calebporzio started a new conversation Error: "Vue Is Not Defined" • 2 years ago

I can use vue if I include the compiled javascript at the end of the body, but if I attempt to use it the @JeffreyWay way I get this error: "Uncaught ReferenceError: Vue is not defined"

I installed vue via: npm install vue --save I included it via: var Vue = require('vue'); using browserify in elixir: mix.browserify('app.js'); I included it in the body using:

Here is my test code for it:

var registration = new Vue({
        data: {
            email: ''
        }
    }).$mount('#registration-form');

Any help is appreciated, thanks!

calebporzio left a reply on Non-local Dev Environment? • 2 years ago

Thanks for the input everyone. This is the way the team handles things. I come from homestead and git, just need good points and solutions as to why they should move towards a more modern dev workflow.

I think the problem lies with having local copies of databases with mock data. We typically need to work with live data for bug fixes and such. Please explain in full the error of our ways. I'm just having trouble seeing the practicality of each having a migrated and seeded database with dummy data to develop on. Help here is needed. Also, btw, there are typically 2-3 people working on one project if that makes a difference.

Also, if you could expound on why SVN is dead and why nothing is SFTPd that would be helpful.

Thanks for your wisdom and insights. Much appreciated.

calebporzio started a new conversation Non-local Dev Environment? • 2 years ago

Hey There,

The company I am currently with does not allow us to use local dev environments. Instead we have a staging server to work off of. The workflow looks like:

  1. Edit local svn repository
  2. Save and Upload via SFTP
  3. Refresh Staging Server to view changes
  4. Repeat

The reason we are doing it this way is because we don't want to give local access to the database. How does a typical not-huge, but not-small operation handle this workflow as far as database access, local dev environments and such.

Thanks, Caleb

8th September, 2015

calebporzio left a reply on How To Handle Login Routes? • 2 years ago

Then here's another question: Would you have one auth controller with getUserLogin & getManagerLogin? or 2 different auth controllers. Same goes for other entities: SomeEntity@userGet / @managerGet or UserSomeEntity@get / ManagerEntity@get?

Thank you for all the feedback. I still haven't made my decision however. I am attracted to one 'login' route.

calebporzio started a new conversation How To Handle Login Routes? • 2 years ago

Hey There,

I am building a web app with 2 very different types of users. For this example I'll say: users & managers.

What is the best / cleanest / proper way to handle sharing of routes. For example the login route. Should it be:

user/login & manager/login

or detect the user type and go from there? Please give any experience or input, much appreciated.

  • Thanks

1st September, 2015

calebporzio left a reply on Hungarian Casing (aArray, CString, BBoolean) • 2 years ago

Thanks for the input guys. I agree with your points and hope to not be using it on my upcoming project. Just was curious if there was any merit to using it.

Edit Your Profile
Update

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