imJohnBon

imJohnBon

Member Since 5 Years Ago

Philadelphia, PA

Lead Programmer at Tighten

Experience Points 23,155
Experience Level 5

1,845 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 193
Lessons
Completed
Best Reply Awards 8
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

15 Sep
1 year ago

imJohnBon left a reply on Returning A Key From A Helper Function

If I'm understanding this correctly, I think you'd need to do this instead:

{{ App\subcategory()->name }}
06 Dec
2 years ago

imJohnBon started a new conversation Passport Not Erroring On Expired Token

I have Laravel Passport successfully setup on Laravel 5.3 using the Client Credentials grant, however I'm running into an issue where I'm trying to test what happens when a token expires. I went into the "oauth_access_tokens" database, found my access token, and set the "expires_at" date to 2 days ago. However, when I use the access token in a request, it still works even though it's expired.

So I tried setting "revoked" to true, and that errored like it should. But it seems an expired token does not throw an error. I even looked through some of passport's source code and can't find anything that would seem to check if the token is expired.

Does anyone know how I can get passport to throw an error if a token is expired?

01 Nov
2 years ago

imJohnBon left a reply on Automated Tests With Auth:api Middleware

Ah, realized it as soon as I posted. Needed to be more explicit about which guard I was using:

$this->actingAs($user, 'api');

imJohnBon started a new conversation Automated Tests With Auth:api Middleware

I'm currently building an API in Laravel 5.3 and Passport as an OAuth service, but I'm having trouble with my functional tests since my endpoints all have the auth:api middleware applied (which requires a valid access token). I tried to disable middleware on those tests, but my endpoints need other middleware enabled so I can't do that.

I also tried this:

$this->be($user);

Hoping that would do the trick, but it didn't. I still get an "Unauthenticated" error back from Passport in my automated tests. Is there any way to get around this within my tests? Or do I need to somehow generate a valid access token each time?

26 Oct
2 years ago

imJohnBon left a reply on Json Test Helper Not Acknowledging URL Params

I figured this out. I'm not sure if it's the best way, but I was able to get it working. I just changed my code to use the call() test helper instead of the json() test helper, like so:

$response = $this->call('GET', "users/{$user->id}", ['include' => 'comments']);

You can then make assertions like so:

$this->seeJsonContains([...], $response);

imJohnBon started a new conversation Json Test Helper Not Acknowledging URL Params

Hey guys,

I'm currently working with Fractal to build an API in Laravel 5.3. Because of Fractal, I have URLs like so:

/users?include=comments

Which would respond with a list of users with their respective comments. Everything works fine when I test the API endpoints directly in Postman or in the browser, however when I try to write an automated test that hits a URL with one of those parameters, the response doesn't include the relationship. Like so:

    $this->json('GET', "users/{$user->id}?include=comments");

If I dump-and-die the response of that, it doesn't include the users comments. But again, if I manually test with Postman, it does work correctly. I've also tried an alternative syntax like so:

    $this->json('GET', "users/{$user->id}", ['include' => 'comments']);

However, it still doesn't work. Does anyone know how to get the JSON helper to work correctly in this situation?

16 Aug
2 years ago

imJohnBon started a new conversation OAuth Client Credentials Grant Question

I'm in a situation where I have 2 Laravel apps:

  1. The first is an API which also serves as an OAuth server.

  2. The second is a web app that will make calls to the API server for data.

So, naturally, the web app is going to need to get an access token to make requests to the API. I was planning on using the "Client Credentials" grant type to achieve this, given that the web app itself is the client, and not a specific user.

But I'm a bit confused about 2 things:

  1. Where should I store the access token I get back from the API server on the web app? In a session? That seems insecure. But if I don't store it somewhere, I would need to request a new token with every request.

  2. How do I handle a request that comes back from the API as an expired token? Ideally I'd like to catch that, request a new access token, and then re-make the same request. Sounds like something I could put in the global error handler maybe, but I'm not familiar with a way in Laravel to just rerun the last request that was made. Any tips?

10 Aug
2 years ago

imJohnBon started a new conversation Testing And The "new" Keyword

Quick question, I know when it comes to Unit tests, it's best to avoid creating new objects with the "new" keyword and use dependency injection instead. That all makes sense to me, since it allows you to mock the objects.

However, something I often see in Laravel's docs is stuff like this (actually something Taylor just tweeted):

https://pbs.twimg.com/media/Cpg68j5UsAACdlG.jpg:large

