All Tag: quick-tip Posts

    Craig Riley

    3 months ago - Development

    Laravel forms: casting an input before validation

    If you’re familiar with casts in Laravel, you’ll know them as a great way to transform values on their way to and from the database. A boolean cast – for example – is stored in the database as a 1 or a 0, whereas inside your code, it will be true or false. But what...

    Craig Riley

    6 months ago - Development

    Inverse BelongsToThrough relationships in Laravel models

    No, Laravel doesn’t actually have a BelongsToThrough relationship, a common frustration for models where you want to access the top level of a BelongsTo chain. Consider this setup: A user has authored many posts. Those posts have many reviews. So how do we define the inverse relationship back up from Review -> User (the post...