Laravel has quite a convenient mechanism of dealing with database changes. It consists of Migration files for database structure and Seed files for sample data. But why separate them if sometimes it make sense to add it all to one file?
Another interesting feature in Laravel Eloquent mechanism. When updating existing entry, we just use update() or save() and then updated_at field is changed automatically. But what if we want to stick our own updated_at instead of automatic one?
I’m pretty sure that majority of you haven’t read ALL official Laravel documentation – you work only with functions you actually need and know, right? So I like to dig up some less known or “hidden” features which are new to many people. So today one of those “Did you know?” cases.
This short lesson will be both about Laravel and about general software development. One of the most often and common mistakes made by developers is not checking input data. And then not only you get random errors of something “not found”, but sometimes much worse – expose your system to vulnerabilities and attacks. So let’s discuss that with examples from Eloquent world.
This time – a really short tip. In default Laravel Auth functionality there are some predefined values, settings and similar stuff – one of them is redirecting to /home URL after successful login, or if a user is already logged in. What if we don’t have that /home – what if in our case it’s different?
Laravel default authentication is awesome. But by default it works by checking two fields – email and password. What if we have some additional fields to check? For example, if user is approved?
Another great news for Laravel community – more and more often repeated functions become a part of Laravel framework itself. Today a new addition is Authorization or ACL functionality.
There’s one really neat Laravel Eloquent function which, from my experience, a lot of developers don’t know. How do we write WHERE clauses on Eloquent queries?
Sometimes there is a situation where we have our main project database, but we need to take some external data from another database – for example, where blog is stored, managed by 3rd party software. How to handle it in Laravel 5?