It seems like in these cases, there's no way around new'ing up an instance of an object. But would using code like that effect testability?

05 Aug
2 years ago

imJohnBon left a reply on Confused About Queues / Heroku

@toniperic Thanks for the further info man, I appreciate it. Also, for documentations sake, I reached out to Heroku with that same question (basically, do I need supervisor when using a Heroku worker dyno to run my queue) and this was the response:

Generally it's not required. The platform will try to keep the dyno up, so if the PHP process exits the dyno will be recreated. The dyno is marked as crashed, and if it continues crashing the platform will wait longer and longer between restarts (just in case restarts cause the crashing). So long as you aren't expecting the process to end and causing it several times a day most just leave it to the platform to handle restarts.

If you want to try Supervisor it looks like a Python app, you might be able to add the Python buildpack before PHP and get it installed during the build. You won't have access to places like /etc though so it would have to have configuration under /app, not sure but perhaps it's a command-line flag in Supervisor to get it to do that. When I try these things I first just get it onto the dyno using a buildpack, then heroku run bash to experiment with what commands work on the dyno before updating Procfile."

04 Aug
2 years ago

imJohnBon left a reply on Confused About Queues / Heroku

@toniperic Hey man, thanks so much! This was a really informative response / blog post and I really appreciate it. I definitely feel like I have a much more solid understanding of queues now.

Do you happen to have any experience specifically running a queue listener on a Heroku dyno? The only final part I'm trying to wrap my head around is where Supervisor fits into the setup.

imJohnBon started a new conversation Confused About Queues / Heroku

I'm working on an application and I'm looking to utilize queues for basic things like image resizing, etc. I understand the concept of queues but I'm a little bit confused on the implementation.

I have Amazon SQS hooked up to my application and I'm able to add queue'd items to it. However, I'm a little bit confused by my next steps. For instance, do I still need a failed_jobs table? If not, what happens to failed jobs? I'm assuming SQS has it's own place for storing failed jobs?

Also, do I still need to setup supervisor? Heroku (my host) seems to have the concept of a worker "dyno". But I'm not sure if these worker dynos do the same thing that supervisor is doing, or if I need to install supervisor on the worker dyno somehow.

I apologize that this is a little bit jumbled, just curious if anyone has had the basic experience of setting up a queue on a Heroku hosted application.

18 Jul
3 years ago

imJohnBon left a reply on Complex Relationship Query

@d3xt3r As hacky as it does seem, I agree with you. This would seem to be the most straightforward solution to the problem.

15 Jul
3 years ago

imJohnBon left a reply on Complex Relationship Query

