<?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 Ahmad Yousef on Medium]]></title>
        <description><![CDATA[Stories by Ahmad Yousef on Medium]]></description>
        <link>https://medium.com/@ahmadyousefdev?source=rss-27c23029c586------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*wW8UTutJvaWHJYtU.jpg</url>
            <title>Stories by Ahmad Yousef on Medium</title>
            <link>https://medium.com/@ahmadyousefdev?source=rss-27c23029c586------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:09:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahmadyousefdev/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[Introducing Automs for Laravel]]></title>
            <link>https://ahmadyousefdev.medium.com/introducing-automs-for-laravel-bc0740f2c31d?source=rss-27c23029c586------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc0740f2c31d</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[code-generation]]></category>
            <category><![CDATA[package]]></category>
            <dc:creator><![CDATA[Ahmad Yousef]]></dc:creator>
            <pubDate>Sat, 13 Feb 2021 11:13:07 GMT</pubDate>
            <atom:updated>2021-02-13T11:13:07.400Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_jOc6STsXCTCxsaZRDb1A.jpeg" /></figure><p><a href="https://github.com/ahmadyousefdev/automs">Automs</a> is a tool that allows you to create a fully functional component for Laravel using its Jetstream dashboard only by one command line. This will help you create components for your management system or control panel easier and faster.</p><p>This package will generate a Laravel component with all its related files and they are</p><ol><li>The model</li><li>The controller</li><li>The migration</li><li>The views</li><li>And will also add the routes to the web route file.</li></ol><p>These files will be fully written and fully functional depending on their availability in the package library.</p><p>And all of that only by one command php artisan automs:create.</p><p>You can continue reading this article to see how it works, or you can <a href="https://youtu.be/fAWRMLBYqRA">watch this video</a> that teaches you the installation and the usage of this package.</p><p><strong>First</strong>, let’s create a new Laravel app called test</p><pre>laravel new test</pre><p><strong>Then</strong>, let’s call our package via composer</p><pre>composer require &quot;ahmadyousefdev/automs&quot; --dev</pre><p><strong>After that</strong>, let’s complete the installation of Jetstream and livewire by running these 5 commands.</p><pre>php artisan jetstream:install livewire<br>npm install<br>npm run dev<br>php artisan migrate<br>php artisan vendor:publish --tag=jetstream-views</pre><p>Don’t forget to change the database credentials in your .env file</p><p>Now that our environment is ready, let’s begin creating components for our control panel</p><p>For example, we want a component named <strong>Article</strong>, Let’s write</p><pre>php artisan automs:create article</pre><p>We can see this message</p><pre>Full model Article and its components were generated successfully</pre><p>which mean that our files are generated, and they are:</p><ol><li>app/Models/Article.php</li><li>app/Http/Controllers/ArticleController.php</li><li>database/migrations/2021_02_11_184617_create_articles_table.php</li><li>resources/views/articles/index.blade.php</li><li>resources/views/articles/create.blade.php</li><li>resources/views/articles/show.blade.php</li><li>resources/views/articles/edit.blade.php</li></ol><p>Now we can run php artisan migrate to migrate our newly created table</p><p>If everything worked, we will see the articles link in the navigation bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZtKPyqvDzEWR-F8lEpeoXQ.png" /></figure><p>After clicking on it, we can see the index where all the article records will be shown</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yfdf60KQAWS0IC39A1ZIuA.png" /></figure><p>We can create a new article by clicking “create article” button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MIuWTV4oU_SEa3ThsXOr8w.png" /></figure><p>And that’s it!</p><p>If the component is not available, for example if we write php artisan automs:create carWe will see this message Empty model Car and its components were generated successfully</p><p>This will create the component files for us in a minimal form, we can add our migration details and complete the views and controller as we like.</p><p>You can read the Readme file for more details. And if you want to contribute and help us add more components to this package, please read the contributing section on the readme file.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc0740f2c31d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multiple Image Uploader with Laravel 5.5 and Dropzone.js]]></title>
            <link>https://ahmadyousefdev.medium.com/multiple-image-uploader-with-laravel-5-5-and-dropzone-js-6f39974ba1c6?source=rss-27c23029c586------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f39974ba1c6</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[uploader]]></category>
            <category><![CDATA[ajax]]></category>
            <category><![CDATA[dropzone]]></category>
            <category><![CDATA[clipboard]]></category>
            <dc:creator><![CDATA[Ahmad Yousef]]></dc:creator>
            <pubDate>Wed, 18 Oct 2017 15:31:49 GMT</pubDate>
            <atom:updated>2017-10-18T15:31:49.587Z</atom:updated>
            <content:encoded><![CDATA[<p>In a lot of our projects we need to make a multiple image uploader. In this tutorial, We will make an advanced AJAX uploader. This uploader will:</p><ol><li>upload multiple images via AJAX.</li><li>show the thumbnails of those uploads using <a href="http://www.dropzonejs.com/">Dropzone.js</a></li><li>show the URL link of the uploaded images and copy it to the clipboard using <a href="http://clipboardjs.com/">clipboardjs</a>.</li></ol><p>The result will be like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*dMxIcmJYqSw4Y20nZEMpVQ.gif" /><figcaption>AJAX image uploader</figcaption></figure><h3><strong>Let’s start !</strong></h3><p><strong>The Controller:</strong></p><p>First of all, let’s make a controller for our upload function:</p><pre>php artisan make:controller UploadController</pre><p>let’s write our upload function (each line explained)</p><pre>public function upload(Request $request)<br>{<br>    // Creating a new time instance, we&#39;ll use it to name our file and declare the path<br>    $time = Carbon::now();<br>    // Requesting the file from the form<br>    $image = $request-&gt;file(&#39;file&#39;);<br>    // Getting the extension of the file <br>    $extension = $image-&gt;getClientOriginalExtension();<br>    // Creating the directory, for example, if the date = 18/10/2017, the directory will be 2017/10/<br>    $directory = <em>date_format</em>($time, &#39;Y&#39;) . &#39;/&#39; . <em>date_format</em>($time, &#39;m&#39;);<br>    // Creating the file name: random string followed by the day, random number and the hour<br>    $filename = str_random(5).<em>date_format</em>($time,&#39;d&#39;).<em>rand</em>(1,9).<em>date_format</em>($time,&#39;h&#39;).&quot;.&quot;.$extension;<br>    // This is our upload main function, storing the image in the storage that named &#39;public&#39;<br>    $upload_success = $image-&gt;storeAs($directory, $filename, &#39;public&#39;);<br>    // If the upload is successful, return the name of directory/filename of the upload.<br>    if ($upload_success) {<br>        return response()-&gt;json($upload_success, 200);<br>    }<br>    // Else, return error 400<br>    else {<br>        return response()-&gt;json(&#39;error&#39;, 400);<br>    }<br>}</pre><p>As we can see, we store the file using storeAs , in the storage that named public . that can be customized from config/filesystems you’ll see a public system there, I changed it to look like this:</p><pre>&#39;public&#39; =&gt; [<br>    &#39;driver&#39; =&gt; &#39;local&#39;,<br>    &#39;root&#39; =&gt; public_path(&#39;uploads&#39;),<br>    &#39;url&#39; =&gt; env(&#39;APP_URL&#39;).&#39;/uploads&#39;,<br>    &#39;visibility&#39; =&gt; &#39;public&#39;,<br>]</pre><p>This way, the files will be uploaded to public/uploads/ .</p><p><strong>The Route:</strong></p><p>In our routes/web file will add this post route which will go to our controller:</p><pre>Route::post(&#39;/upload&#39; , &#39;UploadController@upload&#39;);</pre><p><strong>The View:</strong></p><p>let’s make a blade file that contains our uploader and its javascript functions:</p><p>in head section in our blade file, we’ll add <a href="http://www.dropzonejs.com/">Dropzone.js </a>dependencies:</p><pre>&lt;script src=&quot;{{url(https://medium.com/&#39;js/dropzone.js&#39;)}}&quot;&gt;&lt;/script&gt;<br>&lt;link rel=&quot;stylesheet&quot; href=&quot;{{url(https://medium.com/&#39;css/dropzone.css&#39;)}}&quot;&gt;</pre><p>Next, we’ll create the uploading form:</p><pre>&lt;form action=&quot;{{ url(https://medium.com/&#39;/admin/upload&#39;) }}&quot; enctype=&quot;multipart/form-data&quot; class=&quot;dropzone&quot; id=&quot;my-dropzone&quot;&gt;<br>    {{ csrf_field() }}<br>&lt;/form&gt;</pre><p>Notice that we added csrf_field() . The form will not work properly without it!</p><p>now, let’s start adding the footer scripts:</p><p>First, let’s add clipboardjs script, which we’ll be using to copy the URL of the uploaded images</p><p>The first script will be the upload script:</p><pre>&lt;script&gt;<br>    <em>Dropzone</em>.options.myDropzone = {<br>        paramName: &#39;file&#39;,<br>        maxFilesize: 5, // MB<br>        maxFiles: 20,<br>        acceptedFiles: &quot;.jpeg,.jpg,.png,.gif&quot;,<br>        init: function() {<br>            this.on(&quot;success&quot;, function(file, response) {<br>                var a = document.createElement(&#39;span&#39;);<br>                a.className = &quot;thumb-url btn btn-primary&quot;;<br>                a.setAttribute(&#39;data-clipboard-text&#39;,&#39;{{url(https://medium.com/&#39;/uploads&#39;)}}&#39;+&#39;/&#39;+response);<br>                a.innerHTML = &quot;copy url&quot;;<br>                file.previewTemplate.appendChild(a);<br>            });<br>        }<br>    };<br>&lt;/script&gt;</pre><p><em>If you want to stop right here, and you don’t need to copy the URLs, you can delete the </em>init<em> function from the above script </em>init:function(){...}<em> and you’ll be done!</em></p><p>In the above script, specifically on success function, we can see that we made a variable a which is a span that will be embedded after each uploaded thumbnail.</p><p>This span has a class thumb-url and a new attribute that called data-clipboard-text which contains the response from our upload function.</p><p>Our span also has the classes btn btn-primary , those are boostrap classes, we will be using bootstrap to show the tooltip when the user click to copy the URL.</p><p>Let’s add the clipboard js:</p><pre>&lt;script src=&quot;{{url(https://medium.com/&#39;js/clipboard.min.js&#39;)}}&quot;&gt;&lt;/script&gt;</pre><p>Now let’s write our function:</p><pre>&lt;script&gt;<br>    <em>$</em>(&#39;.thumb-url&#39;).tooltip({<br>        trigger: &#39;click&#39;,<br>        placement: &#39;bottom&#39;<br>    });<br><br>    function <em>setTooltip</em>(btn, message) {<br>        <em>$</em>(btn).tooltip(&#39;hide&#39;)<br>            .attr(&#39;data-original-title&#39;, message)<br>            .tooltip(&#39;show&#39;);<br>    }<br><br>    function <em>hideTooltip</em>(btn) {<br>        setTimeout(function() {<br>            <em>$</em>(btn).tooltip(&#39;hide&#39;);<br>        }, 500);<br>    }<br><br>    var <strong><em>clipboard </em></strong>= new Clipboard(&#39;.thumb-url&#39;);<br><br>    <strong><em>clipboard</em></strong>.on(&#39;success&#39;, function(e) {<br>        e.clearSelection();<br>        <em>setTooltip</em>(e.trigger, &#39;Copied!&#39;);<br>        <em>hideTooltip</em>(e.trigger);<br>    });<br><br>    <strong><em>clipboard</em></strong>.on(&#39;error&#39;, function(e) {<br>        e.clearSelection();<br>        <em>setTooltip</em>(e.trigger, &#39;Failed&#39;);<br>        <em>hideTooltip</em>(e.trigger);<br>    });<br>&lt;/script&gt;</pre><p>This way, when the user click on the copy button, it will show a tooltip that says copied! and the URL will be copied to the clipboard!</p><p>I hope you find this tutorial helpful</p><p>Nice coding! 🌹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f39974ba1c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Useful Color Generators in SCSS]]></title>
            <link>https://ahmadyousefdev.medium.com/useful-color-generators-in-scss-f2232a1d964e?source=rss-27c23029c586------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2232a1d964e</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[sass]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[scss]]></category>
            <dc:creator><![CDATA[Ahmad Yousef]]></dc:creator>
            <pubDate>Wed, 19 Jul 2017 09:49:40 GMT</pubDate>
            <atom:updated>2017-07-19T09:49:40.484Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3czWtQimE-KqMPEvvFj71w.png" /></figure><p>Writing color classes for your project could take a lot of your time. luckily, SCSS functions will make this easier. In this tutorial, we will learn how to make:</p><ol><li>background set</li><li>color set</li><li>shadow set</li></ol><p>We will start by making our Color list:</p><pre>$list : (<br>        silver: #bdc3c7,<br>        asbestos: #7f8c8d,<br>        blue: #3498db,<br>        wet-asphalt: #34495e,<br>        purple: #8e44ad,<br>        green: #2ecc71,<br>        red: #c0392b,<br>        pink: #e74c3c,<br>        carrot: #e67e22,<br>        orange: #f39c12<br>);</pre><p>Now, let’s make our mixins:</p><pre>// This mixin will generate background-color property for the colors in our list<br>@mixin background-color($args) {<br>  background-color: $args;<br>}</pre><pre>// This mixin will generate color property for the colors in our list<br>@mixin inner-color($args) {<br>  color: $args;<br>}</pre><pre>//This mixin will generate box-shadow property for the colors in our list<br>@mixin shadow-color($args) {<br>  box-shadow: inset 0 123px 190px -30px $args; // of course you can change the values to suit your work<br>}</pre><p>To generate the above mixins from our list, we have to write this function:</p><pre>@each $name,$color in $list {<br>  .#{$name}-background {@include background-color($color);}<br>  .#{$name}-color {@include inner-color($color);}<br>  .#{$name}-shadow {@include shadow-color($color)}<br>}</pre><p>The above code will take each color from our list and generate three classes for it, for example, if we take our first color silver: #bdc3c7 we will see those classes in our compiled css file:</p><pre>.silver-background {<br>background-color: #bdc3c7;<br>}<br>.silver-color {<br>color: #bdc3c7;<br>}<br>.silver-shadow {<br>box-shadow: inset 0 123px 190px -30px #bdc3c7;<br>}</pre><p>That’s all 😄</p><p><em>In the same way, you can write any mixins and functions to generate classes from the colors in the list, like border colors for example.</em></p><p>I hope you find this tutorial useful. 😙</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2232a1d964e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Middlewares in laravel]]></title>
            <link>https://ahmadyousefdev.medium.com/middlewares-in-laravel-9067b7fb7e46?source=rss-27c23029c586------2</link>
            <guid isPermaLink="false">https://medium.com/p/9067b7fb7e46</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[middleware]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Ahmad Yousef]]></dc:creator>
            <pubDate>Mon, 26 Sep 2016 08:50:47 GMT</pubDate>
            <atom:updated>2016-09-26T08:53:30.247Z</atom:updated>
            <content:encoded><![CDATA[<p>Middlewares are important for any laravel app, say that you want to make an admin page for admin users only, or accept the post only from an activated user, luckily, this is pretty easy in laravel.</p><h3>Using the Middlewares:</h3><p>There are two basic ways to use middlewares in laravel:</p><ol><li>With Routing:</li></ol><pre>// For multiple routes:<br>Route::group([&#39;middleware&#39; =&gt; [&#39;middleware_name&#39;]], function()<br>{ //put your routes here}</pre><pre>// OR for a single route:<br>Route::get(&#39;/&#39;, function () {})-&gt;middleware(&#39;middleware_name&#39;);</pre><p>2. With _construct:</p><pre>// For All functions in the controller:<br>public function __construct()<br>{ <br>$this-&gt;middleware(&#39;middleware_name&#39;);<br>}</pre><pre>// Or for only some of them:<br>public function __construct()<br>{ <br>$this-&gt;middleware(&#39;middleware_name&#39;,<br>[&#39;only&#39; =&gt;[&#39;create&#39;,&#39;store&#39;,&#39;edit&#39;,&#39;update&#39;]]);<br>}</pre><pre>// Or except some of them:<br>public function __construct()<br>{<br>$this-&gt;middleware(&#39;middleware_name&#39;,<br>[&#39;except&#39; =&gt;[&#39;index&#39;,&#39;show&#39;]]);<br>}</pre><h3>Making a middleware:</h3><p>Let’s make a middleware “isActivated” that will check the if the user has activated his account or not <em>(Assuming that we have a Boolean column “is_activated” in our users table)</em>:</p><p><strong>First, </strong>we will make a middleware named “IsActivated” by running this command:</p><pre>php artisan make:middleware IsActivated</pre><p>This will generate a middleware in “ /app/Http/Middleware/”</p><p>Let’s take a look at this middleware:</p><pre>&lt;?php</pre><pre>namespace App\Http\Middleware;</pre><pre>use Closure;</pre><pre>class IsActivated<br>{<br>    /**<br>     * Handle an incoming request.<br>     *<br>     * <a href="http://twitter.com/param">@param</a>  \Illuminate\Http\Request  $request<br>     * <a href="http://twitter.com/param">@param</a>  \Closure  $next<br>     * <a href="http://twitter.com/return">@return</a> mixed<br>     */<br>    public function handle($request, Closure $next)<br>    {<br>        return $next($request);<br>    }<br>}</pre><p>Now we can write the code that will ensure “is_activated” is true:</p><p><strong>Let’s replace</strong> the “handle” function with this code:</p><pre>public function handle($request, Closure $next)<br>    {<br>        $activated= Auth::user()-&gt;is_activated;<br>        if ($activated !== 1 )<br>        {<br>            return redirect()-&gt;back()-&gt;withErrors(array(&#39;message&#39; =&gt; &#39;You did not active your email yet, pleas active your email&#39;));<br>        }<br>        return $next($request);<br>    }</pre><p>As we can see, this function will check the current user row in database and search for “is_activated” column, if it’s not equal to 1 (you can use this instead: “<em>!($activated)” </em>) and then return an error message if failed or proceed to the next request.</p><p><strong>After that, </strong>we will go to <em>“app/Http/Kernel.php”</em> and add our middleware to the <em>“ $routeMiddleware”</em> array <em>(Note: You can see some useful middlewares there that you can use in your app)</em>:</p><pre>protected $routeMiddleware = [<br>        .....<br>        &#39;isActivated&#39;=&gt;\App\Http\Middleware\ActivatedUser::class,<br>    ];</pre><p><em>Notice that we named our middleware “isActivated”.</em></p><p>By that we finished making our middleware and now we can use it as a constructor in our controller or in a route like I mentioned above :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9067b7fb7e46" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>