realtebo

realtebo

Member Since 2 Years Ago

Experience Points 10,880
Experience Level 3

4,120 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 81
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

13 May
2 months ago

realtebo started a new conversation After Upgrading To 5.8, € Is Printed Litterally

I've this helper

function currency($value, $euro = true, $decimal = 2)
{
    return ($euro ? '€ ' : '') . number_format($value, $decimal, ',', '.');
}

I'm using in my blades, since project started with a v5.4, like this

<td nowrap="" class="">
    {{ currency($record->purchase_list_price) }}
</td

Before upgrading, I was getting printed on my webpage

 €21.02

Now I get

  &euro;21.02

Why? What's changed and how to avoid this escaping?

02 May
2 months ago

realtebo started a new conversation Is There A Way To Optimize Css?

My goal is to 'simply' remove duplicated rules from final css

for example, including bootstrap.scss and then overriding it ca cause to have 2

html { 
  font-family: ... something ...
}

definitions

And I'd like to have only one in the generated one.

15 Apr
3 months ago

realtebo left a reply on What's The Recommended Way To Build Form?

Thanks.

We were using laravel collective package, But project is dead.

12 Apr
3 months ago

realtebo started a new conversation What's The Recommended Way To Build Form?

I discovered just now that laravel collective package is died.

Whic is now the official/unofficial recommendation for build very very complex forms?

My situation is that I've about 30 variants of a very similar structure, but in every declination there is not only differences on which fields require, but also entire tabs of fields could be hidden or not, and also validation rules are sooooo different.

Initially, author of actual code used laravel collective for forms and jsvalidation package for integrate jquery validation.

He did a caos, a BIG caos, a WTF caos.

So I'm evaluating ways for a complete refactor, not only changing package, but also how to strcture code, blade inclusions, blade components, etc... etc... etc..

realtebo started a new conversation How To 'compose' The Route Definitions?

I have this main group

