Hesto

Hesto

Member Since 3 Years Ago

Łódź

PHP Developer at Łódź

Experience Points 22,900
Experience Level 5

2,100 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 268
Lessons
Completed
Best Reply Awards 7
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.

10 Nov
2 years ago
22 Oct
2 years ago

Hesto left a reply on [Collections] Random Method Wierd Behaviour

@Hawkleaf Well it works, it was my mistake when i test. Thanks.

21 Oct
2 years ago

Hesto left a reply on [Collections] Random Method Wierd Behaviour

@Hawkleaf thanks but still ids are not unique.

Hesto left a reply on [Collections] Random Method Wierd Behaviour

Read about range func. I just want 20 random unique user ids using collections.

Hesto started a new conversation [Collections] Random Method Wierd Behaviour

I try to fetch some unique user ids but it doesnt work. Can anyone explain me why?

 public function randomUniqueUsers()
    {
        //empty collection
        $uniqueUsers = collect();

        //fetch users
        $users = User::all();

        //key by user ids
        $users->keyBy('id');

        foreach (range(1 ,20) as $index) {
            $user = $users->random(); //get random user
            $uniqueUsers->push($user->id); //add ID to new collection
            $users->forget($user->id); //remove user from collection
            var_dump($users->count()); //each time the count is one less so forget method works
        }

        return $uniqueUsers;
}
08 Oct
2 years ago

Hesto left a reply on How To Remove Item From Relationship Collection

In my opinion the load method is best you can do. Laravel is all about KISS. If you don't have realy good argument to complicate smth (like your lines relationship has thousends of records), just don't.

06 Oct
2 years ago

Hesto left a reply on MySql "ORDER BY IF" Equivalent In Eloquent

Try orderByRaw:

$query->where(...)->orderByRaw('here query with order by if')->get();

Hesto left a reply on How To Remove Item From Relationship Collection

You absolutely can't do this:

$model->lines = $model->lines->filter( ... );

What do you mean by "Remove from collection"? You want to delete the record from DB or you want to associate them with another parent model? If you defined foreign key for lines i think it can't be empty.

04 Oct
2 years ago

Hesto left a reply on Auth Login POST (with Wrong Credentials) Redirects To Home?

If you use laravel 5.1 or higher and you have empty project and you try to setup auth you have to do 2 simple things:

  • install laravel
  • go to root of your project in command line and type
php artisan make:auth

Hesto left a reply on L5.3 Auth Redirects When Using Multiple Guards

@matbeard You should use middlewares. You can look at my package https://github.com/Hesto/multi-auth . Install it in another project, generate multi auth with same guard name which you already try to setup and copy generated middlewares. Then register middlewares in Kernel and use them in LoginController.

03 Oct
2 years ago

Hesto left a reply on [5.3] Multi Auth Configuration Problem: Guards Use Same Session

@d3xt3r I think there must be a way to logging out only one guard. Look at this method from AuthenticatesUsers trait:

public function logout(Request $request)
    {
        $this->guard()->logout();

        $request->session()->flush();

        $request->session()->regenerate();

        return redirect('/');
    }

I think the idea was to logout only one guard...

Hesto started a new conversation [5.3] Multi Auth Configuration Problem: Guards Use Same Session

Hi, I created package for easy setup multi auth https://github.com/Hesto/multi-auth . It just configure multi auth in Laravel 5 way. Almost everything work great but when we log into 2 different guards and then we logout from one of them, the second guard logging out too. Do you know how to fix it? Here is github issue: https://github.com/Hesto/multi-auth/issues/11

02 Oct
2 years ago

Hesto left a reply on Laravel 5.3 Multy Authentication

@odylight authorization has nothing common with my package. You should read more about ACL in laravel or ask about it in other topic. Look at https://github.com/Zizaco/entrust

30 Sep
2 years ago

Hesto left a reply on User Object Available In Middleware And Views

@Shamrockonov i think you are looking for multi auth solution. You can use my package to setup laravel's default multi auth with one commad https://github.com/Hesto/multi-auth . Thanks to that setup you can auth users and admins and whatever you want separately.

Hesto left a reply on Laravel 5.3 Multy Authentication

@odylight You just want to know what is the difference between my package and Laravel's default multi auth, right? It's the same thing. You can setup it yourself using docs. But its work for some hours especially if you are not familliar with laravel or Laravel's multi-auth. You can also use my package to make setup for you with one simple command. Your choice :).

27 Sep
2 years ago
17 Sep
2 years ago

Hesto left a reply on Laravel 5.3 Multi Auth - How Can I Make It Work?

@aritz @larafever you have to read topic from the begginning. I have already developed package with multi-auth https://github.com/Hesto/multi-auth . Have fun.

