fredmarks

fredmarks

Member Since 1 Year Ago

Experience Points 410
Experience Level 1

4,590 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 1
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

11 Feb
2 months ago

fredmarks left a reply on Exception Handler 500 Error

I managed to solve this, thanks to this thread

https://laravel.io/forum/02-19-2015-laravel-5-custom-error-view-for-500

I add this code right at the start of my render method

        if($exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) {
            return parent::render($request, $exception);
        }
09 Feb
2 months ago

fredmarks left a reply on Exception Handler 500 Error

@SNAPEY - I am getting the white screen (i.e. no debug output) in chrome dev tools. Also debugbar shows nothing (no exceptions).

However, If i remove that if(ajax) statement completely, then everything works. i.e. I get all the exceptions showing in dev tools and bugbar.

The only time this is breaking is with 500 exceptions. All others (like the ones in my switch statement) are working and return ajax json as expected

fredmarks left a reply on Exception Handler 500 Error

@BOBBYBOUWMANN - I do have code in the switch, I just did not put it here as it was not relevant.

if ($request->ajax()) {
      $code = $exception->getStatusCode();
}

The error is with $exception->getStatusCode(), even if all I have is the code above, when a 500 exception happens, there is nothing displayed in chrome devtool

Somehow, $exception->getStatusCode(); breaks things

08 Feb
2 months ago

fredmarks left a reply on Exception Handler 500 Error

@BOBBYBOUWMANN - As you have described, the exceptions are showing in my dev tools request tab as expected.

However, the problem I am having is that when I add my ajax if statement in the handler's render method as shown above, I no-longer get the exceptions being displayed in my Chome Dev tool. All I get is a white screen with no response payload

I seem to have narrowed the problem down to this

        //THIS IS CAUSING IT TO BREAK.
        if ($request->ajax()) {
            switch ($exception->getStatusCode()) {
                //it seems this it of code is causing the issue. No exceptions showing in dev tools
                //$exception->getStatusCode()

               //even if I suppress it with @$exception->getStatusCode(), the problem remains
            }
        }

        //THIS IS HARMLESS AND IT CONTINUES TO WORK
        if ($request->ajax()) {
            $foo = 'bar';
            switch ($foo) {
                //continues to work as expected & I still get exceptions in chrome devtool
            }
        }

fredmarks started a new conversation Exception Handler 500 Error

I have added an some custom exception handling for ajax request

\App\Exeptions\Handler.php


public function render($request, Exception $exception)
{

  //do something different when its an ajax call
  if ($request->ajax() && in_array($exception->getStatusCode(), array(403, 419, 404))) {){

      //retun ajax respone

   }

    return parent::render($request, $exception);
}

This is all working fine, however when my code generates a 500 error (e.g. Method does not exist) no output is generated in either debugbar or chrome developer tools.

The only place I now see the exception message is in the log file.

Any ideas how to get around this, so that I can still get my debugging exceptions for 500 errors?

23 Oct
6 months ago

fredmarks left a reply on Validation Ordering

@Cronix @borisu

It may be easier to explain with a screenshot of my form (please see below)

https://unsee.cc/d9f9c8dc/

fredmarks left a reply on Validation Ordering

@Cronix

I have tried your suggesting, but same problem

If a clientid is not provided in the form, the exists rule should not be getting checked at all..... but it is

fredmarks left a reply on Validation Ordering

            'clientid' => [
                'bail',
                'required_if:existing_client,yes',
                Rule::exists('clients', 'id'),
            ],

Still giving the same result.

Bail works once a validation rule has failed.

In this case, the required_if rule is not really failing, given that existing_client != yes

fredmarks started a new conversation Validation Ordering

            'clientid' => [
                'required_if:existing_client,yes',
                Rule::exists('clients', 'id'),
            ],

The problem

The exists rule is being checked, even when the required_if returns false (i.e. existing_client != yes)

How can I write this, so that the exists rule is only checked when the required_if rule has passed

12 Sep
7 months ago

fredmarks left a reply on Eloquent Relationships

@Tray2 I have decided to go with your many to many suggestion.... its working great

Sometimes we gotta just keep things simple

fredmarks left a reply on Eloquent Relationships

I could do that but I will end up repeating myself as the application grows

  • task_users
  • project_users
  • ticket_users
  • foo_users

hence, a single *assigned model with polymorphic relationships with tasks, tickets, projects

Or maybe I am complicating it :)

fredmarks left a reply on Eloquent Relationships

@Tray2 Thanks for the comment. I do not want the users to have the direct relationship with the projects or task table, I want the relationship to go through the "assigned" table. The reason is that

  • A user can be assigned to many tasks
  • A task can have many users assigned to it

So, having a user_id field in the tasks table will not allow this

fredmarks started a new conversation Eloquent Relationships

Hi everyone.

I am setting up my table relationships in my models and I have come stuck. Below are my 4 tables

[User]

  • id
  • name

[Tasks]

  • id
  • title

[Project]

  • id
  • title

[Assigned]

  • user_id
  • assignedtable_id
  • assignedtable_type

I have created my morphMany/morphTo relationships (assigned + project) (assigned + tasks) and that is working fine.

I now want to be able to do get the tasks or projects assigned to a user, by doing this:

\App\Models\User::find(1)->tasks \App\Models\User::find(1)->projects

What relationship do I set up to connect [user]->[assigned]->[tasks]