Oh Dear! monitors your entire website, not just the homepage. You'll get a notification as soon as your website is down, a monthly uptime report, a warning a few days before your SSL certificate expires and much more! Start your free 10 day trial now!

📺 How to avoid large function signatures by using pending objects

Original – by Freek Van der Herten – 1 minute read

In this video I demonstrate how to you can create a fluent API by using pending objects. We'll take a look at how subscribers can be created in Mailcoach. As a bonus I explain how jobs are dispatched using a pending object in Laravel.

This video is part of the Mailcoach video course which will be released early next year. In the video course I'll explain how we built Mailcoach and give tips on how to write well structured and clean code. Subscribe at the Mailcoach site to get notified when it is released.

Stay up to date with all things Laravel, PHP, and JavaScript.

Follow me on Twitter. I regularly tweet out programming tips, and what I myself have learned in ongoing projects.

Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

Comments

You can comment on this post by replying to this tweet.
Matthew Poulter liked on 3rd January 2020
DevCamp retweeted on 1st January 2020
DevCamp liked on 1st January 2020
Claudson Martins replied on 1st January 2020
It could be done returning the model it self, instead of a PendingModel. But I think the goal behind the creation of a pending object is to avoid things that could lead to mistakes. Like reach for a relationship when the model itself isn't persisted yet. Am I right?
Claudson Martins replied on 1st January 2020
Those videos are great, but if you don't mind, could you enable the video speed option? I like to watch everything in 2x 😁
Johan Alvarez liked on 1st January 2020
Manojkiran liked on 31st December 2019
Sohail Ahmad retweeted on 31st December 2019
Sohail Ahmad liked on 31st December 2019
Luca Malattia liked on 31st December 2019
Lukas Cornille liked on 31st December 2019
Marcin liked on 31st December 2019
David Franco liked on 31st December 2019
Abdulrahman As'ad liked on 31st December 2019
Linka Softwares liked on 31st December 2019
Khai Rahman retweeted on 31st December 2019
Khai Rahman liked on 31st December 2019
~/αhmєd liked on 31st December 2019
Misbah ansori liked on 31st December 2019
Dominik Kowalski liked on 31st December 2019
Devon Mather liked on 31st December 2019
Freek Van der Herten replied on 31st December 2019
Thanks!
JΞRRΞD liked on 31st December 2019
Jan-Joost Heurter replied on 31st December 2019
I see some great improvements coming up in 2020 🙌 Great explanation and a great video 👌
James Hemery liked on 31st December 2019
Maurizio retweeted on 31st December 2019
Percy Astocaza liked on 31st December 2019
Jan-Joost Heurter liked on 31st December 2019
Maurizio liked on 31st December 2019
oluwajubelo loves VueJS 🚨 liked on 30th December 2019
Emanuel liked on 30th December 2019
Joan Morell liked on 30th December 2019
DiegoGermánGonzález retweeted on 30th December 2019
Richard Jeffery retweeted on 30th December 2019
Sebastian Rasch liked on 30th December 2019
Adib Hanna retweeted on 30th December 2019
Rolf den Hartog liked on 30th December 2019
rik 🔝 liked on 30th December 2019
Fred Carlsen liked on 30th December 2019
Patrick Artounian liked on 30th December 2019
Alexander von Studnitz liked on 30th December 2019
Mickaël Isaert liked on 30th December 2019
Murali ⌘ Krishna liked on 30th December 2019
Wyatt liked on 30th December 2019
Miguel Piedrafita 🚀 liked on 30th December 2019
Craig Paul retweeted on 30th December 2019
Mozammil liked on 30th December 2019
Chris Smiles liked on 30th December 2019
Matt Murtaugh liked on 30th December 2019
Craig Paul liked on 30th December 2019
loreias liked on 30th December 2019
Kalle Palokankare liked on 30th December 2019
Tim Spratt liked on 30th December 2019
Parthasarathi G K liked on 30th December 2019
Mazedul Islam Khan liked on 30th December 2019
Cyril de Wit liked on 30th December 2019
Joseph Silber replied on 30th December 2019
Just beware: this breaks when doing it in Tinker, since Tinker keeps a reference to the object.
undefined liked on 30th December 2019
Florian Wartner liked on 30th December 2019
José Cage liked on 30th December 2019
oluwajubelo loves VueJS 🚨 retweeted on 30th December 2019
Tomáš Máčala liked on 30th December 2019
PHP Synopsis retweeted on 30th December 2019
Osmar Alves liked on 30th December 2019
Yannick Yayo liked on 30th December 2019
Matan Yadaev liked on 30th December 2019
Roni Estein liked on 30th December 2019
Andre Sayej liked on 30th December 2019
alan wilson liked on 30th December 2019
Tom Witkowski liked on 30th December 2019
이현석 Hyunseok Lee liked on 30th December 2019
Matan Yadaev replied on 30th December 2019
Cool, thanks. Is that pending object the correct name for this pattern? I didn't find other articles about this pattern.
Narayan Ramchandani liked on 30th December 2019
Roni Estein replied on 30th December 2019
Thanks, besides being awesome, taking the time to produce posts and videos on awesome tips is what makes you stand apart.
bernard kssy retweeted on 30th December 2019
Victor Abbah Nkoms retweeted on 30th December 2019
Jimmy Lipham liked on 30th December 2019
Lars Klein liked on 30th December 2019
Victor Abbah Nkoms liked on 30th December 2019
Jeffrey van Rossum liked on 30th December 2019
Arash liked on 30th December 2019
Rati Wannapanop liked on 30th December 2019