FabioPacifici

FabioPacifici

Member Since 1 Year Ago

Rome

Head of IT/Web Development at United Kingdom

Experience Points 30,520
Experience Level 7

4,480 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 302
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

08 Jun
1 week ago

FabioPacifici left a reply on Password Reset Link, Incorrect Format And Invalid Token - Laravel 5.7 Multi Language

Finally figured all out, if anyone needs it:

Issue 1:

To adjust the link of the button inside the password reset email body we need to:

make a new password reset notification class Edit the ResetPassword notification class and its constructor to accept the token Overide the method on the user model Let’s start by making a new notification class using the following artisan command:

php artisan make:notification ResetPassword

Then we modify the file in app/Notifications/ResetPassword.php in the following way:

use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification; 

Above we import the new ResetPassword notification class then change class in the following way, adding the extends ResetPasswordNotification and token inside the construct like so:

class ResetPassword extends ResetPasswordNotification
{
use Queueable;
public $token;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($token)
{
$this->token = $token;
}

Continuing in the same file, we need to edit the toMail method like so:

/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$locale = app()->getLocale();
return (new MailMessage)
->subject('Reset your password - ' . config('app.name'))
->line('Hey this email was sent to you because you requested a password change for your order.')
->action('Reset Password', url($locale . '/password/reset', $this->token))
->line(' if you did not request a password change, please ignore this email.');
}

Now we need to override the method sendPasswordResetNotification inside the User class, in the file app/Http/User.php

First we Import the new ResetPassword class at the top

use App\Notifications\ResetPassword;

Then we Override the method

public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPassword($token));
}

Issue 2:

On the reset.blade.php view, the request returns the locale “en” instead of the password reset token value.

If I dd($request->all()) on the [email protected] method this is what I was gettting:

array:5 [▼
“_token” => “YrwPp06e6dV3iVlyQ59y1lvcNvOwCoQr0bIyAwgX”
“token” => “en”
“email” => “[email protected]”
“password” => “password”
“password_confirmation” => “password”
]

This is solved by Changing the showResetForm method from:

         public function showResetForm(Request $request, $token = null)
            {
                return view('auth.passwords.reset')->with(
                    ['token' => $token, 'email' => $request->email]
                );
            }

To:

  public function showResetForm(Request $request, $token = null)
            {
        $token = $request->token;

        return view('auth.passwords.reset')->with(
            ['token' => $token, 'email' => $request->email]
        );
        }

I wrote a complete multi-language guide for future reference, it's available on my site: https://fabiopacifici.com/laravel-5-7-multi-language-complete-guide/

05 Jun
1 week ago

FabioPacifici left a reply on Password Reset Link, Incorrect Format And Invalid Token - Laravel 5.7 Multi Language

Just found the cause related to the issue 2:

On the reset.blade.php view, the request returns the locale “en” instead of the password reset token value.

If I dd($request->all()) on the [email protected] method this is what I was gettting:

array:5 [▼
“_token” => “YrwPp06e6dV3iVlyQ59y1lvcNvOwCoQr0bIyAwgX”
“token” => “en”
“email” => “[email protected]”
“password” => “password”
“password_confirmation” => “password”
]

This is solved by Changing the showResetForm method from:

         public function showResetForm(Request $request, $token = null)
            {
                return view('auth.passwords.reset')->with(
                    ['token' => $token, 'email' => $request->email]
                );
            }

To:

  public function showResetForm(Request $request, $token = null)
            {
        $token = $request->token;

        return view('auth.passwords.reset')->with(
            ['token' => $token, 'email' => $request->email]
        );
        }
30 May
2 weeks ago

FabioPacifici left a reply on Password Reset Link, Incorrect Format And Invalid Token - Laravel 5.7 Multi Language

@LARAFEVER - Hi Larafever, thanks for your reply. Yes, the routes are in a group with a prefix, however passing the {token} to the post request on the reset method for the ResetPasswordController makes the request to fail.

thanks anyway for your time. Cheers

27 May
3 weeks ago

FabioPacifici started a new conversation Password Reset Link, Incorrect Format And Invalid Token - Laravel 5.7 Multi Language

Hello everyone, and thanks in advance for your time.

I am working on a multi-language site, and all seems working fine until I started doing the reset password views.

I have two issues, where I would appreciate your help as I didn't manage to figure out what's wrong:

  1. The button inside the password reset email has an incorrect format: localhost/{token}/password/reset instead of localhost/{locale}/password/reset/{token}

  2. Why when I visit the page typing the password reset URL correctly into the browser like localhost/en/password/reset/token-token, and submit the form the validation fails and returns the password reset token is invalid?

What would be the best practice here? Should I make a new notification class for the password reset link to fix the point one?

Given that I type the URL manually into the browser, then shouldn't the password reset token validation work as it is?