Route::group([
    'prefix' => 'backend',
    'middleware' => ['web']
], function () {
...

Inside it, I've this subgroup

Route::group([
        'middleware' => ['auth']
    ], function () {

With another subgroup

Route::group([
            'namespace' => 'Users',
            'prefix' => '',
        ], function(){

And inside this I've a tons of routes. I'd like to splite route definitions in a few files and the 'compose' the final route files.

I'd like to avoid brutal require (...).

Is there a way to load some routes from a file/class/helper/whatelse and 'inject' in the final file in the appropriate row? Like a blade has inclusion methods, ... something similar

08 Mar
4 months ago

realtebo left a reply on Laravel 5.5: "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" Method Is Deprecated

Damn, i am still on this problem to fix.

I tried to log $exception, to see what format is and decide if NOT send to sentry, but Log::* methods are not logging NOTHING here.

Why?

05 Mar
4 months ago

realtebo left a reply on Laravel 5.5: "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" Method Is Deprecated

I cannot understand how to workaround this. I cannot upgrade laravel project actually.

Is there a place where I can intercept this exception?

I am using sentry, and so getting some thousand of useless warning are killing my free plan (only 5k / month).

In app\Exceptions\Handler.php I've this piece of code, and I am trying to act on it

    public function report(Exception $exception)
    {
        if (app()->bound('sentry') && $this->shouldReport($exception)){
            app('sentry')->captureException($exception);
        }
    
        parent::report($exception);
    }

But in this point, I cannot use Log functions so I've no idea of exact format of $exception and how to say to NOT report to sentry !

01 Mar
4 months ago

realtebo started a new conversation From PDF To Excel With Laravel

Hi ! I've the need to convert PDF into Excel. These are customer orders.

I think to convert pdf to tiff using imagemagick (convert) and then from tiff to text and then parse extracted text to recreate the pdf.

Could you kindly suggest me a more 'drect' way? Is there any (paid ) sdk to obtain this?

28 Feb
4 months ago

realtebo left a reply on Laravel 5.5: "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" Method Is Deprecated

Is there a recommended fix/workaround ?

We are using sentry and so we do not want to hide nothing.

realtebo started a new conversation Laravel 5.5: "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" Method Is Deprecated

In my index.php I have

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);
$response->send();

The row

    $request = Illuminate\Http\Request::capture()

is causing a deprecation warning;

User Deprecated: The "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead.

How can I get rid of this?

Thanks in advance

13 Jan
6 months ago

realtebo started a new conversation App Works Served By `php Artisan Serve` But Not Using`nginx`

I created a new app using composer. I need 5.4 specifically for a test I need to do.

composer create-project --prefer-dist laravel/laravel blog "5.4.*"

I can run app using

php artisan server

But when triyng to serve it using nginx, I got the damn classic old blank white page.

Note: To simplify my life, because it's only a local dev virtual machine everything is owned by root:root and with permissions 777. So no permission problems.

ENV: I am working on a Ubuntu 16.04.5 vmware virtual machine, with 4 cpu + 4 gb ram and a lot of free space.

My /var/log/nginx/*.log files do not present me any kind of error.

Please, could you check my nginx config file?

server {

    listen       80;

    server_name  demo_app.ismyservice.space;
    
    root         /var/www/html/demo_app/public;

    add_header  X-Frame-Options "SAMEORIGIN";
    add_header  X-XSS-Protection "1; mode=block";
    add_header  X-Content-Type-Options "nosniff";

    charset     utf-8;

    index       index.php index.html index.htm;
    
    location / {
        try_files   $uri $uri/ /index.php?$query_string;
    }

    location    = /favicon.ico { access_log off; log_not_found off; }
    location    = /robots.txt  { access_log off; log_not_found off; }

    error_page  404 /index.php;

    location ~ \.php$ {
        fastcgi_pass    unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index   index.php;
        include         fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

}

I already checked /var/run/php/php7.2-fpm.sock

stat /var/run/php/php7.2-fpm.sock
  File: '/var/run/php/php7.2-fpm.sock'
  Size: 0               Blocks: 0          IO Block: 4096   socket
Device: 13h/19d Inode: 232         Links: 1
Access: (0660/srw-rw----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2019-01-13 17:00:29.014876613 +0100
Modify: 2019-01-13 16:47:33.710778131 +0100
Change: 2019-01-13 16:47:33.710778131 +0100
 Birth: -

Kindly, I am here asking an help to diagnose se problem!

13 Sep
10 months ago

realtebo left a reply on How To Query A 1-to-many Relation , Selecting And Filtering On Both Table?

array:2 [▼
  0 => array:3 [▼
    "query" => "select `names`.* from `names` 
    "bindings" => array:1 [▶]
    "time" => 8.0
  ]
  1 => array:3 [▼
    "query" => "select `address_text_field` as `my_address` from `addresses` where `id_of_the_name` in (?, ?, ?, ?, ?, ?, ?) and `address_text_field` like ? 
    "bindings" => array:8 [▶]
    "time" => 2.0
  ]
]

realtebo left a reply on How To Query A 1-to-many Relation , Selecting And Filtering On Both Table?

No, sorry, this is doing 2 queries, doesn't do a JOIN, why?

It first execute a select * on names and a select on addresses where id in (... list of names id )

realtebo left a reply on How To Query A 1-to-many Relation , Selecting And Filtering On Both Table?

This works, thanks.

Kindly, how can I add a WHERE on name.first_name field ?

realtebo started a new conversation How To Query A 1-to-many Relation , Selecting And Filtering On Both Table?

Names Table

id
first_name

Addresses Table

id
if_of_the_name        
address_text_field 

Name model class

public function addresses()
{
    return $this->hasMany(Address::class, 'if_of_the_name');
}

Address model class

public function name()
{
    return $this->belongsTo(Name::class, 'if_of_the_name');
}

My problem is that when I do this I got a SQL error

Name::with('indirizzi')->where('indirizzi.address_text_field ', 'like', '%something%')->get();

The error is that Eloquent does not use join at all. Is doing two querys. Also, I've no idea of how to select some fields only

I'd like to obtain a simple

SELECT names.first_name as my_first_name, addresses.address_text_field as my_address
FROM names
LEFT JOIN addresses
    ON names.id = addresses.if_of_the_name

Please, do not comment about not standard names, I cannot do nothing against this

06 Sep
10 months ago

realtebo left a reply on Is There A Way To Set Old() Values?

I'm reusing a form both for create and for edit

i'd like to avoid to test if old then old, otherwise if set the model->field show model-field.

Is there a way?

realtebo started a new conversation How To Avoid Mix At All In Development?

Is there a way to bypass mix while developing? Is sooooo slow on my specific environment.

I'd like to simply use my javascript and css 'as is' in development and then I'll manually run npm run production before releasing.

I know how handle dynamic inclusions, based on env, into my blade layout, but how to be able to 'load all js and css as is' in devlopment is out of my knowledge.

Is it possible?

07 Aug
11 months ago

realtebo started a new conversation How To Bind Parameter To Query?

I'ma trying to log SQL query executed, but I'd like to have a plain sql.

$query_array = DB::getQueryLog();
        foreach ($query_array as $query) {

            DB::table('sql_logger')->insert([
                'user_id'   => $request->user() ? $request->user()->id : null,
                'query'     => addslashes ($query["query"]),
                'bindings'  => json_encode($query["bindings"]),
            ]);
        }

Is there a way to bind without recreate the wheel

06 Aug
11 months ago

realtebo left a reply on Eloquent "Attach" - Which Event Is Fired?

@fico7489 : my goal is intercept events to register created_by, updated_by, and deleted_by.

Is there a way to make your package comunicate with the 'revisionable' package?

realtebo started a new conversation Can I Add Protected $dates To A Model Using A Trait?

In every model I'm adding

 protected $dates = ['deleted_at'];

to use with softDeletes.

Is there a way to add this line of code in a trait ? Actually I got this error

Illuminate\Database\Eloquent\Model and App\Traits<trait name> define the same property ($dates) in the composition of App\Models<model name>. However, the definition differs and is considered incompatible. Class was composed

I added

protected $dates = ['deleted_at'];

so I think it's identical... or not?

03 Aug
11 months ago

realtebo left a reply on How To Use Custom Pivots?

I need to use a class because I need some logs and I do log using class events.

So for use model event with custom logic bi need a pivot custom table

Anyway my question is how to use a class.

Thanks for your reply

realtebo started a new conversation How To Use Custom Pivots?

I am trying to use a custom pivot. Please ignore names. It's a test project to understand custom pivot.

Data relation is

FIRST <-- n : n --> SECOND

In the First model class I write

public function seconds() {
        return $this->belongsToMany('App\Models\Second')
                    ->using('App\Pivots\FirstsSecondsPivot');
}

and viceversa, in the Second model I write

public function firsts() {
        return $this->belongsToMany('App\Models\First')
                    ->using('App\Pivots\FirstsSecondsPivot');
}

the Pivot is

<?php

namespace App\Pivots;

use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Database\Eloquent\SoftDeletes;

class FirstSecondsPivot extends Pivot
{

    use SoftDeletes;
    protected $dates = [ 'deleted_at' ];

    protected $table = "first_to_second_pivot_table";
}

the table is 

id id_first id_second


In my controller, I've receiving both objects to be saved

First::create($request->input('first'))
                        ->seconds()
                        ->create($request->input('seconds'))
                        ->save();

First and Second object are saved, then I expect to see a new row in the first_to_second_pivot_table , or at minimum an error about name of fields ...

Insted, the sql error is about the table first_second not found; so Laravel is ignoring my pivot class at all, trying to use its default naming convention.

Question: what's the Laravel's way to use a custom pivot table? .

realtebo left a reply on Trait InteractsWithPivotTable: Add Attributes On Toggle Method

Hi, I reply to this old thread because I'm in the same situation.

i need to extend the pivot table and while I absolutely exlude to modify framework src, I've no idea of how tell my model to use my extended trait instead of it's default.

02 Aug
11 months ago

realtebo left a reply on Does Something Change If I Chain Instead Of Start Another Command?

... and in both case we cannot specify execute order, right ?

realtebo started a new conversation Does Something Change If I Chain Instead Of Start Another Command?

Sorry for absolutely strange title. My English is bad, suggest me a new title.

My questions is if does something changes beetween this two forms

mix.styles( .... ) .css(....);

and

mix.styles( .... );
mix .css(....);

I ask you because I've the strange need to do a sass to css conversion AND THEN use normal css command to pack the new file with the others

01 Aug
11 months ago

realtebo left a reply on What's The Simplets Way To Handle A Simple 3 Level Authorization?

I'm oriented to try Gates system (but actually not using any package).

Seems that our webapp will have a 95% of standard users, that will be authorized to do a 95% of 'things'.

a 4.99% of 'admins' which can do things (just as example) like create a new user

and 1 (we) supermegaiperadmin.

So every user will have a role column in the users table. Very basic.

Using gates we will define the few 'tasks' that elevated privileges (or a superman)

Something like

    Gate::define('create-user', function ($user) {
        return $user->role === 'ADMIN';
    });

    Gate::define('manage-admins', function ($user) {
        return $user->role === 'SUPERMEGAIPERADMIN';
    });

So the approach is a 'deny-all -> if logged, allow-all -execpt .... "

I see in the doc that Gates must be used in controller with the following syntax.

if (Gate::allows('create-users', $post)) {
   ...
}

if (Gate::denies('manage-admins', $post)) {
    ...
}

Question: is there a way to automatically call ... 'something' when invoking a controller action to be sure that a check is done at evey controller action?

From your comments, I'll look at possibility to create a little middleware with the goal to check automatically the logged user, if logged, versus what is trying to do.

Is there the situation where to use middleware? Or can I use something already made?

Or am I fully doing bad things?

realtebo left a reply on What's The Simplets Way To Handle A Simple 3 Level Authorization?

Thanks for suggestion. Probably it's a little too simple.

I'm looking for a simple, but declarative way to create 3 roles and 'actions' or 'tasks' that every user can do.

In the code, when need, I'd check with something like can().

I'm sorry to have only confused idea, but I am still tryin g to understand the system used magically by laravel with can; probably it could be the right way, I'am simply not enough trained to understand what to do... online tutorials I've found until now are so bad ...

I'll continue to experiment, study and Google, but I'll accept every suggestion :)

realtebo left a reply on Pivot Table: Cannot Listen To Events, But Timestamps Works

so it never calls your pivot model or event

But, actually my model is using timestamps and softDelete and all of these works.

Anyway, i simply give up.

Thanks

realtebo started a new conversation Pivot Table: Cannot Listen To Events, But Timestamps Works

I created a model for a pivot table only to track create, update and (soft)delete events.

These works. But when I attach my listeners to the same events, my listeners are not fired.

My goal is simply to populate fields: created_by, updated_by and deleted_by

This is my Trait, working for other models. It's the first time i try to use it with a pivot table

trait CrudUserTrait {

    
    static function bootCrudUserTrait() {

        // create a event to happen on updating
        static::creating(function($table)  {
            $table->created_by = Auth::user()->getAuthIdentifier();
        });

        // create a event to happen on deleting
        static::updating(function($table)  {
            $table->updated_by = Auth::user()->getAuthIdentifier();
        });

        // create a event to happen on saving
        static::deleting(function($table)  {
            $table->deleted_by = Auth::user()->getAuthIdentifier();
        });
    }
}

realtebo started a new conversation Blades Can Access $errors, So How To Access It From Controller?

I'd like to dump $errors using dump or DebugBar.

I am wondering how to do, because my blade can access

$errors->all()

But I am not able to dump $errors in my controller.

30 Jul
11 months ago

realtebo started a new conversation What's The Simplets Way To Handle A Simple 3 Level Authorization?

We can have

  • superadmin
  • admin
  • normal users

I see that we can use gate and/or policies ...

What's the most rapid way to handle this simple situation?

For example... i'd like to simply declarate who can do what in term of users and controler actions and leave to laravel to handle these checks.

Is it possible?

23 May
1 year ago

realtebo started a new conversation Problem Installing On Win10: You Should Verify That The "storage" And "bootstrap/cache" Directories Are Writable.

I (think) succesfully installed Vagrant and homestead on my Win10 development machine.

Actually I've this pointing:

/home/vagrant/code/<project_name> => D:/laravel/<project_name>

This folder exists on disk.

I enter via vagrant ssh and positioned into home/vagrant/code.

Runned

laravel new <project_name> --force

But got:

You should verify that the "storage" and "bootstrap/cache" directories are writable.

and no files created

28 Sep
1 year ago

realtebo left a reply on Is There A Serie About What's New In Laravel 5.5?

Oh, thank you!.

I was expecting it inside the skills/laravel category.... Strange that is not assigned to it

27 Sep
1 year ago

realtebo left a reply on How To Log Single Queries?

Thanks, but I need to log (to files or to db or whatever..) so where must I enableQueryLog and where getQueryLog() ?

Of course, I don't want to dd, but I understand that $query, before, the end(..) is an array of executed queries...

Where are the appropriate point to insert this code?

Is there no an event like 'query executed' to listen to?

realtebo started a new conversation Artisan: Calling A Command From Web Controller Require 6x Time Than Executing From Command Line

I've a artisan command pull:updates that run on webserver via cron. It takes <10 seconds.

I've created for utility on dev only a route /pull/updates that simply do

return Artisan::call('pull:updates');

It takes >60 seconds.

I've litterally no idea on why.

realtebo started a new conversation How To Log Single Queries?

I'd like to intercept EVERY single query (only on dev !) to index them. My goal is catch repeated query to cache them or to optimize by code flow.

I already enabled debugBar, and so I can see ALL of the query of a single page, but I cannot manually 'scan' every page.

26 Sep
1 year ago

realtebo started a new conversation Is There A Serie About What's New In Laravel 5.5?

I mean: https://laracasts.com/skills/laravel

I cannot see a "What's new in 5.5 ?" and I hope it will be added soon !

realtebo left a reply on How To Start Creating Service Provider?

Works !

cart.php class

<?php

namespace App\Cart;

use App\User;

class Cart {

    private $user;

    public function __construct(User $user)
    {
        $this->user = $user;
    }

    public function test()
    {
        echo  $this->user->email;
    }
}
public function register()
    {
        $this->app->singleton(Cart::class, function ($app) {
            return new Cart(Auth::user());
        });
    }

in controller

use App\Cart\Cart;
...
public function index(Request $request, Cart $cart)

in view

{{ $cart->test() }}

realtebo left a reply on How To Start Creating Service Provider?

@JackJones Thanks...

I've create App\Cart\Cart.php

<?php
namespace App\Cart;
class Cart {
    private $user;
    public function __construct(App\User $user)
    {
        $this->user = $user;
    }

    public function test()
    {
        dd($this->user);
    }
}

Then changed CartServiceProvider to register my class

use App\Cart\Cart;
..... 
public function register()
    {
        $this->app->singleton(Cart::class, function ($app, $user) {
            return new Cart($user);
        });
    }

But now ? How can Iinject my service provider?

realtebo started a new conversation How To Start Creating Service Provider?

I done this

php artisan make:provider CartServiceProvider

Then I added to config\app.php, inside `'providers' array this

App\Providers\CartServiceProvider::class,

This is the actual code , comment striped out, of the provider itself.

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class CartServiceProvider extends ServiceProvider
{

    public function boot()
    {
        //
    }


    public function register()
    {
        //
    }


    public function test()
    {
        return "Cart Service is working";
    }

}

I'm trying to use it into one of my controller.

I added

use App\Providers\CartServiceProvider;

Then into one of the controller action I tried to inject the provider

public function index(CartServiceProvider $cart)
    {
        return view('customer_area.dashboard')
                ->with('cart', $cart);
    }

I don't have modified yet the view.

When I access to index action of this controller, I got the exception

Unresolvable dependency resolving [Parameter #0 [ $app ]] in class Illuminate\Support\ServiceProvider

This is now obscure for me how to fix this....

25 Sep
1 year ago

realtebo started a new conversation On A Protected Route, How To Get Current User?

This is my actual code

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class CustomerAreaController extends Controller
{
    private $user;
    private $locale;

    public function __construct()
    {
        $this->middleware('auth');

        $this->user     = Auth::user();
        $this->locale   = $this->user ? $this->user->locale : 'it ';
        dd($this->user);
    }

    public function index()
    {
        return view('customer_area.dashboard')
                ->with('locale', $this->locale);
    }
}

My problem is this: Auth::user() returns null. How is it possible? If authenticated user was really null, the middleware should have redirected me to login pagre, or not?

So, how to get current user ?

realtebo left a reply on Password Resets Bring Me To A Situation Where Users Cannot More Login

the function $broker->reset accepts 2 arguments

the first is thye array credential , containing email, password and token the second is a callback

so the reset() function pass email and password to the calllback

I tried to dump user and password vars, and they were filled. Both before calling resetPassword, in the callback, both inside resetPassword.

i aboslutely cannnot undestand my resetPassword function doesn't hash properly.

This is the original code of resetPassword

protected function resetPassword($user, $password) { $user->password = Hash::make($password); $user->setRememberToken(Str::random(60)); $user->save(); event(new PasswordReset($user)); $this->guard()->login($user); }

And this is mine

protected function resetPassword($user, $password) { $user->password = Hash::make($password); $user->setRememberToken(Str::random(60)); $user->save(); event(new PasswordReset($user)); }

I really cannot understand if really the problem is here, but here $user is the right \App\User and $password arrives not encrypted (as argument), so It's not a problem of dataI pass to It.

But code is the same as framework's original one.... (here the github Link to this function)[https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Auth/ResetsPasswords.php#L103]

22 Sep
1 year ago

realtebo left a reply on Npm Run Dev - ARGGG!!

if, like me, you have a windows host + Vagrant box running on virtual box as provider, try to, from box SSH shell

npm install cross-env --non-bin-links

realtebo left a reply on Laravel Error In Project After Windows Reinstall

In config\app.php, there is this row

'key' => env('APP_KEY'),

who read the constant from env.php file.

Is the constant still set?

realtebo started a new conversation Password Resets Bring Me To A Situation Where Users Cannot More Login

In my ResetPasswordController I override the reset method to be able to handle multilangauges (but this is not the problem).

For documentation, it came from Illuminate/Foundation/Auth/ResetsPasswords.php

That's my code

public function reset(Request $request)
    {

        $this->validate($request, $this->rules(), $this->validationErrorMessages());

        // Here we will attempt to reset the user's password. If it is successful we
        // will update the password on an actual user model and persist it to the
        // database. Otherwise we will parse the error and return the response.

        // returns an array
        $credentials = $this->credentials($request);
        // returns an Illuminate\Auth\Passwords\PasswordBroker
        $broker      = $this->broker();
        $user        = $broker->getUser($credentials);

        // To DEBUJ
        //$tokens      = $broker->getRepository();

        $response = $broker->reset($credentials, function ($user, $password) {
                $this->resetPassword($user, $password);
        });

        $locale = $user->locale;

        // If the password was successfully reset, we will redirect the user back to
        // the application's home authenticated view. If there is an error we can
        // redirect them back to where they came from with their error message.
        return $response == Password::PASSWORD_RESET
            ? $this->sendResetResponse($response, $locale)
            : $this->sendResetFailedResponse($request, $response);
    }

Then I override resetPassword. Please note that at this point the password is still clear (not encrypted, I mean). I override it to avoid autologin after password reset.

Link to original code

protected function resetPassword($user, $password)
    {
        $user->password = Hash::make($password);
        $user->setRememberToken(Str::random(60));
        $user->save();
        event(new PasswordReset($user));
    }

Note: The whole process seems to work well; user password is updated into db, the remember token is regenerated, the reset_password table row is deleted and user is succesfully redirected to login page with a success alert box.

**The problem: ** the user now uses the new password and the system reply user not found....

21 Sep
1 year ago

realtebo started a new conversation How To Translate Or Customize Default Password Reset Email?

After a lot of digging into source code, following traits, facades and so on, I found what I think is the part of code really send the password reset email.

https://github.com/laravel/framework/blob/5.5/src/Illuminate/Auth/Notifications/ResetPassword.php

    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->line('You are receiving this email because we received a password reset request for your account.')
            ->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
            ->line('If you did not request a password reset, no further action is required.');
    }
}

I need to customize this message, not to translate the text.

I'm too far away now to understand where / how to override or extend or .. whatelse .... this method..

realtebo left a reply on How To Send Mailables Using Mail() Instead Of Smtp?

Thanks, I know this page, but I don't see anything about how to use Mailables with mail() instead of a specific driver.....

Can you direct me to the point?

realtebo started a new conversation How To Send Mailables Using Mail() Instead Of Smtp?

In a very old server, where actually lives a Wordpress installation, I'm testing a new webapp.

While in homestead/vagrant I succesfully send email using mailtrap.io, In the testing env I'd like to test the live sending, but I cannot use any smtp, mailing to mailtrap.io doesn't works and because it's a shared host I think it could be a problem.

Well, Wordpress now is using the basic php mail() command, and I'd like to send Mailables using the same method. Does it exist a way to do this?

20 Sep
1 year ago

realtebo left a reply on Auth: How To Check An Extra Field In Addition To Email And Password?

I found a well- working solution

In my LoginController.php I override two function from the trait AuthenticatesUsers;.

Note that the 2nd override is just to override the message to the user.

    /**
     * Attempt to log the user into the application.
     * NOTE: this override DO NOT uses at all the trait version
     * See: https://laravel.com/docs/5.5/authentication#authenticating-users
     *
     * @param  \Illuminate\Http\Request  $request
     * @return bool
     */
    protected function attemptLogin(Request $request)
    {
        return Auth::attempt(
            $this->credentials($request) + ["enabled" => true],
            $request->filled('remember')
        );
    }

    /**
     * Get the failed login response instance.
     * NOTE: this override DO NOT uses at all the trait version
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Symfony\Component\HttpFoundation\Response
     *
     * @throws ValidationException
     */
    protected function sendFailedLoginResponse(Request $request)
    {
        throw ValidationException::withMessages([
            $this->username() => [trans('auth.failed_or_account_not_activated')],
        ]);
    }