MrFiliper

MrFiliper

Member Since 1 Year Ago

Experience Points 640
Experience Level 1

4,360 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 3
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.

21 Aug
8 months ago

MrFiliper left a reply on Categories, SubCategories And Products With Pagenation

@biishmar i do this, i have only one table with categories with this design

categories

  • id
  • sub_id

@aurawindsurfing i know, but this is the problem. I want sometnig like this:

$ids = [];

$ids[] = $cat->id;

foreach ($cat->children()->get() as $child) {
    $ids[] = $child->id;
}

$cats = StoreCategory::where('sub_id', '=', $ids)->get();

Now, i have all ids of subcategories. Next, i get products in these categories.

$products = null;

        foreach ($cats as $cc) {
            $products = $cc->products()->get(); //Now there, i get all products in these category. What i need, is to store thies products into variable (collection) and after loop, paginate these products. But how?
        }

//Something like $products->paginate(15);

MrFiliper started a new conversation Categories, SubCategories And Products With Pagenation

Hi, i have these models:

Category

  • id
  • sub_id

Product

  • id
  • name

ane table

product_categories

  • id
  • category_id
  • product_id

Main category

  • SubCategory 1
  • SubCategory 2

I want to display all items in "Main Category", how can i do that with pagenation? In laravel blade, i can use loop, but i need pagenation.

14 Jun
11 months ago

MrFiliper left a reply on Custom Column In Password_resets

Because I change email to email_id in accounts (users) table. Then, i must change create method, or delete method, right?

13 Jun
11 months ago

MrFiliper left a reply on Custom Column In Password_resets

Ok, i found a solution. In DatabaseTokenRepository.php is methods deleteExisting and getPayload. Here is my edited code:

    protected function getPayload($email, $token)
    {
        return ['email_id' => $email, 'token' => $this->hasher->make($token), 'created_at' => new Carbon];
    }
        return $this->getTable()->where('email_id', $user->getEmailForPasswordReset())->delete();

But, is there a way, how to override this methods insted of editing of source?

MrFiliper left a reply on Custom Column In Password_resets

´´´ public function getEmailForPasswordReset() { return Email::find($this->email_id)->email; } ´´´

give me error

´´´ SQLSTATE[42S22]: Column not found: 1054 Unknown column 'email' in 'where clause' (SQL: delete from m `password_res where e `em = [email protected]) ´´´

MrFiliper started a new conversation Custom Column In Password_resets

I want to edit column email in password_resets table to email_id, because i have another table with name emails, and there are have all emails.

This is my edited method in ForgotPasswordController

    public function sendResetLinkEmail(Request $request)
    {
        $this->validateEmail($request);

        $email = Email::where('email', '=', $request->get('email'))->first();

        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            ['email_id' => $email->id]
        );

        return $response == Password::RESET_LINK_SENT
            ? $this->sendResetLinkResponse($response)
            : $this->sendResetLinkFailedResponse($request, $response);
    }

User.php

    public function getEmailForPasswordReset() {
        return $this->email_id;
    }

and error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'email' in 'where clause' (SQL: delete from `password_resets` where `email` = 1)

I know why the bug is coming up, but i can't found, where i can change email column to email_id.

28 May
11 months ago

MrFiliper left a reply on GET Request $request->getContent() Is Empty

The problem is in laravel router (web.php). API send POST request to router, but laravel ? transofrm ? request to GET request and all the data disappeared. To resolve the issue i use laravel api router (api.php), there I configure POST request and now it works with $request->getContent().

Thanks all for help! I appreciate it.

MrFiliper left a reply on GET Request $request->getContent() Is Empty

@hdsavani Thats ok, but api send xml content in the header of request and i need to get it from here. I can't change the api.

MrFiliper left a reply on GET Request $request->getContent() Is Empty

@hdsavani http://www.beta.foodfriends.cz/pohoda/supplies/ but i can't pass to url, because api sending to my in content

@R3l4x3 Not working

[2018-05-28 12:31:13] local.INFO: app.requests {"request":[],"method":"GET"} 

MrFiliper left a reply on GET Request $request->getContent() Is Empty

$content = $request->all();

Log::info('app.requests', ['request' => $content, 'method' => $request->method()]);

will return empty content too

[2018-05-28 12:22:12] local.INFO: app.requests {"request":[],"method":"GET"} 

MrFiliper started a new conversation GET Request $request->getContent() Is Empty

I need to get content (xml) from GET request.

With pure php this works and return xml contant

$content = file_get_contents("php://input");

When i use $request->getContent() in laravel, there is empy request.

11 Sep
1 year ago

MrFiliper started a new conversation Method Attempt Does Not Exist Or Auth Guard Driver [api] Is Not Defined.

I use Lumen 5, and I'm having trouble with using authentication.

I have uncommented

$app->register(App\Providers\AuthServiceProvider::class);
$app->withFacades();
$app->withEloquent();

in app.php but authentication not work /

    public function postLogin(Request $request)
    {
        $this->validate($request, [
            'email'    => 'required|email',
            'password' => 'required',
        ]);

        $credentials = $request->only('email', 'password');

        if (Auth::attempt($credentials, $request->has('remember'))) {
            return ['result' => 'ok'];
        }

        return ['result' => 'not ok'];
    }

If I create a request to /login with params need to succesful request, display error:

Method attempt does not exist.

Ok, next I create new auth.php config

<?php

return [
    'defaults' => [
        'guard' => 'api',
        'passwords' => 'users',
    ],

    'guards' => [
        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
        ],
    ],

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => \App\User::class
        ]
    ]
];

and display next error: Auth guard driver [api] is not defined.

Why? The api guard is defined in the config?!

Thanks for replay!