Inside the web.php routes file I have the following routes:

Route::get('/password/email/', 'Auth\[email protected]')->name('password.email');
        Route::post('/password/email/', 'Auth\[email protected]')->name('password.email');

        Route::get('/password/reset/{token}', 'Auth\[email protected]')->name('password.reset');
        Route::post('/password/reset', 'Auth\[email protected]')->name('password.reset');

The password.reset view looks like posts to the following route:

                    <form method="POST" action="{{ route('password.reset', app()->getLocale()) }}">


The ResetPasswordController:


<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;

class ResetPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset requests
    | and uses a simple trait to include this behavior. You're free to
    | explore this trait and override any methods you wish to tweak.
    |
    */

    use ResetsPasswords;

    /**
     * Where to redirect users after resetting their password.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    public function redirectTo()
    {
        return app()->getLocale() . '/home';
    }

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }
}

25 May
3 weeks ago

FabioPacifici left a reply on Why The Mailable Fails When The Csv Attachment Has Many Rows?

Digging a bit deeper with the issue that seems related to the file size as you kindly have pointed out this is what I have found:

  • the e-mail works fine if the .csv file attached has a maximum of 28 rows, and it's total size is 3.65 KB.
  • if the csv file has 29 rows or more that the email is not fired and telescope do not log the request as expected.
  • if I try to compress the file manually then attach it to the mailable, nothing is sent at all. No matter how many rows there are inside the csv file I compressed.

When I check the requests on Telescope, after trying to attach the csv file with over 29 rows, don't see the GET /import request that I would expect to see, but inside the log I can see that the email was logged and includes the results form the csv file too with a stacktrace at the end.

Deleted the log content of today, and checked its content again after only one attempt, and with a file of just 29 rows to trow the error, and I noticed that it has the following stacktrace:

String data, right truncated: 1406 Data too long for column 'content' at row 16..

Tests Imported. Email report notification sent to: [\\"[email protected]\\"]\"},\"response_status\":302,\"response\":\"Redirected to http:\/\/127.0.0.1:8000\/home\",\"duration\":2988,\"hostname\":\"LAPTOP-FAB\"}, 2019-05-25 16:22:54, request, 8dc5ac38-1561-45c4-aee4-ae6819482318), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?)) at /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: 22001): SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'content' at row 16 at /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458)
[stacktrace]
#0 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('insert into `te...', Array, Object(Closure))
#1 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(459): Illuminate\Database\Connection->run('insert into `te...', Array, Object(Closure))
#2 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(411): Illuminate\Database\Connection->statement('insert into `te...', Array)
#3 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2541): Illuminate\Database\Connection->insert('insert into `te...', Array)
#4 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/telescope/src/Storage/DatabaseEntriesRepository.php(117): Illuminate\Database\Query\Builder->insert(Array)
#5 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/telescope/src/Telescope.php(491): Laravel\Telescope\Storage\DatabaseEntriesRepository->store(Object(Illuminate\Support\Collection))
#6 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/telescope/src/ListensForStorageOpportunities.php(45): Laravel\Telescope\Telescope::store(Object(Laravel\Telescope\Storage\DatabaseEntriesRepository))
#7 [internal function]: Laravel\Telescope\Telescope::Laravel\Telescope\{closure}()
#8 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Object(Closure), Array)
#9 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(75): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#10 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure), Object(Closure))
#11 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Container/Container.php(572): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Object(Closure), Array, NULL)
#12 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(965): Illuminate\Container\Container->call(Object(Closure))
#13 /mnt/c/Users/Fabio/projects/Laravel/test-project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(191): Illuminate\Foundation\Application->terminate()
#14 /mnt/c/Users/Fabio/projects/Laravel/test-project/public/index.php(60): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\RedirectResponse))
#15 /mnt/c/Users/Fabio/projects/Laravel/test-project/server.php(21): require_once('/mnt/c/Users/Fa...')
#16 {main}
"} 

FabioPacifici left a reply on Why The Mailable Fails When The Csv Attachment Has Many Rows?

@TRAY2 - Hi Tray, thanks for your reply. I don't actually think it is a size problem for now, however, I will compress the final attachment, thank for the lead.

FabioPacifici left a reply on Why The Mailable Fails When The Csv Attachment Has Many Rows?

@BOBBYBOUWMANN - Hi Bobby, thanks for your reply. The file I am using during my tests is only a portion of the final attachment that I would like to send, and is only 464 KB, it has only 3700 rows.

However, the final attachment that is almost 80000 rows is 11 mb only.

Anyway yes, you are right. Most providers do not allow large attachments a link will be a better approach, thanks for your lead. It means I will then need to use an external storage disk to achieve that, as my application runs inside a custom device, and it's not accessible to the public so it won't be possible to generate that link where the user can download the attachments.

FabioPacifici left a reply on Why The Mailable Fails When The Csv Attachment Has Many Rows?

Hi Bobby, thanks for your reply. The file I am using during my tests is only a portion of the final attachment that I would like to send, and is only 464 KB, it has only 3700 rows.

However, the final attachment that is almost 80000 rows is 11 mb only.

Anyway yes, you are right. Most providers do not allow large attachments a link will be a better approach, thanks for your lead. It means I will then need to use an external storage disk to achieve that, as my application runs inside a custom device, and it's not accessible to the public so it won't be possible to generate that link where the user can download the attachments.

FabioPacifici started a new conversation Why The Mailable Fails When The Csv Attachment Has Many Rows?

Hello everyone, hope you are doing well.

I am trying to send an email with a large CSV file attached, it works fine if the file has a simple line of text like "hello word" but when the attachment is 70000 rows the mail is not dispatched and I got no errors on screen.

The file is stored on the public storage, I am using using the log and telescope locally.

Inside the log I can see the email but not in telescope, when the attachment is large the request to the mailable class doesn't show up, but it does if the file has simply "hello word" in it.

Why is it doing that?

18 Feb
4 months ago

FabioPacifici left a reply on Laravel And NGINX All Routes Not Found

Thanks @filth you are a life saver!

04 Dec
6 months ago

FabioPacifici left a reply on I Need Some Guidance On Where To Start With Certain Project

Hi @josuerhg using Laravel+ vue.js is definitely one of your best options you have so far, but you can also try with Laravel+Angular.

If you don't know how to use vue then you can watch this: https://laracasts.com/series/learn-vue-2-step-by-step

If you want to try with Angular you might want to watch this, however is a bit outdated: https://laracasts.com/lessons/laravel-and-angular

If you go with Vue, then Laravel is a good way to approach your project. You will find an example component inside your Laravel 5.7 project folder to help you get started. Make sure to watch the vue step by step series and if you didn't already.

19 Nov
6 months ago

FabioPacifici left a reply on Import CSV Files Into DB, Laravel 5.7

Thank you all for your replies!

@talinon thanks for your tip! I managed to make it work using Laravel-Excel but I had to install some of the required libraries first.

So finally the csv file is imported like so:

The table schema

 Schema::create('speed_tests', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('server_id');
            $table->text('sponsor');
            $table->text('server_name');
            $table->text('timestamp');
            $table->decimal('distance');
            $table->integer('ping');
            $table->bigInteger('download');
            $table->bigInteger('upload');
            $table->text('share')->nullable();
            $table->ipAddress('ip_address');
            $table->timestamps();

The Laravel-Excel import class

<?php

namespace App\Imports;
use App\SpeedTest;
use Maatwebsite\Excel\Imports\HeadingRowFormatter;
use Maatwebsite\Excel\Concerns\ToModel;

class SpeedTestsImport implements ToModel
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        return new SpeedTest([
            'server_id'     => $row[0],
            'sponsor'       => $row[1], 
            'server_name'   => $row[2],
            'timestamp'     => $row[3],
            'distance'      => $row[4], 
            'ping'          => $row[5],
            'download'      => $row[6],
            'upload'        => $row[7],
            'share'         => $row[8],
            'ip_address'    => $row[9]
        ]);
    }
}

Inside the controller:

    public function import() 
    {
        Excel::import(new SpeedTestsImport, 'test.csv');

        return redirect('/')->with('success', 'All good!');
    }

And tested in my routes file

Route::get('/import', '[email protected]');

FabioPacifici started a new conversation Import CSV Files Into DB, Laravel 5.7

Hello all! how are you doing today? I would like to import information from a CSV file and store them inside a dedicated DB table. Then present the results inside a chart using charts.js. What would be the best and cleanest approach to achieve that today using Laravel 5.7, Vue and chart.js?

Thanks in advance

13 Nov
7 months ago

FabioPacifici left a reply on Please Bring Back The Older Laracasts Design

Hi @jeffreyway, just noticed that the tooltips are not appearing property on the profile page if you mouse hover or click the very first badges on the left or the last on the right the text is outside the screen for laptops and tablets.

07 Nov
7 months ago
02 Nov
7 months ago

FabioPacifici left a reply on How To Run Laravel Project Locally Without Using "php Aritsan Serve" Command?

@AbdulBazith If you client laptop is running Windows 10 you might want to enable WSL (Windows subsystem Linux) instead of using xamp then once everything is set up properly you can load your website on that laptop by simply visiting site.dev.

ignore the points where I am installing wp-cli on my environment.

At the end of the article you can find reference to the main post from valeryan.

https://fabiopacifici.com/my-development-environment-for-laravel-wordpress/

I hope it helps.