@thefuzzy0ne Yeah, I was thinking the same thing. That error really through me off, I'm guessing it's comparing the columns between the users table and the pivot table for whatever reason (I rarely have to use unions so I'm a bit rusty).

But I don't think you can do a relationship through a pivot table with a hasMany relationship, only a belongsToMany to my knowledge. I'll have to double check that.

imJohnBon left a reply on Complex Relationship Query

@thefuzzy0ne I was thinking the same thing, a union seems like the right idea. But I just get a "Syntax error: 7 ERROR: each UNION query must have the same number of columns" when I try it. Trying to dig deeper into that error.

@ChristophAust I think that would just gives me back the current user with the "following" relationship eager loaded, not a list of users that the user follows WITH the current user included. When I'm testing it, it's actually giving me all the users back, which is very very odd. Will have to test further.

@cklmercer I believe the second option would break pagination because we're just pushing an extra result to the end and not making it part of the query.

imJohnBon started a new conversation Complex Relationship Query

I have a situation where users can follow other users. So I have my standard users table, and then also a "relationships" pivot table that looks like this:

  • from_user_id
  • to_user_id

That connects the users together. On my user model, I have this:

    /**
     * @return mixed
     */
    private function following()
    {
        return $this->belongsToMany(User::class, 'relationships', 'from_user_id', 'to_user_id');
    }

Now the tricky part. I can easily run a query to get all of a users followers by doing this:

$user->followers();

The problem I am facing though is that I want to create a query that gets all of a users followers AND the current user. So something like this on the model:

function followersAndSelf() {
    return $this->followers()->orWhere('id', $this->id);
}

(That obviously won't work but just trying to get the point across). Has anyone done a query like this?

08 Jul
3 years ago

imJohnBon left a reply on Problem With Postgres And UUIDs

Would delete this if I could, but realized I made a mistake. One of my UUID columns was accidentally a varchar column instead (I messed up the migration). Had to convert it to a UUID and now it's fine.

imJohnBon started a new conversation Problem With Postgres And UUIDs

I'm using the UUID package "webpatser/laravel-uuid" with a postgres data store, and I'm trying to perform a simple whereHas query on a relationship, similar to this from the docs:

// Retrieve all posts with at least one comment containing words like foo%
$posts = Post::whereHas('comments', function ($query) {
    $query->where('content', 'like', 'foo%');
})->get();

However, whenever I try, I get this error: "Undefined function: 7 ERROR: operator does not exist: character varying = uuid. You might need to add explicit type casts. "

Has anyone run into this before? Trying to Google around and getting results about this error, but nothing substantial enough to figure out how to fix it.

imJohnBon left a reply on Query And Return Multiple Models?

@seanwu Thanks! Figured I was looking for a union. Appreciate the link to the talk as well, will definitely check it out. If it was entirely up to me, I would definitely be using a more robust search tool for this as well.

07 Jul
3 years ago

imJohnBon started a new conversation Query And Return Multiple Models?

Let's say I have an app like Instagram, so I have users, tags, and images at the very least. Now I want to add a global site search. So when the user enters a search phrase, it searches usernames of users, names of tags, and titles of images, and then returns a collection filled with multiple different models (users, tags, and images).

I know I could query all 3 and then merge the collections or something, but that's not ideal. Has anyone done anything like this? I'm assuming some kind of raw query will be necessary.

26 Jun
3 years ago

imJohnBon left a reply on Laravel 5.3 Wish List

Some way to create database seeds specifically for seeding "real" data, not dummy data.

For instance, the site I'm building might have a need for several seeds that do things like create an initial "Admin" user. I would need this seed data for my local/dev environments, AND for my live environment.

I think this package attempts to do something similar: https://github.com/slampenny/SmartSeeder

imJohnBon started a new conversation Lumen Reusing Middleware Queries

For the sake of the example, let's say I have a blog with "Posts" that can be private or public. If a user tries to go to a post that is private, they get redirected back to the homepage. So in my Middleware I'd have something along these lines: ''' $post = Post::find(2);

if ($post->is_private) { return redirect('/); }

return $next($request); '''

This works fine, but the bad part is if the Middleware passes, once I get to my Controller I have to do ANOTHER query to the database again to get the Post, even though we already got it in the Middleware. In Laravel this is solved by Route Model Binding, but I can't find a good solution in Lumen apart from just copying the logic. Has anyone found a better solution?

21 Jun
3 years ago

imJohnBon left a reply on Lumen Override Route Parameter In Middleware

@ChristophAust Correct, this needs to be applied to roughly a dozen endpoints. Middleware seems the most appropriate since it's reusable to it's whole purpose is to effect the request before it hits your controller method.

20 Jun
3 years ago

imJohnBon started a new conversation Lumen Override Route Parameter In Middleware

I'm currently trying to implement a Middleware in Lumen that makes it so that if someone types in a URL like this:

/users/self

It will replace "self" with the current logged in users ID. However, I'm having a really hard time figuring out how to replace "self" with the ID by the time it gets to the controller. I thought maybe something like this would work:

public function handle($request, Closure $next)
{
    if ($request->route()[2]['id'] === 'self') {
        $request->route()[2]['id'] = $this->getCurrentUsersId();
    }

    return $next($request);
}

However, it does not update the requests 'id' value like I hoped it would. Does anyone have any advice on this?

14 Jun
3 years ago

imJohnBon left a reply on Complex HasManyThrough

@d3xt3r Thanks man! It's clearly been a long day; I was totally letting the "user belongs to itself" get into my head and confuse me. For some reason I was stuck on this being a hasManyThrough relationship and not a belongsToMany. I can confirm your code works, thanks again!

imJohnBon started a new conversation Complex HasManyThrough

I'm in a situation where I have users, and users can follow other users. So my tables look like this:

users

  • id
  • username

relationships

  • id
  • from_user_id
  • to_user_id

So, if I followed another user, there would be a new record created on the relationships table where the from_user_id would be MY id, and the to_user_id would be THEIR id.

Now I'm looking to create an eloquent relationship on my User model where I get all of the Users that I am following. So basically, I want to get all the users from the relationship table where the "from_user_id" is my id and the "to_user_id" is the user(s) I am getting.

I know I could do this via looping over a collection or whatever, but I wanted to keep it inside the relationship itself to offset the heavy lifting to the database. Any thoughts?

09 Jun
3 years ago

imJohnBon started a new conversation Lumen PHPUnit Tests Fail

I'm running Lumen 5.2 (latest) and even my ExampleTest that ships with the codebase is failing right now with a cryptic error: "Undefined index: REQUEST_METHOD". Searching for the error doesn't even return any valuable results when Google'd.

Anyone come across this and figure out a solution?

19 May
3 years ago

imJohnBon left a reply on Resetting Passwords In Lumen

For anyone who finds this in the future via a Google search or something, I did figure this out and then wrote a blog on it.

imJohnBon started a new conversation Resetting Passwords In Lumen

Has anyone successfully implemented a password reset feature in Lumen?

Lumen has access to things like Laravel's PasswordBroker and PasswordManager, however I haven't been able to successfully utilize them. Thinking about just rolling my own, but I'd hate to give up stuff like the DatabaseTokenRepository that is built in. Rewriting all that seems foolish.

17 May
3 years ago

imJohnBon left a reply on FormRequests In Lumen

@spekkionu

Thanks for the reply.

I'm not trying to pull in a bunch of Laravel functionality into Lumen though, literally just Form Requests because they're a great way to keep controllers slim and separate concerns.

What you suggested is exactly what the old thread I linked to suggests as well. Unfortunately, as you mentioned, it seems that functionality has roots that go a bit deeper than what is necessary for an API (like sessions and flash data).

I guess, at a basic level, I wish Lumen either included a slimmed down version of Form Requests or, at least, it'd be great if the documentation explained how to do it on your own. Currently the only thing that can be found around implementing it yourself is a one-off github comment that says "you can still set them up with some ioc bindings though" with no further explanation despite 2 subsequent comments in that thread which express the same question I have.

If I ever figure it out I'll come back to this thread and write out an explanation. Until then, I suppose the only way is to use the $this->validate() method directly in controller methods.

imJohnBon started a new conversation FormRequests In Lumen

I'm trying to figure out how to create a custom Request class to handle request validation in Lumen. In Laravel, you can do it easily by extending the FormRequest class, but Lumen does not include illuminate/foundation which is what powers that.

There are some references to this functionality online:

https://github.com/laravel/lumen-framework/issues/124 https://github.com/dingo/api/issues/717

And there's even a Laracasts thread about it:

https://laracasts.com/discuss/channels/lumen/how-can-i-use-illuminatefoundationhttpformrequest-on-lumen-micro-framework?page=0

However the solutions in there all seem a bit hacky.

In that first GitHub like, GrahamCampbell said "You can still set them up with some ioc bindings though.". Has anyone figured this out and have an example of how to implement it?

imJohnBon left a reply on Fractal Paginating Subresources

Heads up for anyone in the future who finds this thread via Google or something, I tweeted this question to the book author (Phil Sturgeon) and here was his response:

"add a link to /authors with whatever query string items need to be there. " https://twitter.com/philsturgeon/status/732222938825560064

Basically, the sub-resources pagination should have it's own pagination URL that would be called if the user tried to paginate the sub-resource. This new request would only return the sub-resource results. Pretty simple really, was over complicating it in my head thinking that for some reason you would keep hitting the original resource endpoint for more sub-resources.

11 May
3 years ago

imJohnBon started a new conversation Fractal Paginating Subresources

I'm currently working on integrating Fractal into an API Lumen project: https://github.com/thephpleague/fractal

However, I have a question about paginating embed. Let's say we have API response:

{
    "data":  [
        { "id": 11 },
        { "id": 12 },
        { "id": 13 },
        { "id": 14 },
        { "id": 15 }
        "authors":  [
            "data": [
                { "id": 14 },
                { "id": 15 }
            ]
            "pagination": {
                "cursor": {
                    "previous": 5,
                    "current": 10,
                    "next": 15,
                    "count": 5
                }
            }
        ]
    ],
    "pagination": {
        "cursor": {
            "previous": 5,
            "current": 10,
            "next": 15,
            "count": 5
        }
    }
}

Fractal has pretty great documentation on setting up pagination, but I don't see anything on how I would create a URL to paginate the "authors" embed there, which has it's own pagination. Anyone done this?

26 Jan
3 years ago

imJohnBon left a reply on Training And Education

Completely agree with you @JeffreyWay. I have always felt that, overall, modern education is broken. Broken so bad that only a complete overhaul would fix it.

The success I currently have in my career is almost entirely thanks to me reading on my own, or watching videos on this site, or doing internships. Almost none of it is thanks to my 16 years of education. Which is maddening. Because it's not like I learned the important life stuff either (electrical, plumbing, banking, etc). Most of education is boring filler, "memorize these names and these dates and then forget it after test". If concepts were stressed over memorizing facts, and efforts were made to make it interesting (like you said, Harry Potter over shakespeare), then maybe the system would be worth a damn.

One of the big reasons I love technology so much is that I think it will eventually be the savior of the education system. It could one day be possible for each student to have their own personal teacher tailored to their learning needs and their interests. I hope I get to be a direct part of that revolution.

06 Jan
3 years ago

imJohnBon left a reply on Confused About "Mocks" Testing Jargon Video

@ifpingram Thank you for the response! I was used to things like Mockery where Mocks are more implicitly created.

imJohnBon started a new conversation Confused About "Mocks" Testing Jargon Video

I just watched the "Mocks" Testing Jargon video: https://laracasts.com/series/testing-jargon/episodes/2

But I'm still honestly confused about how that code works. For instance, this is the code in "RegistersUserSpec" that imports the "mocks".

function let(UserRepository $repository, Mailer $mailer)
{
    $this->beConstructedWith($repository, $mailer);
}

We then use those $repository and $mailer classes as "mocks". But what makes them mocks? Did importing them using the "let" command make them mocks? Jeffrey mentioned that if we did this:

function let(UserRepository $repository, Mailer $mailer)
{
    $this->beConstructedWith(new UserRepository, $mailer);
}

It would not work, but I don't really understand why, unless something special is happening behind the scenes when you import classes with the "let" function. Any assistance?

23 Aug
3 years ago

imJohnBon left a reply on [L5] Are Eager Load Constraints Broken?

@Popmatik My pleasure. pmall is correct, the way I solved this was to by joining data from the second table into the first one.

Of course, that's all just words. So let's look at real code. To continue with my previous example, let's say we have users, and users can associate themselves with their favorite movies. In this case we have 3 tables: "users", "movies", and "movie_user".

For the sake of this example, let's say that the user can only associate themselves with one movie (their favorite movie, or whatever). And we want to sort the retrieved list of users by the title of favorite movie, for whatever reason. Your instinct may be to do this:

$users = User::with(['movies' => function($query)
{
    $query->orderBy('title', 'desc');
}])->get();

But like I mentioned earlier, that's an incorrect assumption. You're sorting the movies that you've retrieved, not the users. So how would we sort the main user query by the sub query? Through a join:

$users = User::join('movies', 'users.id', '=', 'movies.user_id')
    ->select('users.*', 'movies.title')
    ->orderBy('title', 'ASC')
    ->get();

As you can see, we join the user table and the movies table together on that first line by telling the query that the "user_id" column on the "movies" table is equal to the "id" column on the "users" table.

Then in the second line, we tell it that we want ALL the data from the "users" table and just the "title" from the "movies" table (you could also get everything from the movies table if you needed it). And now that we have the title of the movie "joined" into the main user query, we can order by the title of the movie and it will effect the main user list.

Hope that helps! I'm no Jeffrey Way but if you have any further questions I'll give it my best shot.

16 Aug
3 years ago

imJohnBon started a new conversation Would You Put Image Processing In A Queue?

I'm curious about what you guys do with image processing.

Naturally, if you're doing something like resizing an image to 10 different sizes, it might be a pretty heavy task to do when the user saves their profile.

So ideally a queue would solve this right? Do it in the background at a later time. However, in this case, as soon as the user saves their profile a few of those resized images are seen on the next page. Which implies that it would need to be done at the exact same time that the profile is updated/saved.

So how do you guys handle this?

20 Jul
4 years ago

imJohnBon left a reply on L5 : Pagination Url

Did anyone ever solve this issue?

My document route IS set to public, but Laravel 5.1 is returning pagination urls with an end slash before the argument. Like this:

/example/?page=2

instead of

/example?page=2

And since I'm calling the link via ajax, everything errors because the ajax hits a redirect upon trying to go to "/example/?page=2".

imJohnBon started a new conversation What Am I Supposed To Do With The Result Of Storage::get()?

So I have a situation where locally I want to store the files on disk, but on my live environment I want to store them on Amazon S3.

Naturally this is what the Storage facade is built for. And storage::put() works pretty well. However Storage::get() returns some raw data about the image. How exactly am I supposed to use that to get a path that I can pass to my view to display the image inside an tag?

Everything I see online seems to suggest some crazy solution where you have a controller just for images and whatnot. Surely (hopefully) there must be a simpler solution??

16 Jul
4 years ago

imJohnBon started a new conversation Render All URLs With Https?

Does anyone know how to get URLs to render with https when they are output in blade templates with things like link_to_route()?

For context, my site is running on Heroku with SSL up and running. But Heroku doesn't seem to let me edit my .htaccess file (or any file directly on the server, for that matter).

(I apologize if this was posted twice, I thought I posted it but now can't see it in my profile).

imJohnBon started a new conversation Render URLs With Https?

Does anyone know how to get URLs to render with https when they are output in blade templates with things like link_to_route()?

For context, my site is running on Heroku with SSL up and running. But Heroku doesn't seem to let me edit my .htaccess file (or any file directly on the server, for that matter).

imJohnBon started a new conversation Redirect All Errors On Live

How do you guys handle errors on your live environments? I know if you set APP_DEBUG to false you don't get anything specific, but you still get that ugly default Symfony (I believe) page. Obviously in a live environment you'd never want a user to see anything.

How do you go about redirecting any type of error to a default "error" page?

08 Jul
4 years ago

imJohnBon started a new conversation Passing Data To A "confirm" Modal Before Storing.

So I have a situation that is basic CRUD, but with a confirmation modal.

Let's just assume for the sake of explanation that I have a "Podcast" resource. When the user hits "Create Podcast", the podcast isn't actually created. Instead a modal pops up asking them to confirm that they actually want to create it (so something like PodcastsController@confirmCreate() is called). The modal displays the title and length and some other data about the podcast that they're about to create as well.

Then if they still want to create it, they click "Confirm" and the resource is created. My only question is, how do I get the original input data from that first controller call? Since technically the original "Create Podcast" form is submitted the first time, I don't have access to it when the user clicks the second form to confirm it.

08 Jun
4 years ago

imJohnBon left a reply on Firing JS Events On Successful Form Submit Without Ajax?

@sitesense Wow, I was thinking way too inside the box this morning. The 3rd party service has an entire PHP API wrapper that I can use and even leverage Laravel events to keep the code clean. Thanks man.

imJohnBon started a new conversation Firing JS Events On Successful Form Submit Without Ajax?

I'm curious to how everyone here architects/handles this dilemma. I need to fire a javascript event to a 3rd party service when one of my forms successfully submits. This form cannot use ajax.

For example, I have a podcast site and every time someone subscribes to a new podcast I want to send the following information to the 3rd party API:

  1. The user who subscribed
  2. The podcast they subscribed to.
  3. The time they subscribed.

The only way I can think to do this would be to return the info inside of GET variables in the page I redirect to. For instance:

example.com/podcast/subscribed?event=podcast-subscription&user=1&podcast=4&time=000000

And then look for the "event=podcast-subscription" GET variable in my JS and fire the appropriate event to my 3rd party service.

Is this really the best way to go about this? Anyone have a better way?

26 May
4 years ago

imJohnBon started a new conversation Socialite LinkedIn Integration

Has anyone done Socialite LinkedIn integration? LinkedIn is not one of the default integrations Socialitie offered but it does look like a package exists for it:

https://github.com/SocialiteProviders/LinkedIn

I was mostly just wondering if anyone has had any experience with using it.

15 Apr
4 years ago

imJohnBon started a new conversation Custom Validation Message From Request Object?

Does anyone know how to change the validation error messages that get returned from form that fails validation when using a Request object?

I see in "Illuminate\Foundation\Http\FormRequest" there is a method that looks like this:


    public function messages()
    {
        return [];
    }

I thought overriding that would work, but it didn't.

02 Apr
4 years ago

imJohnBon left a reply on Seeding With Real Data?

@Gewora a fair point! Thanks.

imJohnBon left a reply on Seeding With Real Data?

@Gewora you're saying you use seeds for production data? Or console commands?

imJohnBon started a new conversation Seeding With Real Data?

I'm a little bit confused about how I should go about seeding my database with "real" data. IE data that will actually be used in a production environment. For instance, let's say whenever the site is created I also want to create 5 admin accounts.

You would think seeds are the right answer, but I've seen a lot of people say that seeds should be exclusively used for fake test data. The alternative seems to be putting "real" data into the database through migrations.

But that doesn't seem to scale well. Let's say you need to change one of the emails of the admins you are creating? You can't really go back and just change that one migration. You would risk losing data that has changed over time. Otherwise you need to create an entire migration for that simple thing, which seems crazy.