<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mahmoud Ahmed</title>
    <description>The latest articles on DEV Community by Mahmoud Ahmed (@mahmouditaly).</description>
    <link>https://dev.to/mahmouditaly</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F340175%2F4fde00dc-46b0-416c-860a-bc74a361919e.jpeg</url>
      <title>DEV Community: Mahmoud Ahmed</title>
      <link>https://dev.to/mahmouditaly</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mahmouditaly"/>
    <language>en</language>
    <item>
      <title>Custom your routes in Lumen</title>
      <dc:creator>Mahmoud Ahmed</dc:creator>
      <pubDate>Sun, 02 Aug 2020 17:42:18 +0000</pubDate>
      <link>https://dev.to/mahmouditaly/custom-your-routes-in-lumen-52ag</link>
      <guid>https://dev.to/mahmouditaly/custom-your-routes-in-lumen-52ag</guid>
      <description>&lt;p&gt;&lt;a href="https://scrutinizer-ci.com/g/Mahmoud-Italy/Lararoutes-lumen-custom-routes/?branch=master" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bj5zl3aX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://scrutinizer-ci.com/g/Mahmoud-Italy/Lararoutes-lumen-custom-routes/badges/quality-score.png%3Fb%3Dmaster" alt="Scrutinizer Code Quality" width="113" height="20"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lumen package to help you customize your routes.&lt;br&gt;
Specialize for whom using lumen, &lt;br&gt;&lt;br&gt;
If you don't you better do now, Lumen is stunningly micro-framework &lt;b&gt;Faster 4x than laravel&lt;/b&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installation
&lt;/h1&gt;

&lt;pre&gt;composer require lararoutes/lumen-custom-routes&lt;/pre&gt;

&lt;h1&gt;
  
  
  Usage
&lt;/h1&gt;

&lt;p&gt;Add those lines in top of routes/web.php&lt;/p&gt;

&lt;pre&gt;
  use Lararoutes\Lumen\CustomRoutes;
  $app = new CustomRoutes($router);
&lt;/pre&gt;

&lt;p&gt;That's it. done&lt;/p&gt;

&lt;h1&gt;
  
  
  Example
&lt;/h1&gt;

&lt;p&gt;Instead of doing this shit&lt;/p&gt;

&lt;pre&gt;
  $router-&amp;gt;get('posts', 'PostController@index');
  $router-&amp;gt;post('posts', 'PostController@store');
  $router-&amp;gt;get('posts/{id}', 'PostController@show');
  $router-&amp;gt;put('posts/{id}', 'PostController@update');
  $router-&amp;gt;delete('posts/{id}', 'PostController@destroy');
&lt;/pre&gt;

&lt;p&gt;We Can simple do this now&lt;/p&gt;

&lt;pre&gt;$app-&amp;gt;apiResource('posts', 'PostController');&lt;/pre&gt;

&lt;p&gt;However, you can also custom your routes as much as u want in Lararoutes\Lumen\CustomRoutes.php&lt;/p&gt;

&lt;pre&gt;
    function apiResoruce($uri, $controller)
    {
        $this-&amp;gt;app-&amp;gt;get($uri, $controller.'&lt;a class="mentioned-user" href="https://dev.to/index"&gt;@index&lt;/a&gt;');
        $this-&amp;gt;app-&amp;gt;post($uri, $controller.'&lt;a class="mentioned-user" href="https://dev.to/store"&gt;@store&lt;/a&gt;');
        $this-&amp;gt;app-&amp;gt;get($uri.'/{id}', $controller.'&lt;a class="mentioned-user" href="https://dev.to/show"&gt;@show&lt;/a&gt;');
        $this-&amp;gt;app-&amp;gt;put($uri.'/{id}', $controller.'@update');
        $this-&amp;gt;app-&amp;gt;delete($uri.'/{id}', $controller.'@destroy');

        // feel free to add more..

    }
&lt;/pre&gt;

&lt;h1&gt;
  
  
  Credits
&lt;/h1&gt;


&lt;ul&gt;

    &lt;li&gt;&lt;a href="https://github.com/Mahmoud-Italy" rel="noopener noreferrer"&gt;Mahmoud Italy&lt;/a&gt;&lt;/li&gt;

    &lt;li&gt;&lt;a href="https://github.com/Mahmoud-Italy/Lararoutes-lumen-custom-routes/graphs/contributors" rel="noopener noreferrer"&gt;All Contributors&lt;/a&gt;&lt;/li&gt;

  &lt;/ul&gt;
