Hesto

Hesto

PHP Developer at Łódź

Member Since 4 Years Ago

Łódź

Experience Points
22,900
Total
Experience

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.

Level 5
22,900 XP
Nov
10
2 years ago
Oct
22
2 years ago
Activity icon

Replied to [Collections] Random Method Wierd Behaviour

@Hawkleaf Well it works, it was my mistake when i test it. Still i dont have any answer why my solution didnt work but i have working solution at least. Thanks.

Oct
21
2 years ago
Activity icon

Replied to [Collections] Random Method Wierd Behaviour

@Hawkleaf thanks but still ids are not unique.

Activity icon

Replied to [Collections] Random Method Wierd Behaviour

Read about range func. I just want 20 random unique user ids using collections. You have comments to each line.

Activity icon

Started a new conversation [Collections] Random Method Wierd Behaviour

I try to fetch some unique user ids but it doesnt work. IDs are not unique in the new collection. 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;
 }
Oct
08
3 years ago
Activity icon

Replied to 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.

Oct
06
3 years ago
Activity icon

Replied to MySql "ORDER BY IF" Equivalent In Eloquent

Try orderByRaw:

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

Replied to 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 records 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.

Oct
04
3 years ago
Activity icon

Replied to Auth Login POST (with Wrong Credentials) Redirects To Home?

@thebasix 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
Activity icon

Replied to 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.

Oct
03
3 years ago
Activity icon

Replied to [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...

Activity icon

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

Oct
02
3 years ago
Activity icon

Replied to 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

Sep
30
3 years ago
Activity icon

Replied to 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.

Activity icon

Replied to 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 laravel's docs but its work for some long 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 :).

Sep
27
3 years ago
Sep
17
3 years ago
Activity icon

Replied to 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.

@mr.teapot can you mark one of my answer with link to package as best answer? It would help people a lot.

Sep
16
3 years ago
Activity icon

Replied to [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 benefits from that complication. Make pivot table for each guard. admin_role, role_user etc.

Activity icon

Replied to [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.

Activity icon

Replied to [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

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

Sep
12
3 years ago
Activity icon

Replied to 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.

Sep
11
3 years ago
Activity icon

Replied to 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.

Sep
09
3 years ago
Activity icon

Replied to [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.

Activity icon

Replied to [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
Activity icon

Replied to [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.

Sep
07
3 years ago
Activity icon

Replied to [Laravel 5.3] Change URL In Reset Password Link With Mulit Auth

Sorry my fault. It should be

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

You just don't have to name the guard.

Activity icon

Replied to [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.

Activity icon

Replied to 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.

Activity icon

Replied to 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?

edit: Try to install https://github.com/Zizaco/entrust i have similar composer.json to it.

Activity icon

Replied to 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 because we have admin panel. Show me one popular open source CMS with single table login.

Sep
06
3 years ago
Activity icon

Replied to [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 know another packages with multi auth, that was the reason why i made it.

Activity icon

Replied to 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 to check if it works. Look into your ./composer.json and check if there is latest version of hesto/multi-auth.

"hesto/multi-auth": ">=1.0.4"
Activity icon

Replied to [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
Sep
05
3 years ago
Activity icon

Replied to LaravelCollective/HTML In Laravel 5.3

@ruchit288 Did you register facades too?

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

Replied to [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 laravel fresh copy, 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. Reset passwords will work fine.

Sep
01
3 years ago
Activity icon

Replied to 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 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';

The next thing is you have to add persondetail_id when you are creating new record. Try it:

 public function store(createuserrequest $request)
    {
    ///////////////////////////////    Father Detail  /////////////////////////////////

             $fatherdetail = fatherdetail::create([
             'f_firstname'=>$request->input('f_firstname'),
             'f_middlename'=>$request->input('f_middlename'),
             'f_lastname'=> $request->input('f_lastname'),
             'f_status'=> $request->input('f_status'),
             'g_firstname'=> $request->input('g_firstname'),
             'g_middlename'=> $request->input('g_middlename'),
             'g_lastname'=> $request->input('g_lastname'),
            ]);

        ////////////////////////////////  Persons Detail  /////////////////////////////////

             $persondetail = $fatherdetail->persondetail()->create([
             'firstname'=>$request->input('firstname'),
             'middlename'=>$request->input('middlename'),
             'lastname'=> $request->input('lastname'),
             'day'=> $request->input('day'),
             'month'=> $request->input('month'),
             'year'=> $request->input('year'),
             'birthplace'=> $request->input('birthplace'),
             'city'=> $request->input('city'),
             'cnic'=> $request->input('cnic'),
             'gender'=> $request->input('gender'),
            ]);

         

    return "success";
    }
Activity icon

Replied to Laravel 5.2 Route Based Auth Views

@wayand This package is only for Laravel 5.3 but if you decide to update your project to Laravel 5.3 i can help you. This package use Laravel built in auth, but it just make annoying setups for you. So you don't have to copy controllers, override methods add guards and providers in auth.php... the package setup with one simple command. 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 Laravel Auth will be working too. It can be installed with:

php artisan make:auth

And if your application needs more guards you can always add another one. All guards will be working together properly.

For laravel 5.2 setup yor files with this topic

http://stackoverflow.com/questions/34614753/can-anyone-explain-laravel-5-2-multi-auth-with-example

Activity icon

Replied to 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

Aug
31
3 years ago
Activity icon

Replied to [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.

Aug
30
3 years ago
Activity icon

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.

Activity icon

Replied to 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.

Aug
29
3 years ago
Activity icon

Replied to 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.

Aug
26
3 years ago
Activity icon

Replied to 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.

Activity icon

Replied to Default Value For Model Relation

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

Activity icon

Replied to 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.