16 Sep
2 years ago

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo Just keep it simple :). You made simple thing realy complicated and i think you dont have benefits from that complication. Make pivot table for each guard. admin_role, role_user etc.

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo What do you exactly want to do? You have access to guard's name from middlewares. Look at RedirectIfAuthenticated or RedirectIfNotAdmin middleware.

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo you have to add to your route auth:{guard} middleware

12 Sep
2 years ago

Hesto left a reply on Laravel 5.3 Package.json File Modification

@Musharraf package.json is npm's file. Its like composer.json for composer. If you will use

npm install 

packages will be installed in you project. As default in /resources/assets/js/app.js and /resources/assets/sass/app.scss packages are included and then compiled by gulp. If you dont want to use them just delete them from paths above and include what you want.

11 Sep
2 years ago

Hesto left a reply on Laravel 5.3 Multi Auth - How Can I Make It Work?

@jekinney with multi-auth i use roles and permissions too. Employee could be manager, cheef or accountant etc. You know, i feel you have never built enough big system to appreciate multi-auth. Laravel is all about Keep It Simple Stupid (KISS) so if your projects don't need multi-auth just don't use it. But you can't tell people to not use multi-auth because YOU don't need it. Many people need it to their projects including me.

09 Sep
2 years ago

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo You're welcome :).

It looks like it fetch authenticated user and thats why you can use Auth::user() with any guard. But i'm not sure. I will check it later.

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo i just found solution. The problem was RouteServiceProvider where i forgot about auth:{guard} middleware. I will add it to my multi-auth packages soon, and you can fix it manually:

    Route::group([
            'middleware' => ['web', 'admin', 'auth:admin'], //you need to add the last middleware to array to fix it
            'prefix' => 'admin',
            'as' => 'admin.',
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/admin.php');
        });

And now you can use whatever you want to get user:

    Auth::user();
    Auth::guard()->user();
    Auth::guard('admin')->user();
    auth()->user();
    //etc, every method works fine

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo Well, i was sure that i did it before, but i can't repeat it. It just doesn't work. When i find solution ill tell you.

07 Sep
2 years ago

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

Sry my fault. It should be

Auth::guard()->user();

You don't have to

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo if you are logged in as User Auth::user() will return User class. If you are logged in as Admin Auth::user() will return Admin class.

Hesto left a reply on Laravel 5.3 Multi Auth - How Can I Make It Work?

@jekinney What if you need another logic in employees (admins) and users? For example shopping carts should belongs to users, but if they belongs to employees its weird right? Employees could have any working schedules but users dont need it. In my opinion that big things like users and employees should be sapareted.

Hesto left a reply on Laravel 5.3 Multi Auth - How Can I Make It Work?

@sjarifhd you can try

composer dump-autoload

or maybe delete vendor dir and try to composer install again. What OS do you use?

Hesto left a reply on Laravel 5.3 Multi Auth - How Can I Make It Work?

@jekinney the easiest example is e-commerce. I can't even imagine how unprofessional is one form for both users and admins for that case. In fact almost every business system need multi auth becouse we have admin panel. Show me one popular open source CMS with single table login.

06 Sep
2 years ago

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo you have to create {guard} _role table foreach guard. Thanks to laravel 5.3 auth changes Auth::user() always return currently logged in user (even when use custom guard) so entrust is finally good solution for ACL with multi auth. Entrust dont work well with laravel 5.2 multi auth. I dont another packages with multi auth, that was the reason why did i make it.

Hesto left a reply on Laravel 5.3 Multi Auth - How Can I Make It Work?

@sjarifhd Looks like composer bug? Maybe update composer to latest version or try to install another package.

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo You're welcome :). I just made new version, its minor change in code but very important. I wrote everything in changelog but i will paste it here.

v1.0.4

  • added name and prefix to route group configuration in RouteServiceProvider
Route::group([
    'prefix' => 'admin', //if you have older version of package (< v1.0.4) add this line manually,
    'as' => 'admin.', //if you have older version of package (< v1.0.4) add this line manually (the DOT at the end is important), 
    'middleware' => ['web', 'admin'],
    'namespace' => $this->namespace,
], function ($router) {
    require base_path('routes/admin.php');
});
  • Now you will be able to name your routes without adding guard's name to route name in your routes/{guard}.php and your routes will be named (its important)
//New way
Route::get('/home', function () { // <- no {guard} prefix and it has proper name (admin.home)
    //content
})->name('home'); // http://your-project/admin/home

//Old way
Route::get('/admin/home', function () { // <- with {guard} prefix
    //content
})->name('admin.home'); // http://your-project/admin/home
05 Sep
2 years ago