&lt;h1&gt;
  
  
  License
&lt;/h1&gt;

&lt;p&gt;The MIT License (MIT). Please see License File for more information.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>lumen</category>
      <category>routes</category>
      <category>apiresource</category>
    </item>
    <item>
      <title>LaraSecure - IP Blocker</title>
      <dc:creator>Mahmoud Ahmed</dc:creator>
      <pubDate>Wed, 22 Jul 2020 14:30:17 +0000</pubDate>
      <link>https://dev.to/mahmouditaly/larasecure-ip-blocker-a71</link>
      <guid>https://dev.to/mahmouditaly/larasecure-ip-blocker-a71</guid>
      <description>&lt;h1&gt;
  
  
  IP Blocker
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://scrutinizer-ci.com/g/Mahmoud-Italy/LaraSecure-IPBlocker/?branch=master" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h0F7XFt---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://scrutinizer-ci.com/g/Mahmoud-Italy/LaraSecure-IPBlocker/badges/quality-score.png%3Fb%3Dmaster" alt="Scrutinizer Code Quality" width="113" height="20"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://scrutinizer-ci.com/code-intelligence" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GLQ9-Qwd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://scrutinizer-ci.com/g/Mahmoud-Italy/LaraSecure-IPBlocker/badges/code-intelligence.svg%3Fb%3Dmaster" alt="Code Intelligence Status" width="162" height="20"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A Laravel Package to increase the security of your websites by preventing access for users having blocked IP Addresses.&lt;/p&gt;

&lt;p&gt;However, you can add IP Addresses as many as you want into table called ipblockers which you want to disallow access to your site from spam etc.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installation
&lt;/h1&gt;

&lt;pre&gt;composer require larasecure/ip-blocker --dev&lt;/pre&gt;

&lt;h1&gt;
  
  
  Then publish the config
&lt;/h1&gt;

&lt;pre&gt;php artisan vendor:publish --tag=ipblocker&lt;/pre&gt;

&lt;pre&gt;php artisan migrate&lt;/pre&gt;

&lt;h1&gt;
  
  
  Usage
&lt;/h1&gt;

&lt;p&gt;Add this middleware in Kernel.php $routeMiddleware to restrict IP Addresses&lt;/p&gt;

&lt;pre&gt;'IPBlocking' =&amp;gt; \Larasecure\IPBlocker\Middlewares\IPBlocking::class&lt;/pre&gt;

&lt;p&gt;Add IPBlocking middleware to route group for which you want to restrict access.&lt;/p&gt;

&lt;pre&gt;
  Route::group(['middleware' =&amp;gt; 'IPBlocking'], function(){
    // you routes..
  });
&lt;/pre&gt;

&lt;p&gt;or you can injected in RouteServiceProvider.php&lt;/p&gt;

&lt;pre&gt;
  protected function mapApiRoutes()
    {
        Route::prefix('api')
            -&amp;gt;middleware(['api', 'IPBlocking'])
            -&amp;gt;namespace($this-&amp;gt;namespace)
            -&amp;gt;group(base_path('routes/api.php'));
    }
&lt;/pre&gt;

&lt;p&gt;or just add middleware to single route&lt;/p&gt;

&lt;pre&gt;
  Route::get('/', function () {
    //
  })-&amp;gt;middleware('IPBlocking');
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Users will be redirect to "403 | Forbidden" page if their IP exist on ipblockers table.&lt;/b&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Security
&lt;/h1&gt;

&lt;p&gt;If you discover any security related issues, please email &lt;a href="mailto:mahmoud.italy@outlook.com"&gt;mahmoud.italy@outlook.com&lt;/a&gt; instead of using the issue tracker.&lt;/p&gt;

&lt;h1&gt;
  
  
  Credits
&lt;/h1&gt;


&lt;ul&gt;

    &lt;li&gt;&lt;a href="https://github.com/Mahmoud-Italy" rel="noopener noreferrer"&gt;Mahmoud Italy&lt;/a&gt;&lt;/li&gt;

    &lt;li&gt;&lt;a href="https://github.com/Mahmoud-Italy/Larafast-fastApi/graphs/contributors" rel="noopener noreferrer"&gt;All Contributors&lt;/a&gt;&lt;/li&gt;

  &lt;/ul&gt;
&lt;h1&gt;
  
  
  License
