Connect with us

Laravel 5.8.8 Released (bugs fixed and new features )

kizinho

Published

on

Follow
Laravel 5.8.8 Released (bugs fixed and new features )
Photo: Naijacrawl

The Laravel team released Laravel 5.8.8 yesterday with a new query builder method along with the latest fixes and changes in the 5.8 branch.

 

First, a new Builder::forPageBeforeId() method was added to compliment an existing forPageAfterId().

 

These methods are useful to query for records before or after a given record. In the pull request author Tim MacDonald illustrates the following example to get the records around a “focused” post:

$posts = new Collection;

$posts = $posts->concat(ChatPost::forPageBeforeId(15, $focused->id)->get()->reverse());

$posts = $posts->push($focused);

$posts = $posts->concat(ChatPost::forPageAfterId(15, $focused->id)->get());

 

 

You can see the full list of fixes below, and the whole difference  between 5.8.7 and 5.8.8 on GitHub.

 

The full release notes for Laravel 5.8 are available in the GitHub 5.8 changelog:

 

v5.8.8

Added Added Illuminate\Database\Query\Builder::forPageBeforeId() method (#28011)


Fixed

BelongsToMany::detach() with custom pivot class (#27997)

Fixed incorrect event namespace in generated listener by event:generate command (#28007)

 

Fixed unique validation without ignored column (#27987)


Changed

 

Added parameters argument to resolve helper (#28020) Don’t add the path only if path is empty in compiled view (#27976)

 

Refactoring

Refactoring of env() helper (#27965)



kizinho

I am a software developer, like meeting people and love blogging, that's why I developed naijacrawl because that's what I love doing.

Continue Reading
Click To Comment

BE First To Comment


    Leave a Reply

    Your email address will not be published. Required fields are marked *

    How to convert image from png, jpg to webp image in Laravel

    kizinho

    Published

    on

    How to convert image from png, jpg to webp image in Laravel
    Photo: Naijacrawl

    Hi, folks will show how you can convert any image to webp image.

    Why Webp

    WebP is making headway in the image format space this year. The image format — which is developed by Google — uses both lossy and lossless compression by utilizing technology that Google purchased from On2 Technologies.


    WebP has been around a while now, actually, and it first made headlines in a 2010 Google press conference. But, like any new technology, it had some initial rough patches. Today, WebP is on version 1.0.0, so we thought it would be a great time to talk about what makes WebP so powerful, and why it’s a fantastic option for web designers and developers.


    Before I proceed to describe what WebP actually is, let us focus on why it matters—it’s not only about making images smaller, but it’s also about why and how the images need to be made smaller.


    You may have heard about design mistakes killing your SEO and conversion rates. While there are some aspects that CSS or JavaScript are responsible for, like blocking rendering, the images nowadays are a huge part of any website’s weight. Therefore, users on slower connections will have trouble interacting with your website (unless it’s an AMP).

    Just recently, It’s an interesting area of expertise, where you take care of lots of small things to deliver one big thing—a superfast, superlight website that reads on any device and looks amazing at the same time.


    Chances are, you’ve seen WebP images before. If you open Naijacrawl in Google Chrome, all of those thumbnails are going to be WebP thumbnails. If you were to open the Facebook app on your android phone, all of the images that you see would be WebP. It’s definitely being utilized by various companies around the world to increase performance.


    So let's see how you can do the same using laravel to convert your images to webp image.


    Note this works in all laravel versions


    I assumed you have a project already or you can create one by using this command


    composer create-project laravel/laravel webimage --prefer-dist


    You must have installed a composer before you can run the command.


    We need a controller so let's create one

    php artisan make:controller ImageWebpController
    


    Inside the controller, we will write a code that will process our image and convert it to webp inside a folder


    What it Requires

    file extension

    file name

    folder

    <?phpnamespace App\Http\Controllers;
    
    
    use Illuminate\Http\Request;
    use Illuminate\Support\Str;
    
    
    class ImageWebpController extends Controller {
    
    
        public function webpImage(Request $request) {
            if ($request->hasFile('file')) {
                $file = $request->file('file');
                $extension = $file->getClientOriginalExtension();
                $rand = '-' . strtolower(Str::random(10));
                $name = $rand . '.' . $extension;
                return $this->processImage($file, $name);
            }
        }
    
    
        private function processImage($file, $name) {
            $file->move(public_path('/test/image'), $name);
            //convert to webp 
            $webp = public_path() . '/test/image/' . $name;
            $im = imagecreatefromstring(file_get_contents($webp));
            $new_webp = preg_replace('"\.(jpg|jpeg|png|webp)$"', '.webp', $webp);
            imagewebp($im, $new_webp, 50);
            return [
                'message' => 'image successfully converted to webp. check your folder to see it'
            ];
        }
    
    
    }
    
    
    

    from what i did, i check if the request is a file before proceeding , have to get extension of the file and use it make a slug name for the image, because i don't want it to carry original name.

    $extension = $file->getClientOriginalExtension();
    

    I have to use str function to form a characters for the name of the image

     $rand = '-' . strtolower(Str::random(10));
    //final 
    name$name = $rand . '.' . $extension;
    

    I needed another private function because i want to separate my code for easy to read using processImage function.

     private function processImage($file, $name) {
            $file->move(public_path('/test/image'), $name);
            //convert to webp 
            $webp = public_path() . '/test/image/' . $name;
            $im = imagecreatefromstring(file_get_contents($webp));
            $new_webp = preg_replace('"\.(jpg|jpeg|png|webp)$"', '.webp', $webp);
            imagewebp($im, $new_webp, 50);
            return [
                'message' => 'image successfully converted to webp. check your folder to see it'
            ];
        }
    

    After i called it to the main function which is webpImage function .

    Inside processImage function , the file is moved to my public folder called test/image before converting it to webp image

    //get image that we want toconvert 
    $webp = public_path() . '/test/image/' . $name;
    //create the image       
     $im = imagecreatefromstring(file_get_contents($webp));
    //accept image extensions of jpg,png,webp 
    $im = imagecreatefromstring(file_get_contents($webp));        
    $new_webp = preg_replace('"\.(jpg|jpeg|png|webp)$"', '.webp', $webp);
    //make the webp image and set the quality to 50 //the more quality the more it becomes broght and increase mb// you can set to 100 which means no quality will be reduced        
    imagewebp($im, $new_webp,50);
    

    From my code i didn't add validation rule which you can do it if you needed it , just to make it allow only files and extension type


    Find this article helpful kindly share it.

    Continue Reading

    PhpStorm 2019.1 Provides Blade Debugging Support and a Laravel Code Style Preset

    kizinho

    Published

    on

    PhpStorm 2019.1 Provides Blade Debugging Support and a Laravel Code Style Preset
    Photo: Naijacrawl

    JetBrains announced the release of PhpStorm 2019.1.This week with debugging support for Blade (and Twig) templates and a new predefined Laravel code style configuration.

     

    Upgrade your Laravel applications to Laravel 5.8 and get XDebug ready to start debugging Laravel Blade templates in PhpStorm 2019.

     

    Thanks to a Laravel 5.8 contribution for including the Laravel 5.8 Blade Template File Path in compiled templates, now you can set a breakpoint directly in a blade file instead of having to search for the compiled template and setting a breakpoint: Another Laravel-related feature in PhpStorm 2019.1 is a predefined Laravel code style setting.

     

    You can configure it for your project from the preferences menu — Settings > Editor > Code Style > PHP and then select “set from > Predefined Style > Laravel”:

     

    If you want to get a quick overview of what’s new, check out this video from JetBrains: The official PhpStorm blog has a PhpStorm 2019.1 release announcement post with all the details of the release.

    Continue Reading

    Latest



    Face of Naijacrawl


    ChukwubuikemSunday ChukwubuikemSunday

    Sunday Chukwubuikem


    Higher - 09061773292

    Trending