I just ran through Laravel’s intermediate quickstart tutorial<\/a>. On the whole it was rather well put together and worked with as little or as much copying and pasting as you felt like using. Here I’m just recording a few notes for future reference about non-obvious things I encountered.<\/p>\n One interesting thing to note is that using curly braces instead of round brackets in your blade templates can lead to not-obviously-related error messages. For instance, my first attempt at a template began with<\/p>\n instead of the correct<\/p>\n While obviously this is a simple typo that is entirely my own fault, the resulting error message,<\/p>\n FatalErrorException in fba8cddd62bd85dee11955629f018a61 line 24: was not particularly enlightening, and I spent rather longer than I would have liked before noticing my error.<\/p>\n The tutorial seems to leave out two important lines when it comes to authorising the deletion of tasks via policy. Specifically, when the tutorial gets to the point of adding the new policy to app\/Providers\/AuthServiceProvider.php<\/span>\u00a0,<\/p>\n it fails to mention that this won’t work until the lines<\/p>\n are also added to the file.<\/p>\n Finally, if you create your own files from scratch for the tutorial instead of cloning their repo<\/a>, then registering and logging in will appear to result in an error,<\/p>\n NotFoundHttpException in RouteCollection.php line 161:<\/p><\/blockquote>\n This can be surprising at first, and might make you think there actually is an error in your code, but of course it is essentially just a 404 Not Found error\u2014by default you are redirected to \/home<\/span>\u00a0, which hasn’t been created. One option would of course be to create home view. Another, which is what the Laravel repo does, is to override the redirection destination in app\/Http\/Controllers\/Auth\/AuthController.php<\/span>\u00a0 and point it at\u00a0\/tasks<\/span>\u00a0instead.<\/p>\n To do so, simply set the\u00a0$redirectTo<\/span>\u00a0property to the desired path, for example<\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":" I just ran through Laravel’s intermediate quickstart tutorial. On the whole it was rather well put together and worked with as little or as much copying and pasting as you felt like using. Here I’m just recording a few notes for future reference about non-obvious things I encountered. Error messages for simple typos One interesting … [Read more…]<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[4,5],"_links":{"self":[{"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/posts\/60"}],"collection":[{"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":14,"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":74,"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/posts\/60\/revisions\/74"}],"wp:attachment":[{"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.munderwood.ca\/index.php\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}Error messages for simple typos<\/h1>\n
\/\/ Incorrect way to extend a layout:\r\n\/\/ Note the use of {} instead of ()\r\n@extends{'layout.php'} \/\/ DO NOT DO THIS!\r\n<\/pre>\n
\/\/ Correct way to extend a template\r\n@extends('layout.app')<\/pre>\n
\nsyntax error, unexpected ‘,’<\/p><\/blockquote>\nImporting models and policies for authorisation<\/h1>\n
protected $policies = [\r\n Task::class => TaskPolicy::class,\r\n];<\/pre>\n
\/\/ app\/Providers\/AuthServiceProvider.php\r\n\r\n\/\/ ...\r\n\r\nuse App\\Task;\r\nuse App\\Policies\\TaskPolicy;\r\n\r\n\/\/ ...<\/pre>\n
Redirecting on login<\/h1>\n
\/\/ app\/Http\/Controllers\/Auth\/AuthController.php\r\n\r\nclass AuthController extends Controller\r\n{\r\n \/\/ ...\r\n\r\n use AuthenticatesAndRegistersUsers, ThrottlesLogins;\r\n\r\n protected $redirectTo = '\/tasks';\r\n\r\n \/\/ ...\r\n}<\/pre>\n