&lt;/h1&gt;

&lt;p&gt;The MIT License (MIT). Please see License File for more information.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Becoming a (good) developer</title>
      <dc:creator>Mahmoud Ahmed</dc:creator>
      <pubDate>Sat, 18 Jul 2020 11:04:50 +0000</pubDate>
      <link>https://dev.to/mahmouditaly/becoming-a-good-developer-23k1</link>
      <guid>https://dev.to/mahmouditaly/becoming-a-good-developer-23k1</guid>
      <description>&lt;p&gt;Hello again. In this post, I will walk you through the topics which might be helpful to support your goal to become a good and successful developer.&lt;/p&gt;

&lt;p&gt;This post assumes you are already at least an entry level developer regardless of the programming language.&lt;/p&gt;

&lt;p&gt;So, let’s dive into the concepts to become a good developer.&lt;/p&gt;

&lt;h1&gt;
  
  
  Learn the core concepts
&lt;/h1&gt;

&lt;p&gt;The core concepts of programming in general is helpful no matter which programming language background you are from. Learning the core concepts of the programming in general or for a specific programming language can help you boost your confidence, and it can also leverage your skills on how you can approach to a problem by simply applying the concepts.&lt;/p&gt;

&lt;p&gt;For example, if you belong to the php programming background. You should checkout its core concepts, like, data types (variables), conditional statements (if/else/else if), control statements (for/foreach/while/do..while), OOP (Object oriented programming) concepts. Object oriented programming concepts are similar for most of the programming languages.&lt;/p&gt;

&lt;p&gt;Keep in mind, if you have concepts clear for one programming language, you can easily adopt another programming language. I can say this by my experience. I have been a php developer since last 3 years, and in those last 3 years I have learned too many different things about the workings of php programming language and the core concepts behind it. And since last 1 year, I was able to adopt javascript and dart (used in flutter). Which is great in comparison of learning php in 3 years and other 2 programming languages in just 1 year.&lt;/p&gt;

&lt;p&gt;So take this seriously, take time to learn about the programming language you are engaged into.&lt;/p&gt;

&lt;h1&gt;
  
  
  Read Code
&lt;/h1&gt;

&lt;p&gt;For new developers, this point may seem like, what the hell. Why should I read code while I should be typing it. But, reading code is a good practice to improve your skills and is followed my most of the experienced developers.&lt;/p&gt;

&lt;p&gt;Where should you read the code ? Github….😊.&lt;/p&gt;

&lt;p&gt;As a developer you might have used some kind of library. Is it worth studying the library ? Of course. Go ahead and check the code of any library you might have used. You may be surprised what approaches can be used to solve a problem differently. By reading others’ code you can learn new techniques to acheive something more efficiently. Bonus, you can undestand how the library works, which at some point of time is useful, because as a developer you may need a customized solution with some functionality of a library.&lt;/p&gt;

&lt;p&gt;If you are going to work on an existing project, take it as an opportunity to read the code someone else has wrote. Reading code is a good practice and should be considered important on your journey towards becoming a good developer.&lt;/p&gt;

&lt;p&gt;P.S. Learning by mistakes is a good thing, and learning by others’ mistakes is even better. Reading others’ code can help you avoid the mistakes they might have made.&lt;/p&gt;

&lt;h1&gt;
  
  
  Write readable code (well)
&lt;/h1&gt;

&lt;p&gt;Along with reading the code of others, it is also important to write the readable code.&lt;/p&gt;

&lt;p&gt;How can I make my code readable ?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use appropriate names for variables, methods and functions.
Split each method and function so that each method have single responsibility.&lt;/li&gt;
&lt;li&gt;Splitting method per responsibility can also help in implementing DRY (Don’t repeat yourself) concept.&lt;/li&gt;
&lt;li&gt;Avoid concurrency. (Don’t write code that works in the same way for different places, instead make a single place more capable and responsible for the task).&lt;/li&gt;
&lt;li&gt;If you are going to create classes which in core have the same architecture but corresponds to different entities create an abstact class for them instead of creating the classes with same properties and methods.&lt;/li&gt;
&lt;li&gt;Create trait classes if you are attaching functionality to more than one class.&lt;/li&gt;
&lt;li&gt;The points above are the core ideas, it may differ from the view point of the programming language you might belong to, but every programming language have support for writing code using these approaches.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why should I write readable code ?&lt;/p&gt;

