jkoech

jkoech

Nairobi

Member Since 4 Years Ago

Experience Points 5,450
Experience
Level
Lessons Completed 23
Lessons
Completed
Best Reply Awards 3
Best Answer
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.

16 Feb
11 months ago

jkoech left a reply on Redirect User To /createPost Page After He Registers

Laravel >= 5.3

Modify the new Middleware auth redirector

/app/Http/Middleware/RedirectIfAuthenticated.php

Change the handle function slightly, so it looks like:

public function handle($request, Closure $next, $guard = null)
{
    if (Auth::guard($guard)->check()) {
        return redirect()->intended('/home');
    }

    return $next($request);
}
18 Dec
1 year ago

jkoech left a reply on Breaking Out Of A Foreach

This is really bad. Iterating means will be queried foreach time the loop is executed. Why can't you tell us what you are trying to achieve and we can suggest a better approach.

17 Dec
1 year ago

jkoech left a reply on Php Artisan Make:auth Doesn't Create Controllers

When you run the command php artisan make:auth, what do you see on your terminal/command-line?

jkoech left a reply on Install Pacakge In Laravel App On Cpanel

You can download the app from cpanel, set it up on your local developer environment, install the package via composer the reupload the app.

jkoech left a reply on Need Opinions On Database Design For Roles & Permissions

The reason the second approach is favourable is because of scalability. You won't have any issues in the long-run. I highly recommend the second approach since it has been my go-to approach for most of my projects.

When running your queries, just eagerload the relationship. Eager loading alleviates the N + 1 query problem.

jkoech left a reply on 1and1 Shared Hosting - Quick Comment

What is the issue with 1and1?

09 Dec
1 year ago

jkoech left a reply on Problem Searching Relation Using Yajra Datatables

I manage to solve the problem with the code below:

$brands = Brand::with('categories')
            ->select('brands.*')
            ->whereHas('categories', function ($q) use ($request) {
                if ($request->has('categories') && $request->get('categories') != null ) {
                    $categories = array_filter($request->categories);
                    if(count($categories) > 0) {
                        //$q->where('categories.slug', '=', $request->categories);
                        $q->whereIn('categories.slug', $request->get('categories'));
                    }  
                }
                
            });
08 Dec
1 year ago

jkoech left a reply on .htaccess Easy Problem

The problem is not htaccess, you are missing a blade file. Create the file under resources->views->carriers>sections->footers.blade.php

jkoech started a new conversation Problem Searching Relation Using Yajra Datatables

I have a Brand and Category model, with a many to many relationship. In my Brand Model, I have the following relation:

public function categories()
{
    return $this->belongsToMany(Category::class);
 }

And in my Category model, I have:

public function brands()
{
    return $this->belongsToMany(Brand::class);
}

Everything is working fine, I can search any field in the Brand Model except I haven't been able to search the Category. Below is my code, please help:

$brands = Brand::with('categories')->select('brands.*');

return Datatables::of($brands)
    ->filter(function ($query) use ($request) {

        if ($request->has('brand')) {
            $query->where('brand', 'like', "%{$request->get('brand')}%");
        }

    if ($request->has('category')) {
            $query->whereHas('categories', function ($q) use ($request) {
                $q->where('categories.slug', $request->category);
            });
        }

      
    })->make(true);
04 Dec
1 year ago

jkoech started a new conversation Custom Filter On Laravel 5.5 Using Yajra Datatables Package

I followed this guide https://datatables.yajrabox.com/fluent/custom-filter (all the code is available on the link) on implementing a custom search box. Now I have certain fields which are checkboxes and a user can tick several check boxes. I'm stuck on how I can iterate multiple multiple checkboxes and input fields. Anyone done this before? @yajra could please help if you can? TIA.

jkoech left a reply on Sending Mail On Laravel To Gmail

@king_eke will find sometime to share. Meanwhile, just use sendmail as the mail driver, it saved me the hassle in some project.

03 Dec
1 year ago

jkoech left a reply on New Image Folder Not Found, Laravel Boilerplate

Post the error that shows on your browsers console.

jkoech left a reply on Suggestions For Finding Laravel Developer For Saas Guidance

You could contact some Laravel devopers on this forum. Most have their contact info on their profiles.

jkoech left a reply on Sending Mail On Laravel To Gmail

Enable 2FA on your gmail and use 2FA password. I had the same issue too. Seems like enabling less secure apps makes Google to block any SMTP connection on that account.

