SOFTonSOFA

20 Eloquent tricks – more

Recently I stumbled upon interesting article by Povilas Korop on laravel-news 20 eloquent tips and tricks. First of all thanks for sharing your knowledge Povilas – it helps many people out there, keep it up!

As you probably know, I’ve worked with Eloquent for long and love its features, at the same time I’ve become very sensitive about some of the dangers lurking for inexperienced developers that come with all the magic of Eloquent :)
Let’s use this opportunity to look at the tips from different perspective and learn even more by going through some of them in more details!

Continue reading

A story about Laravel Resources

Leo is a brilliant developer. He turns every idea into code in no time. He’s prepared for any task thrown at him and dives into coding straight away, delivering successfully and rapidly.

These days he’s been working on a public API for the application he and his team is building. A few resources with a few endpoints were not a big challenge for Leo obviously. He caught some models in the wild and turned them into beatiful REST API data source. Done deal.

A few days passed and Whoops! Something went wrong unfortunately.

Continue reading

How to add custom casters in Laravel tinker

I made a series about psysh and Laravel’s tinker – powerful REPL where you can play with your whole application.

ICYMI check it out here: tinker like a boss and here’s example of what we can achieve:

There is, however, missing piece of the puzzle in the series. It describes how you can custimze presenters in REPL (called casters in PsySH), but I describe generic, global casters that reside in PsySH config. This is very handy, but you cannot distribute them among your team members (or anyone else for that matter) in the repo.

Today we are going to add that piece to the puzzle and see how to customize and override psysh casters in Laravel app.
Continue reading

Too much M4g1c will kill you (or at least bite your ass)

freddie

So, as you know, I’m a big fan of Laravel, in particular Eloquent is my favourite.
The beauty and value of both is a lot of conventions and magic happening behind the scenes. That magic, when balanced, allows us focus on things that really matter, rather than taking care of boilerplate and tedious, repetitive tasks, we’ve all been doing so many times. However…
Continue reading

Tinker like a boss – WTF?!

This is part of the series tinker like a boss (in psysh)

  1. tinker… what?
  2. includes
  3. casters (presenters)
  4. aliases
  5. http (and other) helpers
  6. wtf is this error?

Errors – WTF?

Usually getting verbose errors in tinker is now what you want. You made a typo, called wrong method etc – all feedback you need then is a short message and you can fix your error. Sometimes, however, you may want to actually see more information about the errors or full stacktrace behind it.
Continue reading

Tinker like a boss – helpers

This is part of the series tinker like a boss (in psysh)

  1. tinker… what?
  2. includes
  3. casters (presenters)
  4. aliases
  5. http (and other) helpers
  6. wtf is this error?

Helpers

You may find yourself in need of some handy shortcuts when tinkering. I often need to make an HTTP call or run a quick test request, that works exactly as the one you’d run in your Laravel tests.
Continue reading

Tinker like a boss – aliases

This is part of the series tinker like a boss (in psysh)

  1. tinker… what?
  2. includes
  3. casters (presenters)
  4. aliases
  5. http (and other) helpers
  6. wtf is this error?

Aliases

Class aliasing is very simple concept, that allows you to call a class by its alas, rather than original name. It’s not very common to use aliases when writing code , for your IDE gets you covered.

If you’re working with Laravel, it’s worth mentioning that all the facades are also aliases, that’s why you have things like request, validator etc available in global namespace. this is a convention introduced by Taylor to make things a bit more expressive,but still something that your IDE does for you.

Continue reading

Tinker like a boss – custom casters

This is part of the series tinker like a boss (in psysh)

  1. tinker… what?
  2. includes
  3. casters (presenters)
  4. aliases
  5. http (and other) helpers
  6. wtf is this error?

Custom casters

Using Laravel, you’re already familiar with idea of casters even if you’re not aware of that. Check this out:

Continue reading

Tinker like a boss – custom includes

This is part of the series tinker like a boss (in psysh)

  1. tinker… what?
  2. includes
  3. casters (presenters)
  4. aliases
  5. http (and other) helpers
  6. wtf is this error?

Custom includes

Let’s stick to a convention of a .tinker file bootstrapping our REPL env. PsySH allows including such file in 2 ways:

Continue reading

« Older posts

Copyright © 2018 SOFTonSOFA

Theme by Anders NorenUp ↑