Normally, with Laravel (@laravelphp on Twitter), if you create a model and use the “-m” or “–migration” flag to create the accompanying migration, it will pluralize the table.

So for example “User” model will use a “users” table; “Vehicle” model will use a “vehicles” table.

I just discovered however, that if you create a “Data” model, the table will also be created as “data” – not “datas”. It makes complete sense as datas isn’t a word.

I love using this framework.

Rewriting my database structure is proving more work than first thought. Still – I’ve learnt some new Laravel stuff which is always good. So even if it never ends up being used, it’s not been a wasted exercise.

On rethinking my database structure

I’ve been using Laravel for my personal website for about eight months now and haven’t looked back since.

This huge advantage to my rebuilding it in that way — from its original WordPress foundations — was that I had a crash course in using Laravel as well as learning some best practices as well.

Now that I have been using my site daily for all this time, I have found places where it has got messy — unavoidable through the learning experience — as well as places where I want to refine how I publish.

At the moment I am using what are called explicit post types. Meaning that I manually choose which post type a particular post belongs to before publishing — picking the appropriate create form to publish from.

However I have been thinking more and more about implicit post types — post types whose contents define what sort of post it is. Going the way of implicit may also see me abolishing the need for post-type-specific areas of my site.

I could still do this to some degree I suppose. e.g. If a post doesn’t have a title, it’s a note; If it has a location, it’s a checkin; etc.

The only way to see how this is going to go is to build it and actually publish with it for a while, I guess.

Update 8th February 2021: I now use WordPress for my website and have done for a few years now.

Bypassing Laravel’s CSRF Middleware on selected routes (from 5.1)

A handy way to have some of your routes skip the middleware for CSRF protection. Handy in some situations.

Laravel does a great job at protecting us from cross-site request forgeries – or C.S.R.F. for short.But sometimes you may not wish to have that layer present. Well with Laravel 5.1 you can very easily bypass this middleware, simply by populating an array in the following file:

app/Http/Middleware/VerifyCsrfToken.php

Within this class you can add a protected property — an array — called $except, which will tell Laravel to use this middleware except for the ones you specify here.

A complete example could be:

protected $except = [
    'ignore/this/url',
    'this/one/too',
    'and/this',
];

So for those three URLs, the CSRF middleware would be skipped.

I finally did it

Update: I’m now using WordPress again.

Ever since I can remember having my own website, for the most part, I have used WordPress. I’ve loved using it and will always recommend it to clients as being the best way for them to publish online. Of course, with me being a web developer I’m always wanting to tinker. There isn’t a day that goes by without me messing about with something on my site.A concept that I learned about, about six months ago or so, was that of the indieweb. Now this isn’t some new platform or anything like that. Rather it’s a set of principles, a way to approach publish on the web. In fact it’s the oldest method of publishing on the web: publishing on your own website.WordPress is great for publishing. But as my needs became more complex, and needing to make more fine grained choices when publishling different sorts of posts, I found my self neglecting to post notes/thoughts because the process of ticking the correct meta values and category was a bit combersome. The process adding a quick note or thought, like that of jotting something in a notepad, should be quick and effortless.So what I wanted was a stripped back UI from which to post notes, as well as other kinds of posts. Because of this I decided to go with a framework as opposed to a CMS platform, choosing ultimately to go with Laravel.The process is still on going as I still need to configure 301 redirects from my old site. But at least I am now publishing from my new site, and new domain, and it’s never been easier to do.