How to easily set a custom redirect in Laravel form requests

In Laravel you can create custom request classes where you can house the validation for any given route. If that validation then fails, Laravel’s default action is to redirect the visitor back to the previous page. This is commonly used for when a form is submitted incorrectly – The visitor will be redirected back to said form to correct the errors. Sometimes, however, you may wish to redirect the visitor to a different location altogether.

TL;DR (Too long; didn’t read)

At the top of your custom request class, add one of the following protected properties and give it your required value. I have given example values to demonstrate:

protected $redirect = '/custom-page'; // Any URL or path
protected $redirectRoute = 'pages.custom-page'; // The named route of the page
protected $redirectAction = 'PagesController@customPage'; // The controller action to use.

This will then redirect your visitor to that location should they fail any of the validation checks within your custom form request class.

Explaination

When you create a request class through the Laravel artisan command, it will create one that extends the base Laravel class Illuminate\Foundation\Http\FormRequest. Within this class the three protected properties listed above are initialised from line 33, but not set to a value.

Then further down the page of the base class, on line 127 at the time of writing, there is a protected method called getRedirectUrl. This method performs a series of checks for whether or not any of the three redirect properties have actually been set. The first one it finds to be set by you, in the order given above, is the one that will be used as the custom redirect location.

Here is that getRedirectUrl method for your convenience:

/**
* Get the URL to redirect to on a validation error.
*
* @return string
*/
protected function getRedirectUrl()
{
    $url = $this->redirector->getUrlGenerator();

    if ($this->redirect) {
        return $url->to($this->redirect);
    } elseif ($this->redirectRoute) {
        return $url->route($this->redirectRoute);
    } elseif ($this->redirectAction) {
        return $url->action($this->redirectAction);
    }

    return $url->previous();
}

Do you have any extra tips to add to this? Let me know in the comments below.

Thanks.

It’s been a while

I’ve not been writing as often as I’d like this last week. Partly this is due to my having done the Birmingham International Marathon last Sunday and being in recovery from a knee injury from that. But I know that’s a pathetic excuse – there’s always my phone that I can write posts on after all.

That being said I am currently putting together a structure, a strategy if you like, for planning writing and publishing posts at a more consistent rate. Once it is all put together I’ll put together a list of the programs and services I am using for it.

I had a goal a few weeks back of getting to this site to have 250 published posts in total by Christmas day 2017. This post will be number 182 so I’m not sure if I’ll successfully manage 250 by then. But I will give it a good try.

Going to be going pumpkin picking tomorrow but don’t know what I’m going to theme my pumpkin on this year. Last year’s was Pinhead from Hellraiser. I’d love to hear some suggestions from you.

Take care, Dave.

The Last of Us review

The Last of Us was released in 2013, yet i didn’t get to play it till three years later. But when I did, it quickly became one of my top three games of all time. Its whole world and the characters within have somehow become a part of me. Joel and Ellie have become two of the most important characters in my life.

What’s The Last of Us about?

After one of the most emotional game intros I’ve ever experienced, we are placed with our hero, Joel, twenty years into a Post-apocalyptic world. Early on in the game you are entrusted to look after 14-year-old girl, Ellie. This is where it all begins – one of the most important relationships in gaming history starts right here. You are tasked with getting her safely to a group called ‘The Fireflies’, the reasons for which I wont reveal here, and of course it’s not simply a case of walking from A to B.

Once Ellie is with you, she will follow you wherever you go and you must protect her at all costs. But don’t get mistaken that protecting her means she is helpless; quite the opposite is true in fact. As the game progresses you will find that Ellie is just as tough as Joel, if not more so. They both come to rely on each other for survival.

You will end up travelling across America in your mission, encountering some interesting and downright terrifying people. The locations too are beautiful to explore, with the suburbs; the University of Eastern Colorado; a snowy lakeside resort; and more. All of which have been subject to the unstoppable spread of both mother nature and the deadly virus. The combination of overgrown flora and fauna, along with the ever-mutating infected, make for some simultaneously beautiful and grotesque imagery.

Infected everywhere