02 Dec
1 year ago

jkoech left a reply on Problem Installing Laravel On Remote Server (DO) With Composer Install

Try removing or renaming the 'vendor' folder and run composer install

jkoech left a reply on Why Is Laravel Not Running In Wamp?

Does CSS and other files load?

jkoech left a reply on Login Redirect Not Working In 5.5?

If you want to redirect after login, add the following method in your LoginController.php

protected function authenticated(Request $request, $user)
{
    return redirect('/redirect-url'); //put your redirect url here
}
30 Nov
1 year ago
29 Nov
1 year ago

jkoech left a reply on Multiple Users And Signup Forms

Retrieve an instance of your billable model, have a look at https://laravel.com/docs/5.5/billing#creating-subscriptions

jkoech left a reply on Multiple Users And Signup Forms

What you can do, just use one Controller, say users, then create a roles table and a pivot table for user_roles. Then in your User table, have nullable fields for all the different user types (admin, users, network, group) then just show the necessary fields on each registration form. This will simplify Cashier integration. I hope this will work.

26 Nov
1 year ago

jkoech left a reply on Link Multiple Domains With Multiple Laravel Projects (issue With Nginx)

As far as I know, you will need each for every site. What's your environment?

jkoech left a reply on Function Authenticate() Not Triggering

In your login controller have something similar to the below:

protected function authenticated(Request $request, $user)
    {
    if ($user && $user->role === 'admin' || $user->role === 'contributor') {
        return redirect()->route('admin');
    }

     return redirect('/');
    }

Mine works well, just update the conditional.

jkoech left a reply on I've Been Away.

Welcome back @miiikkeyyyy !

jkoech left a reply on Escape '@' In Config Folder In Laravel

Just use single quotes.

jkoech left a reply on Issues Loading Player On Laracast

Never had an issue. Could you try on a different ISP?

jkoech left a reply on Multiple Users And Signup Forms

Laravel provides a simple way to authorize or restrict user actions https://laravel.com/docs/5.5/authorization.

jkoech left a reply on I Buyed Laravel Spark(unlimited) Recently, Do I Get The Update For Spark 6.0 For Free ?

Yes, all spark upgrades are always free. Just read through the upgrade guide when the next version is released.

jkoech left a reply on Eloquent Relationships

Hi Wreed, would you post your migration to make it clear?

24 Nov
1 year ago

jkoech started a new conversation Trying To Get Property Of Non-object

I have the following in my BrandRequest, I expect to get a collection but instead, I only get a string when I dd the $brand. What could be the problem?


namespace App\Http\Requests;

