tokoiwesley

tokoiwesley

Member Since 2 Years Ago

Nairobi

Experience Points 39,170
Experience Level 8

830 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 304
Lessons
Completed
Best Reply Awards 12
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.

16 Jul
4 days ago

tokoiwesley left a reply on Weird 'Function Name Must Be A String' With Auth:api

@matthewh Well, I have figured out that this error is due to improperly registering the said middleware in app/Http/Kernel.php. On correcting my mistake everything is fine and works as expected.

tokoiwesley left a reply on Laravel Passport: 'Function Name Must Be A String' Error

On trying to reproduce the error on a separate project, I found out what the issue was;

I missed to properly register the CheckClientCredentials::class middleware in app/Http/Kernel.php. Everything is now working perfectly.

tokoiwesley left a reply on Vue.js Vs Angular:

@mahaveer Frameworks and languages are just tools. They have both strengths and weaknesses depending on the context (task/project) because of how they work (are designed to work) internally.

So without a specific project at hand (no variables to consider) it's just as @tykus stated!

tokoiwesley left a reply on Weird 'Function Name Must Be A String' With Auth:api

@tray2 I don't exactly see how I have hijacked the thread! I wanted to know whether a solution was found because the problem @matthewh experienced is identical to what am experiencing. Nevertheless, I have created a new thread for my issue.

tokoiwesley started a new conversation Laravel Passport: 'Function Name Must Be A String' Error

I have a working implementation of Laravel Passport that has only uses Password Grant tokens for authentication of users. So on trying to implement Client Credentials Grant for server-to-server authentication, the client middleware throws a weird error I have never encountered before: "Function name must be a string" whenever I apply it on any route I want to protect.

  • php: 7.1.3
  • laravel framework: 5.7.25
  • laravel passport: 7.0

tokoiwesley left a reply on Weird 'Function Name Must Be A String' With Auth:api

@matthewh Did you find a solution?

I am getting this error as well when I tried to implement machine-to-machine (server-to-server) authentication (using client credentials) . In my case the auth:api middleware works perfectly fine, but the client middleware throws the same error described above.

11 Jun
1 month ago
07 Jun
1 month ago

tokoiwesley left a reply on Laravel Passport Test

You don't need to add any controllers. Before diving into Laravel passport testing, you need to be familiar with writing tests in Laravel

tokoiwesley left a reply on Prevent Factory Duplication For Models Relationships

Yes, there is another way. Modify your Seeder as shown below:

factory('App\Thread', 60)->create();

Thread::all()->each(function ($thread){
factory('App\Tag')->create(['thread_id'=> $thread->id]);
});

tokoiwesley left a reply on Tokenmismatchexception With Script

First, don't encrypt the csrf_token(). Pass it exactly the way it is generated. Next, I can see in your script you are setting the X-XSRF-TOKEN header. Have you tried using the X-CSRF-TOKEN header instead?

03 Jun
1 month ago

tokoiwesley left a reply on Relationship HasMany() Dosen't Work

@RESPECT - Then maybe you are using migrations the wrong way. They are meant exactly for this type of job in the first place - easily modifying tables in production.

28 May
1 month ago

tokoiwesley left a reply on Project Not Being Created

@swimmer using @nakov's solution should solve the issue. Your Laravel project folder will be Medici.

tokoiwesley left a reply on Project Not Being Created

What do you want the name of your project folder/directory to be?

tokoiwesley left a reply on Relationship HasMany() Dosen't Work

I created these tables in production manually without migration what i forget

@respect editing code directly in production is a terrible idea. I suggest you write the code in your local environment and test it before moving/deploying it to production.

22 May
1 month ago

tokoiwesley left a reply on Insert Multiple Data Into Database

@EMFINANGA - Say for example a customer can have many orders. Your orders table should have the relevant column to accommodate this relationship then you'll define the relationship and it's inverse in the respective models.

I have used the customers to represent your customer_details table;

customers - id - name ...

orders - id - customer_id ...

Customer model class

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{
    protected $guarded;

    public function orders()
    {
        return $this->hasMany(Order::class, 'customer_id', 'id');
    }
}

Order model class

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    protected $guarded = [];

    public function customer()
    {
        return $this->belongsTo(Customer::class, 'customer_id', 'id');
    }
}

When a customer makes an order, you need to retrieve the relevant customer model (record) and create a related order model (record). Example;

<?php

namespace App\Http\Controllers;

use App\Customer;
use Illuminate\Http\Request;

class OrdersController extends Controller
{
    public function store(Request $request)
    {
        $customer = Customer::find(1);

        Order::create([
            'customer_id' => $customer->id,
            ...
        ]);
    }
}
20 May
2 months ago

tokoiwesley left a reply on Insert Multiple Data Into Database

If I get your question, you need to use a relationship between the two tables.

15 May
2 months ago

tokoiwesley left a reply on Laravel Csrf Token Mismatch In POST Request With URL

@CRAZYLIFE - Then you will need to use the second solution I have suggested above (exclude /response from CSRF protection)

tokoiwesley left a reply on Laravel Csrf Token Mismatch In POST Request With URL

If you don't want to pass the token then exclude /response from CSRF protection in /app/Http/Middleware/VerifyCsrfToken.php file;