The infected that you encounter on your journey can be really tough at times, with all-out gun fights being the worse option to take. The infected people are found at different stages in their individual mutations, with each stage having its own strengths and weaknesses. The most iconic of these stages is probably what are known as ‘Clickers’. These mutated festering people have one of the most iconic sounds I’ve heard – their namesake ‘Clicking’.  They use this as a form of echo location due to their being blind as a bat.

There’s nothing quite so brutal as the moment a clicker grabs a hold a bites down hard.

A game of character

The emotional thread that runs through this game is much stronger than any of the make shift melee weapons that Joel can fashion. The core of The Last of Us is the father/daughter relationship between Joel and Ellie that gets stronger and stronger as time goes on. Although he is initially cold towards her, treating her simply as his current mission, you will see how their bond becomes tighter with each step they take. One of the real great parts of this character development too, is the subtle exchanges of conversation that happen in-game, when you are playing.

It is hard to talk about the characters in this game without drawing comparisons to The Walking Dead. What both The Walking Dead and The Last of Us do so well, is deal with the conflicts between humans themselves. Even though humans as a species have a common enemy in the viral outbreak, there are still separate factions that arise that will kill one another for control and supplies instead of working together.

As strong and positive as the relationship between Joel and Ellie is, there is darkness out there that would see them torn apart. This darkness could not have been portrayed any better than by David. The build up through the Winter chapter to its violent conclusion is one of my favourite scenes in gaming. And that’s all I’ll mention of it.

Multiple playthroughs

I’d never before finished a game and immediately, after the credits, hit ‘New Game’, but with this one I did. I just couldn’t wait to get back into this world once again. Once I knew the story and where conflicts would occur, I found I could take in more of the environment. I would start looking carefully at every little detail in the world around me, ever-impressed with the level of care.

When you replay through at the same difficulty you keep all weapon and character enhancements you gained first time through. This made me feel like a bad ass and I actually went looking for fights.

In Conclusion

It’s rare that a game, or even a film, that gets such high praise and surrounding hype actually lives up to it, but The Last of Us does. It’ll have you laughing at the funny interactions between the characters; it’ll have you terrified and scared for your life. It may even have you questioning the things that you really hold dear in this world of distractions and excess.

The Last of Us not only lives up to its reputation, it dwarfs it.

Stop worrying about your niche – just write

Every single regurgitated blog post I see about starting a blog always says the same thing – find a niche and focus on targeting it. This can be a toxic idea as it has the power to both limit you and paralyse you from writing.

I’m not saying you shouldn’t have a focus in your writing, just don’t let finding a focus stop you from writing.

My advice to anybody out there wanting to start a blog is this – just open a free WordPress.com account and get writing. I mention WordPress as it is cloud-based, free, and has the ability for you to export your posts when you are ready to move to a self-hosted solution.

Just start writing.

Even the process of setting up a self-hosted WordPress site can be danuting for new people, but that’s okay. You shouldn’t need to worry about these steps when you are just starting out.

I highly recommend that you do have a self-hosted website eventually, just don’t let setting one up hinder you from any writing you could actually be doing.

You don’t need to feel that you have to publish everything you write either. Just writing for writing’s sake is good for you. Obviously if you can share your thoughts and experiences with the world then that’s all good, just don’t feel you have to.

Tropic of Cancer by Roslyn Moore

Roslyn Moore is back with her second desert opera, Tropic of Cancer.

I was an immediate fan of Roslyn’s as soon as I first heard her stuff on Soundcloud over a year ago. So the announcement of this new album did get me excited.

Evolution of the desert opera.

Tropic of Cancer is the new album by Roslyn Moore, which builds upon the material from her previous album Hazy. Those older songs – some of which have a different sound to them, coupled with 9 new songs – make for a deeper and darker Roslyn Moore experience on this album.

I’ll first address the elephant in the room. Yes, all of her songs from Hazy are on this new album but what you have to remember is, is that these songs have been available for free on Soundcloud since their release. With this, I tend to think more that she is working out her sound and albums in the public space. Kind of like if a painter uploaded her pictures in stages as she was painting them. The same emotional and ideological core, but each iteration building on the last into a stronger end piece.

Some hand-picked favourites

There were a few songs that immediately stuck with me from Tropic of Cancer. These tended to be ones that sounded like she was experimenting with her sound.

Roslyn Moore

