<br />
<b>Warning</b>:  The magic method SFML_Singleton::__wakeup() must have public visibility in <b>/home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php</b> on line <b>72</b><br />
{"id":60,"date":"2015-12-16T01:09:17","date_gmt":"2015-12-16T08:09:17","guid":{"rendered":"http:\/\/www.munderwood.ca\/?p=60"},"modified":"2015-12-16T01:43:32","modified_gmt":"2015-12-16T08:43:32","slug":"laravel-5-1-intermediate-quickstart-notes","status":"publish","type":"post","link":"https:\/\/www.munderwood.ca\/index.php\/2015\/12\/16\/laravel-5-1-intermediate-quickstart-notes\/","title":{"rendered":"Laravel 5.1 &#8220;intermediate quickstart&#8221; notes"},"content":{"rendered":"<p>I just ran through Laravel&#8217;s <a href=\"http:\/\/laravel.com\/docs\/5.1\/quickstart-intermediate\">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&#8217;m just recording a few notes for future reference about non-obvious things I encountered.<\/p>\n<h1>Error messages for simple typos<\/h1>\n<p>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<pre class=\"lang:php decode:true\">\/\/ 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<p>instead of the correct<\/p>\n<pre class=\"lang:default decode:true\">\/\/ Correct way to extend a template\r\n@extends('layout.app')<\/pre>\n<p>While obviously this is a simple typo that is entirely my own fault, the resulting error message,<\/p>\n<blockquote><p>FatalErrorException in fba8cddd62bd85dee11955629f018a61 line 24:<br \/>\nsyntax error, unexpected &#8216;,&#8217;<\/p><\/blockquote>\n<p>was not particularly enlightening, and I spent rather longer than I would have liked before noticing my error.<\/p>\n<h1>Importing models and policies for authorisation<\/h1>\n<p>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 <span class=\"theme:tomorrow lang:default highlight:0 decode:true crayon-inline\">app\/Providers\/AuthServiceProvider.php<\/span>\u00a0,<\/p>\n<pre class=\"lang:php decode:true\">protected $policies = [\r\n    Task::class =&gt; TaskPolicy::class,\r\n];<\/pre>\n<p>it fails to mention that this won&#8217;t work until the lines<\/p>\n<pre class=\"lang:php mark:5-6 decode:true\">\/\/ 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<p>are also added to the file.<\/p>\n<h1>Redirecting on login<\/h1>\n<p>Finally, if you create your own files from scratch for the tutorial instead of cloning <a href=\"http:\/\/github.com\/laravel\/quickstart-intermediate\">their repo<\/a>, then registering and logging in will appear to result in an error,<\/p>\n<blockquote><p>NotFoundHttpException in RouteCollection.php line 161:<\/p><\/blockquote>\n<p>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 <span class=\"theme:tomorrow lang:default highlight:0 decode:true crayon-inline \">\/home<\/span>\u00a0, which hasn&#8217;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 <span class=\"theme:tomorrow lang:default highlight:0 decode:true crayon-inline \">app\/Http\/Controllers\/Auth\/AuthController.php<\/span>\u00a0 and point it at\u00a0<span class=\"theme:tomorrow lang:default highlight:0 decode:true crayon-inline \">\/tasks<\/span>\u00a0instead.<\/p>\n<p>To do so, simply set the\u00a0<span class=\"theme:tomorrow lang:default highlight:0 decode:true crayon-inline \">$redirectTo<\/span>\u00a0property to the desired path, for example<\/p>\n<pre class=\"lang:php mark:9 decode:true\">\/\/ 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<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just ran through Laravel&#8217;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&#8217;m just recording a few notes for future reference about non-obvious things I encountered. Error messages for simple typos One interesting &#8230; <span class=\"more\"><a class=\"more-link\" href=\"https:\/\/www.munderwood.ca\/index.php\/2015\/12\/16\/laravel-5-1-intermediate-quickstart-notes\/\">[Read more&#8230;]<\/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}]}}