&lt;p&gt;No one would like to work on the code which can not be understood. Even you will curse the developer who might have wrote code that is not readable. So the sake of the art of development, write code that is readable and understadable, so that anyone can undestand your code and can start working on it asap.&lt;/p&gt;

&lt;h1&gt;
  
  
  Learn techniques, not tools
&lt;/h1&gt;

&lt;p&gt;Tools help you to find your way around the problem, but techniques will always stay besides you no matter what tools/programming language you use. Tools come and go. It is good to get familier with the tools you use but don’t rely on them.&lt;/p&gt;

&lt;p&gt;Where can I learn techniques ?&lt;/p&gt;

&lt;p&gt;Out there, in this open source world, there are plenty of implementation in libraries, projects of different techniques. Read code, find different techniques inside them. Here, above discussed point Read Code makes more sense. Follow good developers on Twitter, follow blogs which publishes this kind of articles.&lt;/p&gt;

&lt;p&gt;Learning is a never ending process, but ultimately it makes you better overtime.&lt;/p&gt;

&lt;h1&gt;
  
  
  Share the knowledge
&lt;/h1&gt;

&lt;p&gt;Are you afraid of forgetting the concepts you might have learned ? Here is my tip for making them permenant part of yourself.&lt;/p&gt;

&lt;p&gt;Sharing what you know.&lt;/p&gt;

&lt;p&gt;Teaching what you have learned to other developers is a good practice. Teaching is a process where your mind needs to be precise. And don’t take it as a responsibility, but take it as a goodwill of your knowledge. The knowledge you have aquired was ultimately shared by someone else. So act your part. Share what you have learned.&lt;/p&gt;

&lt;p&gt;Sharing your knowledge makes the learned concepts concrete. Teaching process needs clear knowledge of the concept you are going to teach. So your mind automatically does the process of clearing the concepts if it were not already before you teach it to someone else.&lt;/p&gt;

&lt;h1&gt;
  
  
  Be responsible
&lt;/h1&gt;

&lt;p&gt;Take responsibility of your work and/or your teams’ work. If there has been some fault because of you, take responsibility of the fault. Rectify your mistakes and resolve them.&lt;/p&gt;

&lt;p&gt;This is a very important process, beacause taking responsibility of your mistakes, and resolving them will make you more vigilant before making similar kind of faults/problems, also you will have a solution if you have already resolved similar kind of problems.&lt;/p&gt;

&lt;p&gt;This process will also make you more confident. Also you will be in possesion of new wits with each mistake. 😇&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Being a (good) developer is not a milestone, its a process. You have to stay with the principles whichever helps your become better, either some from this article or from anywhere else.&lt;/p&gt;

&lt;p&gt;Let me know, if I have missed anything in the comments.&lt;br&gt;
This article written by Afaz Khatri&lt;/p&gt;

</description>
      <category>developer</category>
    </item>
    <item>
      <title>Larafast/fastApi package</title>
      <dc:creator>Mahmoud Ahmed</dc:creator>
      <pubDate>Wed, 15 Jul 2020 16:15:37 +0000</pubDate>
      <link>https://dev.to/mahmouditaly/larafast-fastapi-package-egh</link>
      <guid>https://dev.to/mahmouditaly/larafast-fastapi-package-egh</guid>
      <description>&lt;h1&gt;
  
  
  Larafast FastAPI
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://scrutinizer-ci.com/g/Mahmoud-Italy/Larafast-fastApi/?branch=master" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oJQzDUzE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://scrutinizer-ci.com/g/Mahmoud-Italy/Larafast-fastApi/badges/quality-score.png%3Fb%3Dmaster" alt="Scrutinizer Code Quality" width="106" height="20"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://scrutinizer-ci.com/g/Mahmoud-Italy/Larafast-fastApi/build-status/master" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fwH5fXqw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://scrutinizer-ci.com/g/Mahmoud-Italy/Larafast-fastApi/badges/build.png%3Fb%3Dmaster" alt="Build Status" width="87" height="20"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://scrutinizer-ci.com/code-intelligence" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2lwbR_LG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://scrutinizer-ci.com/g/Mahmoud-Italy/Larafast-fastApi/badges/code-intelligence.svg%3Fb%3Dmaster" alt="Code Intelligence Status" width="162" height="20"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What does mean FastAPI:
&lt;/h1&gt;

&lt;p&gt;A Fastapi Laravel package to help you generate CRUD API Controllers and Resources, Model.. etc&lt;/p&gt;

