<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by m2de on Medium]]></title>
        <description><![CDATA[Stories by m2de on Medium]]></description>
        <link>https://medium.com/@m2de?source=rss-97335d4e11e6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PUpilFtNa0eb9S8pMh7jVw@2x.jpeg</url>
            <title>Stories by m2de on Medium</title>
            <link>https://medium.com/@m2de?source=rss-97335d4e11e6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 21:30:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@m2de/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Using Ajax User Login in Laravel (5.3, 5.4, 5.5, 5.6)]]></title>
            <link>https://codeburst.io/using-ajax-user-login-in-laravel-5-3-5-4-5-5-5-6-d4e30b47985f?source=rss-97335d4e11e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4e30b47985f</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[m2de]]></dc:creator>
            <pubDate>Wed, 03 Jan 2018 20:31:31 GMT</pubDate>
            <atom:updated>2018-01-04T17:34:50.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdSBTFgLyCZlrtTgdlmdHg.png" /></figure><p>In a recent project we wanted to handle the User Login form using Ajax submission to provide a better user experience.</p><p>The standard Auth scaffolding in Laravel 5.3+ however assumes that you use a regular POST method to authenticate the user credentials, which means when submitting the AJAX request with correct login credentials, the AJAX request itself is redirected to /home, or whatever page you are redirecting to after login, instead of retuning a JSON response.</p><p>This means that you can’t return any specific data to the front-end after the user has logged in.</p><p>Luckily Laravel has a reserved method, authenticated, which can be overwritten to return a custom response within your LoginController (which should be using theIlluminate\Foundation\Auth\AuthenticatesUsers trait). The method is empty by default so there is no need to worry about overwriting it here.</p><pre>...<br>    /**<br>     * The user has been authenticated.<br>     *<br>     * <a href="http://twitter.com/param">@param</a>  \Illuminate\Http\Request  $request<br>     * <a href="http://twitter.com/param">@param</a>  mixed  $user<br>     * <a href="http://twitter.com/return">@return</a> mixed<br>     */<br>    protected function authenticated(Request $request, $user)<br>    {<br>        // Send required response here<br>    }<br>...</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4e30b47985f" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/using-ajax-user-login-in-laravel-5-3-5-4-5-5-5-6-d4e30b47985f">Using Ajax User Login in Laravel (5.3, 5.4, 5.5, 5.6)</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simpler (better?) Laravel Authorization using Brandenburg]]></title>
            <link>https://codeburst.io/simpler-better-laravel-authorization-using-brandenburg-6ef9a24ef846?source=rss-97335d4e11e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ef9a24ef846</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[m2de]]></dc:creator>
            <pubDate>Wed, 29 Nov 2017 20:40:39 GMT</pubDate>
            <atom:updated>2017-11-30T14:58:20.057Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4_zNYAVP-kNqg62ew5a-cQ.png" /></figure><p>Most web applications which have an account or admin area typically require some kind of access-control which is commonly handled through the use of Roles and Permissions.</p><p>Since Laravel 5.1.11 the framework has provided a convenient way to handle Authorization in the form of Gates and Policies which allow for fine-grained control over determining who, and what, can be accessed.</p><p>The challenge is how to assign Users with Roles and Permissions, and how to integrate this with the standard Gate Policies.</p><p>This is where the <a href="https://github.com/Silvanite/brandenburg">Brandenburg</a> package <em>(which coincidentally I created!)</em> comes into play. I wanted to create a really easy, accessible way to assign permissions to users without needing to learn anything new outside of how to work with standard Laravel Gates and Policies.</p><p>Brandenburg provides a super thin-layer atop the standard Laravel Gates and Policies to easily assign permissions to users via roles and validate these within the Laravel Gates.</p><h4>Why not use an existing package?</h4><p>The reason why I decided to create my own package for this is because I wanted better separation of concerns when it comes to what should live in the Database, and what should live in the source-code.</p><p>Typically, the packages would suggest to validate if a user has a certain Role or Permission.</p><pre>// The code expects you to have the editor role in your database</pre><pre>if ($user-&gt;role === &#39;editor&#39;) {<br>    // grant access<br>}</pre><p>The problem with this approach is that it assumes that you created the editor role in your database because your source-code relies on it. It also means that if you create a new role or permission in your code, you have to create a new database entry to match this new role or permission.</p><p><a href="https://github.com/Silvanite/brandenburg">Brandenburg</a> uses Policies defined in the source only and does not require these to be duplicated in the Database. Instead, these permissions are assigned to Roles in the database, but the validation is done purely on the permission, not the Role itself, meaning that your source-code does not rely on you creating specific data in your DB.</p><pre>// The can-create-articles permissions exists in code only</pre><pre>if ($user-&gt;hasRoleWithPermission(&#39;can-create-articles&#39;)) {<br>    // grant access<br>}</pre><p>If you now create a new Gate Policy in code, Brandenburg will automatically make this available as a permission to assign to a Role in the database without and duplication. There also is an additional helper method which can be used to make this step optional by allowing any user access if nobody has been specifically granted access, which is great for future-proofing your code when initially you may not have multiple user roles.</p><pre>if ($this-&gt;nobodyHasAccess(&#39;can-create-articles&#39;) {<br>    // grant access<br>}</pre><h4>Closing thoughts</h4><p>The Brandenburg package is intended for really simple authorization and won’t be the right fit for everyone. If you need more advanced functionality, I would suggest looking at some of the more complex packages out there, even though they may not share the same approach.</p><p>I’m keen to hear any thoughts on the approach or the <a href="https://github.com/Silvanite/brandenburg">Brandenburg</a> package and hope it can help you with your next Laravel project. A full tutorial / demo will follow in the near-future. Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ef9a24ef846" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/simpler-better-laravel-authorization-using-brandenburg-6ef9a24ef846">Simpler (better?) Laravel Authorization using Brandenburg</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a modal dialog with Tailwind CSS]]></title>
            <link>https://codeburst.io/creating-a-modal-dialog-with-tailwind-css-42722c9aea4f?source=rss-97335d4e11e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/42722c9aea4f</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[m2de]]></dc:creator>
            <pubDate>Thu, 16 Nov 2017 14:11:01 GMT</pubDate>
            <atom:updated>2019-01-02T08:48:51.325Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7TfsFnCdqAyN5YKxdmkYQ.png" /></figure><p>As I’m exploring, learning and using the recently released Tailwind CSS “utility-first” css framework I wanted to share some of my learnings to hopefully help others get a better understand of the framework.</p><p>This example demonstrates how to create a basic modal dialog overlay using Tailwind CSS. It assumes some prior knowledge of HTML, Tailwind CSS and Javascript.</p><h4>Extending Tailwind</h4><p>In order to create an overlay effect by darkening out the webpage content we need to have a wrapper for our Modal with a semi-transparent background. As of writing this, Tailwind doesn’t have a default variable for this so I created a new set of colour options called smoke.</p><pre>var colors = {<br>...<br>&#39;smoke-darkest&#39;: &#39;rgba(0, 0, 0, 0.9)&#39;,<br>&#39;smoke-darker&#39;: &#39;rgba(0, 0, 0, 0.75)&#39;,<br>&#39;smoke-dark&#39;: &#39;rgba(0, 0, 0, 0.6)&#39;,<br>&#39;smoke&#39;: &#39;rgba(0, 0, 0, 0.5)&#39;,<br>&#39;smoke-light&#39;: &#39;rgba(0, 0, 0, 0.4)&#39;,<br>&#39;smoke-lighter&#39;: &#39;rgba(0, 0, 0, 0.25)&#39;,<br>&#39;smoke-lightest&#39;: &#39;rgba(0, 0, 0, 0.1)&#39;,<br>...<br>}</pre><p>Simply recompile Tailwind to generate the new colour variables.</p><h4>Semi-transparent overlay</h4><p>Next we can define the wrapper. We want this to fill the entire viewport and center align the content, both vertically and horizontally. All of this is really easy to do in Tailwind and Flexbox.</p><pre>&lt;div class=&quot;fixed pin z-50 overflow-auto bg-smoke-light flex&quot;&gt;</pre><pre>&lt;/div&gt;</pre><p>Each class is quite self-explanatory …</p><ul><li>fixed pin positions the div absolute and pins it to all corners filling the entire screen</li><li>z-50 makes sure it is top-most in the z-order to position it above other elements on the page</li><li>overflow-auto allows scrolling if the modal is bigger than the viewport</li><li>bg-smoke-light is our new semi-transparent background colour</li><li>flex makes it a Flexbox container so we can easily align/position the content</li></ul><h4>The dialog box</h4><p>Now we are ready to actually create our dialog box to display our message and call-to-actions.</p><pre>&lt;div class=&quot;relative p-8 bg-white w-full max-w-md m-auto flex-col flex&quot;&gt;</pre><pre>&lt;/div&gt;</pre><p>There’s a little bit more going on here so let’s break it down again:</p><ul><li>relative positions the document in the normal flow of the page</li><li>p-8 bg-white adds some padding to the dialog and gives it a white background</li><li>w-full max-w-md — I like this one. This makes the dialog full width but never let’s it grow more than the medium break point. You could take this one further and for example make the dialog full-screen on mobile devices by adding h-full md:h-auto. The md: are responsive helpers provided by Tailwind to only apply classes at specific breakpoints. Neat.</li><li>m-auto flex-col sets all margins to auto to center the dialog.</li><li>flex gives us flexbox control over elements inside. E.g. to align our buttons.</li></ul><h4>A close button/icon</h4><p>Finally, let’s add a close button in the corner.</p><pre>&lt;span class=&quot;absolute pin-t pin-b pin-r p-4&quot;&gt;<br>    &lt;svg class=&quot;h-12 w-12 fill-current text-grey hover:text-grey-darkest&quot; role=&quot;button&quot; xmlns=&quot;<a href="http://www.w3.org/2000/svg">http://www.w3.org/2000/svg</a>&quot; viewBox=&quot;0 0 20 20&quot;&gt;&lt;title&gt;Close&lt;/title&gt;&lt;path d=&quot;M14.348 14.849a1.2 1.2 0 0 1-1.697 0L10 11.819l-2.651 3.029a1.2 1.2 0 1 1-1.697-1.697l2.758-3.15-2.759-3.152a1.2 1.2 0 1 1 1.697-1.697L10 8.183l2.651-3.031a1.2 1.2 0 1 1 1.697 1.697l-2.758 3.152 2.758 3.15a1.2 1.2 0 0 1 0 1.698z&quot;/&gt;&lt;/svg&gt;<br>&lt;/span&gt;</pre><p>By now this should start making sense all on its own …</p><ul><li>absolute pin-t pin-r to position the button in the top right corner of the parent (our dialog).</li><li>p-4 to give it some personal-space</li></ul><p>Sweet, now you can hook up your buttons and triggers using your favourite Javascript and your modal dialog is ready. The linked example uses Vue.js to handle the Javascript because Vue is awesome.</p><h4>Final words</h4><p>A complete modal demo with some animations thrown in for good measure is available on my <a href="https://codepen.io/m2de/details/JONpmj/">Codepen</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*UdYoW108kmgtZ95BowYi1Q.gif" /></figure><blockquote>I hope this little tutorial was useful and highlights how intuitive Tailwind CSS is for quickly creating layouts and functional components.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42722c9aea4f" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/creating-a-modal-dialog-with-tailwind-css-42722c9aea4f">Creating a modal dialog with Tailwind CSS</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tailwind CSS IntelliSense in Visual Studio Code]]></title>
            <link>https://codeburst.io/tailwind-css-intellisense-in-visual-studio-code-9782375ec121?source=rss-97335d4e11e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9782375ec121</guid>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[m2de]]></dc:creator>
            <pubDate>Fri, 10 Nov 2017 19:59:57 GMT</pubDate>
            <atom:updated>2017-11-12T09:23:16.020Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*sPS47fFGdgfhRvIgkMBg3A.gif" /></figure><p>A quick tutorial on how to enable automatic class name completion in VS Code for the new Tailwind CSS framework.</p><p>Most people in the Laravel community will most likely already know about the recently released “Utility-first” Tailwind CSS framework. Like many I started to play around with it as soon as it was released. Almost straight away I found myself having to refer to the documentation quite a lot to look up what the class naming conventions are, and this slowed me down quite a lot.</p><p>I already use the extremely useful IntelliSense for CSS class names extension in my editor, Visual Studio Code, which gives you a list of classes available in your css files when typing class=&quot; in your html files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*f-jJmKCwYjz4uAfV9s5mog.gif" /><figcaption>IntelliSense in HTML files</figcaption></figure><p>Unfortunately the extension did not work when using the Laravel (Blade) file type. Given that a lot of those trying Tailwind are likely to be working in Blade like myself this was not ideal. I checked out the source code for the extensions and opened a PR to include Laravel Blade support. The creator, <a href="https://twitter.com/Zignd">Zignd</a>, of the extension was super nice and quickly merged my PR and released a new version – sweet, I could now quickly see what Tailwind generated classes I had available in my blade templates.</p><h4>Refactoring</h4><p>The next issue I ran into was trying to create tailwind component which are typically created using the @apply syntax inside css files. This allows you to make re-usable components which share the same styles, e.g. Buttons.</p><pre>.btn {<br>    @apply .font-bold .py-2 .px-4 .rounded;<br>}</pre><p>A quick discussion with the Zingd and a PR later we had IntelliSense auto-completion working in Css based extension, making it super quick to lookup what classes are available when creating components in Css files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*sPS47fFGdgfhRvIgkMBg3A.gif" /><figcaption>IntelliSense for Tailwind CSS apply syntax</figcaption></figure><h4>Notes</h4><p>It is important to note that the extension works by scanning css files linked in your html/php, so you need to compile tailwind before the IntelliSense can pick up the class names. You also need to re-index class names after making changes, but a simply click on the provided icon performs a re-scan as required and the updated classes are instantly available.</p><h4>Setup &amp; requirements</h4><ul><li>Visual Studio Code <a href="https://code.visualstudio.com/">https://code.visualstudio.com/</a></li><li>IntelliSense for CSS class names <a href="https://marketplace.visualstudio.com/items?itemName=Zignd.html-css-class-completion">https://marketplace.visualstudio.com/items?itemName=Zignd.html-css-class-completion</a></li><li>Tailwind CSS <a href="https://tailwindcss.com/">https://tailwindcss.com/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9782375ec121" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/tailwind-css-intellisense-in-visual-studio-code-9782375ec121">Tailwind CSS IntelliSense in Visual Studio Code</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>