Starting with the ebbing and flowing of quiet percussion, The Great Escape/15 Rounds was refreshing to hear from Roslyn. The percussion starts and stops with her spoken lyrics continuing, giving it a 50/50 mix of accapella and accompaniment. It gives the song a really interesting sound that is unlike anything Roslyn has done before.

Speaking of things she hasn’t done before – scaring the hell out of me is one of them. The last quarter of Hazy/Agents At The Ferris Wheel took a complete left turn into what I can only describe as a drug-induced, Industrial nightmare. I was nodding off to her calming vocals and this thing just hit me off guard.

It scared the absolute living shit out of me. Good job.

Probably my favourite on the album is a song called Coke&Weed. With its marching-band / jazzy / guitar-kissed infusion, this song has so many interesting parts to it that I keep going back for more. This song would sound so fucking awesome played live in the Road House on Twin Peaks.

In closing

You should think of Tropic of Cancer as more of a transformation from her previous album. All of the songs from her previous album, Hazy, are on here – but so too are 9 new songs. Not only that but some of her previous songs sound like they have been redone / remixed.

I love that Roslyn is still pushing her music forward, experimenting with new ideas, whilst still remaining true to her emotional centre. These songs are still soaked in a dark melancholy, only this time she’s coming at it from new angles and with new styles.

The Trip with Steve Coogan and Rob Brydon

The Trip is a British TV sitcom starring Steve Coogan and Rob Brydon. In it, they play semi-fictionalised versions of themselves as they travel to various restaurants in order to review them for a paper. Each series focuses on a single country.

The story that runs through The Trip is a simple one, giving plenty of space to enjoy the conversations and natural chemistry between Steve and Rob. Often we see them talking over a gorgeous looking meal in one of the restaurants they are reviewing. These conversations then tend to snowball into an array of impressions of famous people. The impressions are hilarious too, which isn’t surprising at all given the calibre of these two comedy legends.

For me, where this series really shines, is in its ability to make me feel like I’m there with them. I could just as well be on the next table over from them in the restaurant listening in.

Despite the many laughs this series has, it still has a serious thread running through it. It often explores the characters’ personal side and how they may occasionally veer off the straight and narrow. These moments aren’t played for laughs either; the whole show is very sincere from beginning to end. In fact the laughs that The Trip triggers are as organic as if you were sat in the room with them.

The friendly rivalry between the two of them is fun to watch as well, with them having occasional digs at one another’s career. There are even times when I’d think one had overstepped the mark. However, I have to remember that they are playing character versions of themselves, not their actual selves.

At the time of writing, there are three series of The Trip: ‘The Trip’, ‘The Trip to Italy’ and ‘The Trip to Spain’. (The first series was set in the countryside villages in the north of England). It is such a fun series to watch one after the other, and I’ve never got tired of sitting with them as they eat some of the worlds best looking food.

Here’s some of the moments from the series for you to taste:

Thoughts on the film “Neon Demon”

With its gorgeous visuals and pulsing soundtrack, Neon Demon is a film that I won’t be forgetting in a hurry. The majority of the story felt to me like it was floating in and out of the conscious mind, with an increasing level of abstract as it went on.

What’s The Neon Demon about?

The Neon Demon follows fresh-faced, 16-year-old model Jesse, played by Elle Fanning, as she enters the harsh world of fashion modelling. We follow her from her first demo photos – featured in the poster above – to her quick rise to fame. With her sudden rise she attracts enemies within the business and even some avid admirers.

By the film’s final scenes I found myself slack-jawed, not quite believing what I was seeing; you could say it left me slightly haunted.

Elle Fanning in Neon Demon

Bold and beautiful visuals

The fact that this film has such an easy to follow story, allowed me to get completely caught up in the rich atmospheres that the director, Nicolas Winding Refn, put together. Neon Demon felt almost like a dream for the most part. In fact even some moments that were grounded had elements of a dream / nightmare in them (the scene with the mountain lion for example). The colours throughout were so refreshing to me as well. The vibrant purples and blood reds gave my eyes a real treat with the bold shots they created.

The film reminded me quite a bit of italian giallo films – those ones that are really unsettling to watch – like “Suspiria” or “Cat O’ Nine Tails”. Just something about them isn’t quite right – some kind of horror that is sitting just beneath the film’s surface. The music only served to enforce this for me and felt somewhere between Giallo and Synthwave – a great combination.

