tokoiwesley

tokoiwesley

Member Since 2 Years Ago

Nairobi

Experience Points 39,070
Experience Level 8

930 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 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.

11 Jun
2 weeks ago
07 Jun
2 weeks 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
3 weeks 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
4 weeks 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
1 month 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
1 month 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
1 month 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
1 month 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
2 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
2 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
2 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
2 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.

tokoiwesley left a reply on Displaying Json Encoded Data From A Database Column

Have you tried doing this:

@foreach($property->image as $image)
    echo $image; // http://kizflex.local/properties/11.jpg
    ...
@endforeach

tokoiwesley left a reply on Any Guide Or Chart Library That Allows For Dynamically Updating Chart?

Laracasts' series Real-time Laravel with Socket.io which uses Node, Redis, and Socket.io will be a great place to get you started on the right path to achieving your goal.

09 Apr
2 months ago

tokoiwesley left a reply on Displaying Json Encoded Data From A Database Column

Use the array cast type on your model class so that the json data will be converted to a PHP array when you access it in your app.

tokoiwesley left a reply on Laravel 5.5 PHP Error

It seems like you app is hosted on server with a shared hosting plan. The solution is to get a VPS (from hosting solutions like Digitalocean, Linode, Vultr etc.) which allows for such flexibility - like installing a specific version of PHP.

tokoiwesley left a reply on Would It Be Right To Add .env To .gitignore And Update It Via Vim On The Server?

That is the normal practice and it should be that way. When you start a new Laravel project, .env will already have been added to .gitignore for you.

tokoiwesley left a reply on Eloquent Methods And Collection Methods

They are not the same, however Eloquent collections extend the base Laravel collection object, thus inheriting all the methods provided by the base collection.

When retrieving a record from a table using Eloquent ORM, the resulting object is an Eloquent collection. So you can use Laravel collection methods on Eloquent collections.