Hesto left a reply on LaravelCollective/HTML In Laravel 5.3

Did you register facades too?

'aliases' => [
    // ...
      'Form' => Collective\Html\FormFacade::class,
      'Html' => Collective\Html\HtmlFacade::class,
    // ...
  ],
02 Sep
2 years ago

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

@ajmerainfo Sure i can. The easiest way is to install my package and use it https://github.com/Hesto/multi-auth . If you don't want use it in your project. Just install it in laravel fresh installation, install my package then use install command with name of guard you already have. If your guard's name is admin just type in console:

php artisan multi-auth:install admin -f

Then copy:

  • sendPasswordResetNotification method from app/Admin.php
  • a file app/Notifications/AdminResetPassword.php
  • content of controllers into your controllers, from app/Http/Controllers/AdminAuth/

And paste it into your project.

01 Sep
2 years ago

Hesto left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

@Bilalfarhat24 My advice: use camel case for class names and plural snake case foryour tables names in database. It will be more readable. I think the problem is that in primary key. You override default primary key in migrations but you didn't tell your models that you made that change. Add to each model

public $primaryKey = 'name_of_primary_key_from_migration';

//example
public $primaryKey = 'persondetail_id';

Hesto left a reply on Laravel 5.2 Route Based Auth Views

@wayand Actually my package allow you to achieve what you described in first post. In your case, install package https://github.com/Hesto/multi-auth and use artisan command:

php artisan multi-auth:install admin -f

It will setup all admin auth for you. Your Admin model will be able to:

  • login: domain.com/admin/login
  • logout: domain.com/admin/logout
  • register: domain.com/admin/register
  • reset passwords

Of course the default auth will be working too. It can be installed with:

php artisan make:auth

And if your application need more guards you can always add another one and all guards will be working together properly.

Hesto left a reply on Multiple Auth

@Muhammad.tareq if your project is in Laravel 5.3, you can use my multi-auth package https://github.com/Hesto/multi-auth

31 Aug
2 years ago

Hesto left a reply on [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

Well i think there is no other good way to handle it, so i just implemented sendPasswordResetNotification() with custom Password reset notification. It works fine.

30 Aug
2 years ago

Hesto started a new conversation [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

I want to change url which is hardcoded in Illuminate\Auth\Notifications\ResetPassword. The change must be done in Model class, becouse different models could have diffrent urls for reset passwords (multi auth).

   /**
     * Build the mail representation of the notification.
     *
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail()
    {
        return (new MailMessage)
            ->line('You are receiving this email because we received a password reset request for your account.')
            ->action('Reset Password', url('password/reset', $this->token)) // <- this url
            ->line('If you did not request a password reset, no further action is required.');
    }

One way is to override in Model's class sendPasswordResetNotification from use Illuminate\Auth\Passwords\CanResetPassword but i am doing it for my Laravel 5.3 multi-auth package (https://github.com/Hesto/multi-auth) and i think its a bad idea to create new class especially for that reset email.

   **
     * Send the password reset notification.
     *
     * @param  string  $token
     * @return void
     */
    public function sendPasswordResetNotification($token)
    {
        $this->notify(new ResetPasswordNotification($token));
    }

Do you have any idea how can i handle it? I can't let it go because when i reset password with my package, for example from admin guard, i get wrong reset link.

Hesto left a reply on Laravel 5.3 Multi Auth - How Can I Make It Work?

@mr.teapot @Laraveldeep @lchandrakanth Here is my multi-auth package: https://github.com/Hesto/multi-auth . There is one thing TODO (look read me) but its fine atm. I will improve it soon.

Hesto left a reply on Laravel 5.3 Multy Authentication

@Yahav @danisemet Here is my multi-auth package: https://github.com/Hesto/multi-auth . There is one thing TODO, you can read about it in readme.

29 Aug
2 years ago

Hesto left a reply on Laravel 5.3 Multy Authentication

@Yahav I had very little time at the weekend but working on it atm. Hope ill end it today, maybe tomorrow. I put it in this topic when i finish.

26 Aug
2 years ago

Hesto left a reply on Laravel 5.3 Multy Authentication

https://laracasts.com/discuss/channels/laravel/laravel-53-multi-auth-how-can-i-make-it-work

Maybe this weekend i will end my package to easy setup multi-auth. For now you have to use the topic above.

Hesto left a reply on Default Value For Model Relation

Copy Product model, ProductImage model and db schema and ill fix it.

Hesto left a reply on Laravel Authenticates Any Logins

Check if redirectTo is public. I have fresh install of laravel 5.3 with make:auth and all works great. Maybe try to reinstall it.