class BrandRequest extends Request
{
    /**
     * Get the Validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        dd($this->brand);
        $id = $this->brand ? ',' . $this->brand->id : '';

        return $rules = [
            'brand' => 'bail|required|max:255',
            'mind_share' => 'bail|required|max:255',
            'slug' => 'bail|required|max:255|unique:brands,slug' . $id,
            'growth_score' => 'nullable|max:255',
            'business_model' => 'nullable|max:255',
        ];
    }
}

08 Dec
2 years ago

jkoech left a reply on Eloquent Relationships With Users/Posts/Comments

Please post your model methods.

jkoech left a reply on Problem With Foreign Key

@tomi, thank you so much, this worked.

jkoech started a new conversation Problem With Foreign Key

I'm having problems adding a foreign key to a table using Laravel migrations. One table called 'act_versions' references the id of another table called 'acts'.

Below is the error:

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'act_id' doesn't exist in table (SQL: alter table act_versions add constraint ac t_versions_act_id_foreign foreign key (act_id) references acts (id))

[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'act_id' doesn't exist in table

Below is my acts migration table

class CreateActsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('acts', function (Blueprint $table) {
            $table->increments('id');
            $table->text('act_title');
            $table->string('cap_no', 10);
            $table->string('cap_no_temp', 10);
            $table->string('first_letter', 1);
        });
    }
}

Below is the act_versions migration table


class CreateActVersionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('act_versions', function (Blueprint $table) {
            $table->increments('id');
            $table->foreign('act_id')
                ->references('id')->on('acts');
            $table->date('assent_date');
            $table->string('commencement_date');
            $table->string('version_year', 4);
            $table->string('preamble');
            $table->tinyInteger('is_published');
            $table->tinyInteger('is_deleted');
            $table->timestamps();
        });
    }
}

26 Jan
2 years ago

jkoech started a new conversation Laravel 5 RESTful API App With OAuth 2, JWT And Dingo API

Hello all, This is my first attempt on building a RESTful API. I have a working Laravel 5 application with authentication and would like to extend it to a 3rd party.

Basically, I need to generate a merchant key that will be used by the third party to access the API.

I read through the forum and noticed that OAuth 2.0, JSON Web Token Authentication for Laravel and Dingo were being mentioned a lot.

I understand how each of the above packages work but I'm having a challenge putting them together and having working.

Anyone who's been don this road or would recommend an alternative approach?

09 Nov
3 years ago

jkoech left a reply on Help With JQuery Ajax & Laravel 5.1 - Delete Item

I'm glad it has finally worked! Thank you @bobbybouwmann

jkoech left a reply on Help With JQuery Ajax & Laravel 5.1 - Delete Item

@bobbybouwmann I've done exactly that but doesn't seem to work either. When a product is added, I can see from the developer tools the divs and it's content but when I click the remove button, it doesn't fire at all.

jkoech started a new conversation Help With JQuery Ajax & Laravel 5.1 - Delete Item

I building a simple add to cart app. I am able to add products via ajax, I can add multiple without a problem.

My issue is, when I try deleting a product from the cart, the click event doesn't work unless I refresh the page. Even though, I can only delete a single product and the click event doesn't work again until I refresh. What could be the problem?

Here is my code:

/*Code for adding a product to cart when an item is selected from the dropdown list*/
$( "#device_list" ).change(function(e) {
    if($("#device_list").val()) {
        var params=[ 
               {name:"name", value:value1},
               {name:"id", value:value2}
         ];

        $.get("{{ url('api/cart')}}", 
        params, 
        function(data) {
            //empty cart
            $('.mycart').empty;
            
            //reload cart with all new items
            $('.mycart').html(data);

        });
    }
});

And the code for removing an item

$( ".remove-btn" ).click(function(e) {
    var params=[ 
          
           {name:"id", value:$(".remove-btn").attr('id')}
     ];

    $.get("{{ url('api/remove')}}", params, 
    function(data) {
        $('.mycart').empty;
        $('.mycart').html(data);

    });
});

jkoech left a reply on PayPal IPN With Laravel

Which version of laravel are you using? If using Laravel 5.1, you can do the following: In VerifyCrsfToken.php, add $except as below:

<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'stripe/*',
    ];
}

Go to Laravel 5.1 documentation

02 Sep
3 years ago

jkoech left a reply on Php Artisan Migrate:rollback Error

As @StuffedGoat said, run '' composer autoload

27 May
3 years ago
26 May
3 years ago

jkoech left a reply on Tech & Programming News Site

Plenty of sites available, a few of my favorite shared below:

General Tech sites: https://news.ycombinator.com http://recode.net/

Laravel specific: http://laravel-news.com

Podcasts: http://www.laravelpodcast.com/ http://www.se-radio.net/

And of course always read the official documentations and practice.

jkoech left a reply on Is There Any Document That Describes An RESTful API?

I don't think a standard documentation exists but you could just follow best practises i.e using RESTful URLs and actions etc. There are plenty of books and guidelines available which will guide you.

14 May
3 years ago

jkoech started a new conversation Vue.js Tutorials

@JeffreyWay would you mind doing a quick intro to Vue.js?

jkoech left a reply on Why Laravel Docs Not Good As Codeigniter

Having a complete example, like the way it's shown on the master documentation, in my opinion is the best way one can easily learn.

13 May
3 years ago

jkoech left a reply on Laravel 5 Authentication And Roles

@csuarez yes, I'll did stick with the middleware, I found out that it was really easy stuff.

@ptgokulrajan basically, I didn't change RedirectIfAuthenticated, I just created a new IsRole middleware, i.e IsAdmin.php with something similar to the below:

'''

@param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user = $request->user(); if ($user && $user->isAdmin()) { return $next($request); } return new RedirectResponse(url('/')); } } '''
21 Apr
3 years ago
13 Apr
3 years ago

jkoech started a new conversation [OT] Mac Screencast App

I'm new to Mac and looking for recommendations for a cool screencast app, like the one @JeffreyWay uses for Laracasts. Thanks.

08 Apr
3 years ago

jkoech left a reply on Cross Platform Desktop App, Anything Better Than Node-webkit?

@isimmons keep me posted on your progress and your evaluation. If it's great, I'll start learning.