/**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'response',
    ];

tokoiwesley left a reply on Laravel Csrf Token Mismatch In POST Request With URL

Use the @csrf Blade directive to generate the token field

<form method="POST" action="/response">
    @csrf
    ...
</form>
07 May
2 months ago

tokoiwesley left a reply on How To Create Relationships?

You are welcome.

tokoiwesley left a reply on How To Create Relationships?

@ALEX_STORM - Each model is mapped to a table thus, each component becomes an entity of its own.

tokoiwesley left a reply on How To Create Relationships?

Check out Eloquent Relationships to learn more about relationships in Laravel's Eloquent ORM.

This explanation about normalizing a database can help you understand the need to split a single table into multiple tables.

tokoiwesley left a reply on How To Create Relationships?

Your question is not very clear. Are you working alongside a tutorial?

05 May
2 months ago

tokoiwesley left a reply on .gitignore - Doesn't Work As Expected

There is a second step to "ignoring" the file since you had already committed it to the remote repo;

git rm --cached config/snappy.php

However, personally I'd be comfortable with @snapey's suggestion.

tokoiwesley left a reply on Consuming Your API With JavaScript

@BURYO - You are welcome. I had mentioned about a change that was made to Laravel in how it handles cookie serialization. You can find out more about this in the article Security Release: Laravel v5.6.30 and v5.5.42 have been released and the official upgrade guide Upgrading To 5.6.30 From 5.6 (Security Release)

tokoiwesley left a reply on Consuming Your API With JavaScript

@BURYO - Change this protected static $serialize = true; to

protected static $serialize = false;

tokoiwesley left a reply on Consuming Your API With JavaScript

@BURYO - That's OK. It's supposed to be in the request headers and not response headers.

tokoiwesley left a reply on New To Forum

Welcome to the community :)

tokoiwesley left a reply on Consuming Your API With JavaScript

Are you getting laravel_token in the response headers?

tokoiwesley left a reply on Consuming Your API With JavaScript

Try adding Passport::withoutCookieSerialization(); in the boot method of the app/Providers/AppServiceProvider.php to see whether that solves the problem.

tokoiwesley left a reply on Consuming Your API With JavaScript

This problem may be due a change in how Laravel handles cookie serialization. Which version of Laravel are you using?

24 Apr
2 months ago

tokoiwesley left a reply on Access Token Validate From Another Server?

Well, if I would have to implement something like that - since this seems to me to be a machine-to-machine authentication issue - I would opt for the Client Credentials Grant Tokens in Passport. Let me know if this helps.

15 Apr
3 months ago

tokoiwesley left a reply on Laravel Passport Correct Usage

@MIKO55 - You are welcome.

tokoiwesley left a reply on Laravel Passport Correct Usage

@MIKO55 - Yes, it's the solution.

tokoiwesley left a reply on Laravel Passport Correct Usage

Passport::withoutCookieSerialization() instructs Passport to disable cookie serialization.

tokoiwesley left a reply on Laravel Passport Correct Usage

@MIKO55 - You are using Apache so it's possible that the Authorization Header is being blocked by a module in Apache. Some devs who have experienced this issue before recommend adding the following in your .htaccess file;

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

Also ensure that the .htaccess file located in the public folder has the following lines;

RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

tokoiwesley left a reply on Laravel Passport Correct Usage

Could it be an environment setup issue! Which web server and OS are you using?

tokoiwesley left a reply on Laravel Passport Correct Usage

Check whether you have include the CSRF token in your application layout file.

// In your application layout...
<meta name="csrf-token" content="{{ csrf_token() }}">

tokoiwesley left a reply on Laravel Passport Correct Usage

@MIKO55 - What response are you getting?

tokoiwesley left a reply on How To Always Run Multiple Queues At All Time Via Supervisor?

Maybe it's because you are dispatching all the jobs and/or queueable entities in your app to only one queue (the default queue). Is this the case?

14 Apr
3 months ago

tokoiwesley left a reply on Laravel Passport Correct Usage

As I tried to reproduce this issue, I found out was that the X-Requested-With header has already been added in ./resources/js/bootstrap.js. Adding it elsewhere in the code (say app.js) results in the Vue component always returning Unauthenticated. So try deleting the X-Requested-With header addition you made before and test again.

tokoiwesley left a reply on Laravel Passport Correct Usage

@MIKO55 - Well I was assuming you had already run php artisan make:auth! At least you now have the laravel_token cookie, so we can focus on why the Vue component is returning Unauthenticated.

13 Apr
3 months ago

tokoiwesley left a reply on Laravel Passport Correct Usage

@MIKO55 - You seem to be mixing up stuff. After successfully authentication in the Web app, you do not need to manually create a token at all. That's the essence of adding \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class in the web middleware group. It creates the automatically, such that all you need is to make requests to the API endpoints (routes) using axios.

tokoiwesley left a reply on Laravel Passport Correct Usage

@MIKO55 - What tool are you using for your XMLHttpRequests?

10 Apr
3 months ago

tokoiwesley left a reply on Eloquent Methods And Collection Methods

@zaster I have added an edit to my initial reply.

tokoiwesley left a reply on Eloquent Methods And Collection Methods

@SNAPEY - My bad! Thanks for pointing out that mistake.