&lt;h1&gt;
  
  
  What actually do?
&lt;/h1&gt;

&lt;p&gt;Suppose you are building an api, and you want to create controller and resources and model and factory.. etc, then you have to do a ton of other tedious and to be honest, boring things like creating migrations, model factories, the controller, form validation and adding all !.&lt;/p&gt;

&lt;p&gt;So what FastAPI does is when you tell it the model name, it will do all those boring things. When it's done you have the following:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Blog.php&lt;/li&gt;
    &lt;li&gt;BlogController.php ship with code already exists&lt;/li&gt;
    &lt;li&gt;BlogStoreRequest.php and BlogUpdateRequest.php&lt;/li&gt;
    &lt;li&gt;BlogResoure.php&lt;/li&gt;
    &lt;li&gt;Timestamped create_blogs_table.php migration file&lt;/li&gt;
    &lt;li&gt;BlogFactory.php&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Installation
&lt;/h1&gt;

&lt;pre&gt;composer require larafast/fastapi --dev&lt;/pre&gt;

&lt;h1&gt;
  
  
  Then publish the config
&lt;/h1&gt;

&lt;pre&gt;php artisan vendor:publish --tag=fastApi&lt;/pre&gt;

&lt;h1&gt;
  
  
  Example
&lt;/h1&gt;

&lt;pre&gt;php artisan fastApi Blog&lt;/pre&gt;

&lt;p&gt;Once done, it will show you the details of the files generated.&lt;/p&gt;

&lt;pre&gt;
Factory created successfully

Created Migration: 2020_07_14_125128_create_blogs_table

Model created successfully

Controller created successfully

Request created successfully

Request created successfully

Resource created successfully
&lt;/pre&gt;

&lt;h1&gt;
  
  
  Snapshot of BlogController
&lt;/h1&gt;

&lt;pre&gt;
namespace App\Http\Controllers;

use App\Blog;
use Illuminate\Http\Request;
use App\Http\Requests\BlogUpdateRequest;
use App\Http\Requests\BlogStoreRequest;
use App\Http\Resources\BlogResource;

class BlogController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $rows = BlogResource::collection(Blog::fetchData(request()-&amp;gt;all()));
        return response()-&amp;gt;json(['data' =&amp;gt; $rows], 200);
    }

    /**
     * Store a newly created resource in storage.
     *
     * &lt;a class="mentioned-user" href="https://dev.to/param"&gt;@param&lt;/a&gt;  BlogStoreRequest  $request
     * @return \Illuminate\Http\Response
     */
    public function store(BlogStoreRequest $request)
    {
        try {
            Blog::create($request-&amp;gt;all());
            return response()-&amp;gt;json(['message' =&amp;gt; ''], 201);
        } catch (\Exception $e) {
            return response()-&amp;gt;json(['message' =&amp;gt; 'Unable to create entry, '. $e-&amp;gt;getMessage()], 500);
        }
    }

    /**
     * Display the specified resource.
     *
     * &lt;a class="mentioned-user" href="https://dev.to/param"&gt;@param&lt;/a&gt;  \App\Blog  $blog
     * @return \Illuminate\Http\Response
     */
    public function show(Blog $blog)
    {
        $row = new BlogResource(Blog::findOrFail($blog));
        return response()-&amp;gt;json(['row' =&amp;gt; $row], 200);
    }

    /**
     * Update the specified resource in storage.
     *
     * &lt;a class="mentioned-user" href="https://dev.to/param"&gt;@param&lt;/a&gt;  OrderUpdateRequest  $request
     * &lt;a class="mentioned-user" href="https://dev.to/param"&gt;@param&lt;/a&gt;  \App\Blog  $blog
     * @return \Illuminate\Http\Response
     */
    public function update(BlogUpdateRequest $request, Blog $blog)
    {
        try {
            $blog-&amp;gt;update($request-&amp;gt;all());
            return response()-&amp;gt;json(['message' =&amp;gt; ''], 200);
        } catch (\Exception $e) {
            return response()-&amp;gt;json(['message' =&amp;gt; 'Unable to update entry, '. $e-&amp;gt;getMessage()], 500);
        }
    }

    /**
     * Remove the specified resource from storage.
     *
     * &lt;a class="mentioned-user" href="https://dev.to/param"&gt;@param&lt;/a&gt;  \App\Blog  $blog
     * @return \Illuminate\Http\Response
     */
    public function destroy(Blog $blog)
    {
        try {
            $blog-&amp;gt;delete();
            return response()-&amp;gt;json(['message' =&amp;gt; ''], 200);
        } catch (\Exception $e) {
            return response()-&amp;gt;json(['message' =&amp;gt; 'Unable to delete entry, '. $e-&amp;gt;getMessage()], 500);
        }
    }
}

