gathuku

gathuku

Member Since 1 Year Ago

Thika

Experience Points 2,400
Experience Level 1

2,600 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 14
Lessons
Completed
Best Reply Awards 0
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.

25 Jul
3 weeks ago

gathuku started a new conversation API Request With Guzzle

Am getting this error while trying to make an api request with Guzzle.

{"fault":{"faultstring":"Header {0} contains non ascii character {1}","detail":{"errorcode":"protocol.http.HeaderNameWit (truncated...)
28 Jun
1 month ago

gathuku left a reply on Vue Components

@MAVERICKCHAN - Let me give it a try

27 Jun
1 month ago

gathuku started a new conversation Vue Components

Am consuming an Api with a Vue Cli application, I have a Login Component which return authentication token on successful Login , How can i be able to fetch the token from Login component data to my main.js so that i can set it in axios request authorization headers .

import axios from 'axios'
import VueAxios from 'vue-axios'

Vue.use(VueAxios, axios)
axios.defaults.baseURL = 'http://127.0.0.1:3000/v1/'
axios.defaults.headers.common = {'Authorization': `Bearer ${Token}`}

Vue.use(VueRouter);

const router=new VueRouter({
  routes,
  mode:'history',
});
Vue.config.productionTip = false

new Vue({
  render: h => h(App),
  router,

}).$mount('#app')
22 May
2 months ago

gathuku left a reply on Nginx Configuration

@CRONIX - How can i resolve this please

21 May
2 months ago

gathuku left a reply on Nginx Configuration

@BOBBYBOUWMANN - Am using the root user > Also enabled 775 rights on the directory.

gathuku started a new conversation Nginx Configuration

Am Getting this error in nginx log , when trying to run laravel(5.5) application. Php setup is working fine when text with a single Hello world file.

2019/05/21 14:49:29 [error] 16832#16832: *24 directory index of "/var/www/html/" is forbidden, client: 196.110.213.204, server: 142.93.214.253, request: "GET / HTTP/1.1", host: "142.93.214.253"

Here is the server block configuration am using.

server {
        listen 80;
        root /var/www/html/public;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name 142.93.214.253;

        location / {
                try_files $uri $uri/ /=404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }
}

19 May
2 months ago

gathuku left a reply on Laravel Form Builder

@tray2 @snapey @kane Thankyou for your replies, am maintaining an old project, but i figured what the problem was.

 {{ Form::file('image', ' ',array('class'=>'form-control')) }}

Removing second parameter worked for me.

 {{ Form::file('image', array('class'=>'form-control')) }}

Read More https://github.com/laravel/framework/issues/948

gathuku started a new conversation Laravel Form Builder

I was debugging an error related with laravel form Builder. Here's the error stack

[2019-05-19 11:11:06] local.ERROR: ErrorException: Illegal string offset 'name' in /home/moses/Documents/WEB/laravel/loan/vendor/laravelcollective/html/src/FormBuilder.php:273
Stack trace:
#0 /home/moses/Documents/WEB/laravel/loan/vendor/laravelcollective/html/src/FormBuilder.php(273): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Illegal string ...', '/home/moses/Doc...', 273, Array)
#1 /home/moses/Documents/WEB/laravel/loan/vendor/laravelcollective/html/src/FormBuilder.php(484): Collective\Html\FormBuilder->input('file', 'company_logo', NULL, '')
#2 /home/moses/Documents/WEB/laravel/loan/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Collective\Html\FormBuilder->file('company_logo', '', Array)
#3 /home/moses/Documents/WEB/laravel/loan/storage/framework/views/e46d5901ebec5d06a99068ca5770f4e323b66982.php(116): Illuminate\Support\Facades\Facade::__callStatic('file', Array)
#4 /home/moses/Documents/WEB/laravel/loan/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(42): include('/home/moses/Doc...')
#5 /home/moses/Documents/WEB/laravel/loan/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/home/moses/Doc...', Array)
#6 /home/moses/Documents/WEB/laravel/loan/vendor/laravel/framework/src/Illuminate/View/View.php(137): Illuminate\View\Engines\CompilerEngine->get('/home/moses/Doc...', Array)
#7 /home/moses/Documents/WEB/laravel/loan/vendor/laravel/framework/src/Illuminate/View/View.php(120): Illuminate\View\View->getContents()
#8 /home/moses/Documents/WEB/laravel/loan/vendor/laravel/framework/src/Illuminate/View/View.php(85): Illuminate\View\View->renderContents()
#9 /home/moses/Documents/WEB/laravel/loan/vendor/laravel/framework/src/Illuminate/Http/Response.php(38): Illuminate\View\View->render()

Anyone hint how i can solve the error.

27 Apr
3 months ago

gathuku left a reply on Internal Api Requests

@XTREMER360 - Here is how you can add it.

$request->headers->set('Authorization','Bearer '.token);

gathuku left a reply on Internal Api Requests

@XTREMER360 - Please inform if you see something which can help. Thankyou

gathuku started a new conversation Internal Api Requests

hello, am consuming an internal API within the same laravel application.

Here is how am sending the request

    $request = Request::create('/api/v1/login', 'POST',[
      'name'=>Input::get('email'),
      'password'=>Input::get('password')
      ]);

    $response = Route::dispatch($request);

form_params are working well Someone help how i can pass headers with authorization bearer token.

14 Mar
5 months ago

gathuku started a new conversation Arrays And Object

how will i be able to loop through the data and extract every value. bearing in mind the values may reduce or increase depending on user's choice.

 array (
  'selected' => 
  array (
    0 => '1',
    1 => '2',
    2 => '3',
    3 => '4',
    4 => '5',
  ),
)

gathuku left a reply on How To Post Data To Laravel Using Ajax

@WILK_RANDALL - how will i be able to loop through the data and extract every value. bearing in mind the values may reduce or increase depending on user's choice.

[2019-03-14 16:08:52] local.INFO: array (
  'selected' => 
  array (
    0 => '1',
    1 => '2',
    2 => '3',
    3 => '4',
    4 => '5',
  ),
)  

gathuku left a reply on How To Post Data To Laravel Using Ajax

@DUBBELTJE - Am not using any form

gathuku started a new conversation How To Post Data To Laravel Using Ajax

Hello , i have an array of data which am trying to pass to a laravel function in controller using ajax. Basically the array contains a list of selected checkbox and their values.

here is my javascript and ajax code

  <script type="text/javascript">

    $.ajaxSetup({
      headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
      }
    });

    document.getElementById('register_unit').addEventListener('click', function(){

    var selected = new Array();

    $(document).ready(function() {

      $("input:checkbox[name=check]:checked").each(function() {
           selected.push($(this).val());
      });

      console.log(postData)
      $.ajax({
      type: "POST",
      url: '/unit/register',
      data: selected,
      cache: false,
      success: function(data){
          alert(data);
      }
      });



    });
    });

    </script>

This is how am logging the data in my controller

  public function saveUnits(Request $request)
    {
      \Log::info($request->all());

    }

Upon logging , i receive an empty array in my log

[2019-03-14 12:23:27] local.INFO: array (
  'undefined' => NULL,
)  

Someone help!

06 Mar
5 months ago

gathuku started a new conversation Laravel

help me solve this when i try to access laravel project in localhost

Sorry, you are not authorized to access this page
17 Feb
6 months ago

gathuku started a new conversation Laravel Cashier With Braintree

Am integrating brain tree using laravel cashier. How can you check if invoice is paid or unpaid from this invoice object.

<table>
    @foreach ($invoices as $invoice)
        <tr>
            <td>{{ $invoice->date()->toFormattedDateString() }}</td>
            <td>{{ $invoice->total() }}</td>
            <td><a href="/user/invoice/{{ $invoice->id }}">Download</a></td>
        </tr>
    @endforeach
</table>
14 Jan
7 months ago

gathuku left a reply on How To Create Facades On Laravel 5.7 Package

I had a typo in my facades class namespace

supposed to be

namespace Gathuku\Mpesa\Facade;

Thanks Everyone for Helping

gathuku left a reply on How To Create Facades On Laravel 5.7 Package

@TALINON - here's what i did on register function of MpesaServiceProvider

  public function register()
    {
        $this->app->bind('gathuku-mpesa',function(){
             return new Mpesa();
        });
    }

My Mpesa class is here

<?php

namespace Gathuku\Mpesa;

class Mpesa{

    public function display(){

        return "this is display funtion";
    }
}

and here's is my facade class

<?php

namespace Gathuku\Mpesa\Facade;

use Illuminate\Support\Facades\Facade;

class Mpesa extends Facade{

    protected static function getFacadeAccessor(){

        return 'gathuku-mpesa';
    }
}

13 Jan
7 months ago

gathuku started a new conversation How To Create Facades On Laravel 5.7 Package

Am making a package in laravel 5.7 which will require use of facades, i have created a facades directory in scr folder with the following class.

<?php

namespace mpesa\Facades;

use Illuminate\Support\Facades\Facade;

class Mpesa extends Facade{

    protected static function getFacadeAccessor(){

        return 'gathuku-mpesa';
    }
}

The i have added the facade in alias object in app config.

'Mpesa' => Mpesa\Facades\Mpesa::class,

unfortunately am getting this error

Class 'Mpesa\Facades\Mpesa' not found

Kindly help.

15 Nov
9 months ago

gathuku started a new conversation Laravel

hello guys i have form which am try to submit but am getting method not allowed error

here's the form

                  <input name="rowid" type="hidden" value="{{$content->rowId}}">
    
                  <div class="input-group mb-3" style="max-width: 120px;">
                    <div class="input-group-prepend">   
                    </div>
                    <input name="qty" type="text" class="form-control text-center" value="1" placeholder="" aria-label="Example text with button addon" aria-describedby="button-addon1">
                    <div class="input-group-append">
                      <input type="submit" class="btn btn-primary" value="&plus;">
                      
                    </div>
                  </div>
                  
                  </form>

here' s my route

Route::post('/update-cart','[email protected]')->name('update-cart');

26 Oct
9 months ago

gathuku started a new conversation Laravel Route

Hey am trying to route to this url but it doesn't load css and javascript

http://myapp.test/test/1 Rote with data not loading public resources ( ie css and javascript)

http://myapp.test/test Without data works fine

Kindly help

03 Aug
1 year ago

gathuku left a reply on Api Requests

Like am suppossed to provide a url to that api , where it will return the results, so how can i listen to that url, so that am able to get that response

gathuku started a new conversation Api Requests

Hey guys....I have a url which is supposed to return Json data , how can i implement these in Laravel. The url is return data from an Api. How do i listen to the url and be able get the data.

02 Aug
1 year ago

gathuku started a new conversation Api Data

'CallBackURL' => 'http://f3c3c.ngrok.io/callback',

Route::post('callback','[email protected]');

public function getDataFromCallback(Request $request){

  $data=$request->getContent();

  dump($data);
}

please help me how to implement a call back in laravel .The callback url returns json data form an API which i want to print/dump in my method , above is the callBackurl, my route and the method where route is directed. Am getting 419 unknown status as the error.

10 Jul
1 year ago

gathuku left a reply on Array Objects

Thanks It's working.

gathuku started a new conversation Array Objects

Hello all, I have an Query which returns an array of data, How can i retrieve those objects data. Currently am getting these error when i try to retrieve an object message in the array.

here's error

Property [message] does not exist on this collection instance.

here's my code

$announ=Announ::where('sent_to','0')->get();

$sender=$announ->message;

05 Jul
1 year ago

gathuku started a new conversation Data Storing

I want after a user has registered Successfully i get the id assigned to that user in table users . then store it in another table immediately.

protected function create(array $data) { $user= User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]);

      Profile::create([
    
        'user_id'=> Auth::User()->id,
      ]);
      return $user;

}

13 May
1 year ago

gathuku started a new conversation Laravel Socialite

I am working on a laravel project that include facebook integration. I am facing the Insecure Login Blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https:// problem since two days. I have tried many ways to solve this problem but nothing happen. So tell me how can I integrate facebook on localhost. please help me.