Bathroom scene in Neon Demon

In Closing

As with Mother! from last week, Neon Demon is another one of those films that defies an easy grouping. There are elements of horror, thriller, very black comedy and even touching on very *taboo subjects. However, those elements are woven into the fabric of the film to create a single, altogether unique viewing experience.

I was thinking about this film still days after I’d watched it. Proceed with caution and an open mind.

*(I can’t really mention the taboo subjects without giving away key events. What I can say is that they aren’t for the faint of heart.)

Her Tape 2 by Her

Her Tape #2 is a six-track E.P. released by ‘Her’ in April of 2017. This E.P. was one of those random finds that I now couldn’t imagine not having in my regular playlist. All of the songs on here are made up of an eclectic mix of instruments and singing styles, expertly woven together.

After a french-spoken introduction, ‘Blossom Roses’ begins with a soulful voice singing over a simple organ melody. The chilled out nature of this music just welcomed me into it like a huge wool blanket. Like the one my lady knitted for me at Christmas. The song soon flowers into what I can only describe as being influenced by Zero 7. ‘Blossom Roses’ was such a great escape from the monotony of my regular commute that I had to hear the whole E.P. before I started work that day.

The next song, ‘Queens’, mixes up the singing style from the previous and has an awesome little guitar riff throughout. Just with ‘Blossom Roses’, the song builds up brilliantly to its crescendo. ‘Queens’ gave me some vibes similar to the band Arcade Fire in parts.

‘Jeanie J’ helped the band’s knack for effective arrangement really sink in for me. Just like with the rest of the songs, none of the individual parts of ‘Jeanie J’ appear to be particularly complex, yet they come together to create a beautifully-arranged song.

If you find yourself with twenty minutes spare nad not sure what to do, check out Her Tape #2. After listening to it, it left me wanting another twenty minutes from them.

Life is Strange: Before the storm episode 1 (Awake)

Going back to the coastal Pacific Northwestern town of Arcadia Bay has been a joy. So many familiar places and people made it welcoming once again. As to did the game’s visual style and character development.

One of the central points of Life is Strange was Max Caulfield’s new power – the ability to rewind time, allowing the player to pick an alternate choice to their original. I was interested to know how a new game, a prequel in the case of Before the Storm, would hold up without this huge key component.

As it turns out there is so much more to these games than just the ability to rewind time. In fact the more I played Before the Storm, the more I realised that – although it is key to the original’s plot – Max’s ability isn’t the most memorable thing about her and Chloe’s adventure. The most memorable things for me were the characters, their relationships and the world they all live in.

Chloe’s special ‘gift’

Although Chloe doesn’t have Max’s power, she does possess the gift of ‘Backtalk’.

Stay with me.

Backtalk is when you engage in a battle of words with another character, with each of your responses having to be chosen before the timer runs out. It feels great to win an argument in this game and a lot of Chloe’s comebacks had me genuinely laughing out loud.

More of a coming of age story

Where a lot of the plot of the original was a mystery / detective story, Before the Storm is more of a coming of age story. There is no mystery to solve here. You, as Chloe Price, are going about your business and quickly befriend Rachel Amber. Their relationship advances nicely given the relatively short time frame and number of locations they have. By the end of the episode I could feel the strength of their friendship quickly becoming love.

I also loved how we got to experience life as Chloe, seeing her subconscious and how she’s coping with the loss of her father. We also see the early stages of David, her mom’s new boyfriend, moving into her life. I have to say that I couldn’t dislike David at all since I knew how heroic he became in the climax of the first game. Saying that, her comebacks to him when engaging him in backtalk are golden.

Still a game of exploration

Before the Storm is just as fun to explore too, as with it’s predecessor. You should talk to everyone and walk everywhere, because you never know what cool little conversations you will have. Each scene also has areas where Chloe can tag with her black marker pen. These are rewarded with achievements too so make sure you find them all.

On the whole I really enjoyed this game. I didn’t miss Max or feel the game needed anything else like another magic power or anything like that. Before the Storm felt smaller in scale to Life is Strange, but the characters and situations still helped to flesh out the world of Arcadia bay much more in my mind.