&lt;/pre&gt;

&lt;h1&gt;
  
  
  Snapshot of Blog Model
&lt;/h1&gt;

&lt;pre&gt;
namespace App;

// use Stroage;
use Illuminate\Database\Eloquent\Model;
// use Illuminate\Database\Eloquent\SoftDeletes;

class Blog extends Model
{
    // use SoftDeletes;
    protected $guarded = [];

    // imageable polymorphic
    public function image() {
        return $this-&amp;gt;morphOne(Image::class, 'imageable');
    }

    // handle attributes
    public function setImageAttribute($value){
        $imageName = time().'.'.$value-&amp;gt;extension();  
        Storage::disk('public')-&amp;gt;put('uploads/'.$imageName, $value);
        $this-&amp;gt;image()-&amp;gt;save($imageName);
    }

    // fetch Data
    public static function fetchData($value='')
    {
        // this way will fire up speed of the query
        $obj = self::query();

          // langauges in case you use multilanguages transactions package..
          if(isset($value['locale'])) {
             app()-&amp;gt;setLocale($value['locale']);
          }

          // search for multiple columns..
          if(isset($value['search'])) {
            $obj-&amp;gt;where(function($q){
                $q-&amp;gt;where('title', 'like','%'.$value['search'].'%');
                $q-&amp;gt;orWhere('body', 'like', '%'.$value['search'].'%');
                $q-&amp;gt;orWhere('id', $value['search']);
            });
          }

          // order By..
          if(isset($value['order'])) {
            $obj-&amp;gt;orderBy('id', $value['order']);
          } else {
            $obj-&amp;gt;orderBy('id', 'DESC');
          }



          // feel free to add any query filter as much as you want...




        $obj = $obj-&amp;gt;paginate($value['paginate'] ?? 10);
        return $obj;
    }
}

&lt;/pre&gt;

&lt;h1&gt;
  
  
  Snapshot of Blog Resource
&lt;/h1&gt;

&lt;pre&gt;
namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class BlogResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * &lt;a class="mentioned-user" href="https://dev.to/param"&gt;@param&lt;/a&gt;  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id'            =&amp;gt; $this-&amp;gt;id,
            'encrypt_id'    =&amp;gt; encrypt($this-&amp;gt;id),
            // 'image'         =&amp;gt; ($this-&amp;gt;image) ? $this-&amp;gt;image-&amp;gt;url : NULL,

            // 'title'      =&amp;gt; $this-&amp;gt;title,
            // 'body'       =&amp;gt; $this-&amp;gt;body,

            'dateForHumans' =&amp;gt; $this-&amp;gt;created_at-&amp;gt;diffForHumans(),
            'timestamp'     =&amp;gt; $this-&amp;gt;created_at
        ];
    }
}
&lt;/pre&gt;

&lt;p&gt;Now add the necessary fields and run&lt;/p&gt;

&lt;pre&gt;php artisan migrate&lt;/pre&gt;

&lt;p&gt;And that saved you an hour worth of repetitive and boring work which you can spend on more important development challenges.&lt;/p&gt;

&lt;h1&gt;
  
  
  Security
&lt;/h1&gt;

&lt;p&gt;If you discover any security related issues, please email &lt;a href="mailto:mahmoud.italy@outlook.com"&gt;mahmoud.italy@outlook.com&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Credits
&lt;/h1&gt;


&lt;ul&gt;

    &lt;li&gt;&lt;a href="https://github.com/Mahmoud-Italy" rel="noopener noreferrer"&gt;Mahmoud Italy&lt;/a&gt;&lt;/li&gt;

    &lt;li&gt;&lt;a href="https://github.com/Mahmoud-Italy/Larafast-fastApi/graphs/contributors" rel="noopener noreferrer"&gt;All Contributors&lt;/a&gt;&lt;/li&gt;

  &lt;/ul&gt;
&lt;h1&gt;
  
  
  License
&lt;/h1&gt;

&lt;p&gt;The MIT License (MIT). Please see License File for more information.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
    </item>
  </channel>
</rss>