15 Jun
1 year ago

MrFiliper left a reply on Lumen Undefined Method RequestGuard::attempt() In Auth

My auth.php

''' return [ 'defaults' => [ 'guard' => env('AUTH_GUARD', 'api'), 'passwords' => 'users', ],

'guards' => [
    'api' => [
        'driver' => 'session',
        'provider' => 'users',
    ],
],

'user' => [
    'driver' => 'session',
    'provider' => 'users',
],

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],
],

]; '''

First problem is solved? But other one is there.

''' Class session.store does not exist

in Container.php (line 719) at ReflectionClass->__construct('session.store') in Container.php (line 719) at Container->build('session.store') in Container.php (line 598) at Container->resolve('session.store') in Container.php (line 567) at Container->make('session.store') in Application.php (line 208) at Application->make('session.store') in Container.php (line 1139) at Container->offsetGet('session.store') in AuthManager.php (line 125) at AuthManager->createSessionDriver('api', array('driver' => 'session', 'provider' => 'users')) in AuthManager.php (line 96) at AuthManager->resolve('api') in AuthManager.php (line 70) at AuthManager->guard() in AuthManager.php (line 294) at AuthManager->__call('attempt', array(array('username' => 'test', 'password' => 'test'), false)) in Facade.php (line 221) at Facade::__callStatic('attempt', array(array('username' => 'test', 'password' => 'test'), false)) in AuthController.php (line 26) at AuthController->login(object(Request)) at call_user_func_array(array(object(AuthController), 'login'), array(object(Request))) in BoundMethod.php (line 29) at BoundMethod::Illuminate\Container{closure}() in BoundMethod.php (line 87) at BoundMethod::callBoundMethod(object(Application), array(object(AuthController), 'login'), object(Closure)) in BoundMethod.php (line 31) at BoundMethod::call(object(Application), array(object(AuthController), 'login'), array(), null) in Container.php (line 531) at Container->call(array(object(AuthController), 'login'), array()) in RoutesRequests.php (line 741) at Application->callControllerCallable(array(object(AuthController), 'login'), array()) in RoutesRequests.php (line 707) at Application->callLumenController(object(AuthController), 'login', array(true, array('uses' => 'App\Http\Controllers\[email protected]'), array())) in RoutesRequests.php (line 681) at Application->callControllerAction(array(true, array('uses' => 'App\Http\Controllers\[email protected]'), array())) in RoutesRequests.php (line 643) at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\Http\Controllers\[email protected]'), array())) in RoutesRequests.php (line 628) at Application->handleFoundRoute(array(true, array('uses' => 'App\Http\Controllers\[email protected]'), array())) in RoutesRequests.php (line 528) at Application->Laravel\Lumen\Concerns{closure}() in RoutesRequests.php (line 781) at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php (line 534) at Application->dispatch(null) in RoutesRequests.php (line 475) at Application->run() in index.php (line 28) '''

14 Jun
1 year ago

MrFiliper started a new conversation Lumen Undefined Method RequestGuard::attempt() In Auth

Hello, I need it to create api for user authentication in Lumen, but there are some problems.

Call to undefined method Illuminate\Auth\RequestGuard::attempt()

in AuthManager.php (line 294)
at AuthManager->__call('attempt', array(array('username' => 'test', 'password' => 'test'), false))
in Facade.php (line 221)
at Facade::__callStatic('attempt', array(array('username' => 'test', 'password' => 'test'), false))
in AuthController.php (line 29)
at AuthController->login(object(Request))
at call_user_func_array(array(object(AuthController), 'login'), array(object(Request)))
in BoundMethod.php (line 29)
at BoundMethod::Illuminate\Container\{closure}()
in BoundMethod.php (line 87)
at BoundMethod::callBoundMethod(object(Application), array(object(AuthController), 'login'), object(Closure))
in BoundMethod.php (line 31)
at BoundMethod::call(object(Application), array(object(AuthController), 'login'), array(), null)
in Container.php (line 531)
at Container->call(array(object(AuthController), 'login'), array())
in RoutesRequests.php (line 741)
at Application->callControllerCallable(array(object(AuthController), 'login'), array())
in RoutesRequests.php (line 707)
at Application->callLumenController(object(AuthController), 'login', array(true, array('uses' => 'App\\Http\\Controllers\\[email protected]'), array()))
in RoutesRequests.php (line 681)
at Application->callControllerAction(array(true, array('uses' => 'App\\Http\\Controllers\\[email protected]'), array()))
in RoutesRequests.php (line 643)
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\\Http\\Controllers\\[email protected]'), array()))
in RoutesRequests.php (line 628)
at Application->handleFoundRoute(array(true, array('uses' => 'App\\Http\\Controllers\\[email protected]'), array()))
in RoutesRequests.php (line 528)
at Application->Laravel\Lumen\Concerns\{closure}()
in RoutesRequests.php (line 781)
at Application->sendThroughPipeline(array(), object(Closure))
in RoutesRequests.php (line 534)
at Application->dispatch(null)
in RoutesRequests.php (line 475)
at Application->run()
in index.php (line 28)

AuthController

class AuthController extends Controller
{

    public function login(Request $request)
    {
        $this->validate($request, [
            'username'    => 'required',
            'password' => 'required',
        ]);

        $credentials = $request->only('username', 'password');

        Auth::attempt($credentials, false); //ERROR

        return ['result' => 'ok'];
    }
}

User

class User extends Model implements AuthenticatableContract, AuthorizableContract
{
    use Authenticatable, Authorizable;

    protected $table = 'users';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */

    protected $fillable = [
        'username', 'email',
    ];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = [
        'password',
    ];
}

I don't know where is problem, why is attempt() method not found?