kvnkrft

kvnkrft

Member Since 1 Year Ago

Experience Points 7,460
Experience Level 2

2,540 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 37
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.

13 Mar
1 week ago

kvnkrft left a reply on Excluding Algolia Results Based On Dates Values

I ended up rewriting code so my application will only add to Algolia when the record should be discoverable. I setup a command and scheduler... so now it checks every minute to see if something should be added/removed.

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

kvnkrft left a reply on Could Not Open Input File: /home/forge/dev.mysite.com/artisan

@BRAUNSON - I figured it out, it was entirely my fault... typo.

So frustrating. Thanks for your help!

kvnkrft started a new conversation Issue Getting SSL To Work (This Site Can’t Be Reached)

I'm having issues getting my SSL certificate to work using Forge. It is installed as per instructions and Forge shows it as installed, but when I go to the site using https, I get This site can’t be reache

It's a wildcard certificate. Everything looks right, but clearly, something isn't okay.

kvnkrft left a reply on My ToSearchableArray() Only Works Correctly Using Scout:import ... Not When Creating Or Updating

I figured it out, but I don't entirely understand why scout:import worked but creating and updating did not.

Here's the revised code that seems to work all around:

public function toSearchableArray(){

        $record = $this->toArray();

        $record['vendor'] = $this->vendor->name;
        $record['categories'] = $this->categories->pluck('slug')->all();

        return $record;

    }

kvnkrft left a reply on Trying To Filter Results Via Route Variable... Vue Instant Search

Figured it out. It needed to to be :query-parameters to bind it.

kvnkrft started a new conversation My ToSearchableArray() Only Works Correctly Using Scout:import ... Not When Creating Or Updating

I've got the toSearchableArray() defined in my Deal model

    public function toSearchableArray(){

        return $this->toArray() + [
                'vendor' => $this->vendor->name,
                'categories' => $this->categories->pluck('slug')->toArray()
            ];

    }

The problem is that when I create a new record or edit a record (model Deal), the entire vendor collection is added and none of the categories.

The strange is is, when I run php artisan scout:import 'App\Deal' everything works exactly as expected... only the vendor name is added, and an array of categories is added to the search index.

Thoughts?

12 Mar
1 week ago

kvnkrft started a new conversation Trying To Filter Results Via Route Variable... Vue Instant Search

I have a route setup

Route::get('/{category}', '[email protected]')->name('category');

and in my home.blade.php I'm trying to filter results with Vue Instant Search based on the category value, but my code is not working -- clearly I don't know what I'm doing.

<ais-index
                    app-id="{{config('scout.algolia.id')}}"
                    api-key="{{config('scout.algolia.key')}}"
                    index-name="{{config('scout.prefix')}}deals"
                    query-parameters="{ filters: '(category:{{$current_category}})' }"
            >

Any thoughts?

kvnkrft started a new conversation Could Not Open Input File: /home/forge/dev.mysite.com/artisan

I'm trying to get scheduled tasks going, but I get this error message when I try to setup the scheduled task in Forge:

Could not open input file: /home/forge/dev.mysite.com/artisan

Any thoughts?

09 Mar
1 week ago

kvnkrft started a new conversation Excluding Algolia Results Based On Dates Values

I have records with a publish_from and publish_to date, if now() is between those 2 values the record is visible to the users. I have the logic in my controller right now, but now I need to move the logic over to VUE to work with Algolia. Is there a way to configure such rules in Algolia? Alternatively, I have to "update" the index every... minute... which doesn't seem right.

I also want to make sure the user can't overwrite settings and grab records that aren't public yet.

06 Mar
2 weeks ago

kvnkrft started a new conversation UUID And Pivot Tables

I found the article about UUID from @wilburpowery (https://wilburpowery.co/posts/easy-uuids-in-laravel/) and everything is working great, other than attaching. The error message is...

SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value (SQL: insert into `deal_category_pivot` (`category_id`, `deal_id`) values (b4fca70c-ba7b-4ad8-99d9-0908aa6837df, 7439b146-cd29-4aa3-9718-bfc93707724d)) 

which makes perfect sense. I just don't know how to modify the trait to take care of this. Any thoughts?

Here is the trait, as per the article...

<?php

namespace App\Traits;

use Illuminate\Support\Str;

trait UsesUuid
{
    protected static function bootUsesUuid()
    {
        static::creating(function ($model) {
            if (! $model->getKey()) {
                $model->{$model->getKeyName()} = (string) Str::uuid();
            }
        });
    }

    public function getIncrementing()
    {
        return false;
    }

    public function getKeyType()
    {
        return 'string';
    }
    
}
02 Apr
11 months ago

kvnkrft started a new conversation Algolia W. Multi-tenant Laravel App

I'm using Alogolia and Vue InstantSearch.

My Laravel app has users, who can belong to one or more companies. Right now I have 3 different Aloglia indices with user details, one for each of my environments (local, development, and production). Each index has the first name, last name, email address and the viewable_by array which contains the IDs of the companies to which the user belongs (so ensure that the user doesn't show up for all companies/tenants).

I am keen to add tenant-specific search criteria to the index, including the teams that the user belongs to. Any thought on how to approach this?

So essentially I'd have to add a "teams" array, a sub-array for each company that has the list of teams. So something like:

user

  • first_name
  • last_name
  • viewable_by -- 7, 45, 192
  • teams -- Company 7 --- Marketing --- Design -- Company 45 --- Technology -- Company 192 --- Marketing --- Creative

Thoughts?

08 Mar
1 year ago

kvnkrft started a new conversation Charting Options. Chartist, ChartJS...

I'm currently using ChartJS in my laravel application, but I'm having issues with the responsiveness. The charts look terrible on a small screen, with legend items overlapping the axis title... I started looking at Chartist, and the responsiveness seems a lot better.

Thoughts on Chartist? Any other charting options?

22 Feb
1 year ago

kvnkrft left a reply on Tenant-specific Searches - Scout Way VS Algolia

I am working on figuring out how to make server-side results work with vue-instantsearch. It's quite an adventure.

18 Feb
1 year ago

kvnkrft left a reply on Request For Feedback On Vue InstantSearch By Algolia

I am surprised that you have not received any feedback.

vue-instantsearch is pretty awesome, very powerful and it makes getting search going, pretty easy - especially for a noob like I am.

I am struggling quite a bit with making instant search work with server-side rendering, or more specific, implementing vue-instantsearch with tenant-specific searches.

17 Feb
1 year ago

kvnkrft started a new conversation Tenant-specific Searches - Scout Way VS Algolia

I've been working on limiting searches to be client specific, and Algolia outlines adding a viewable_by array to each record, then creating a secret API key, using it for the search (https://www.algolia.com/doc/tutorials/security/api-keys/secured-api-keys/how-to-restrict-the-search-to-a-subset-of-records-belonging-to-a-specific-user/). I couldn't figure out how to pass the secret API key through and discovered the where clause with Laravel Scout. It seems like Laravel Scout recommends using the ->where statement for tenant specific results (https://laravel.com/docs/5.5/scout#searching), the problem is that viewable_by contains an array, not a single value.

Anyhow, any recommendations on how to use Laravel Scout to enable tenant-specific search, where users can belong to multiple tenants. I have Users who can belong to many Companies.

kvnkrft started a new conversation Laravel Scout / Alogolia And GenerateSecuredApiKey

I am trying to figure out how and when to generate a secured API key for each of my users, to ultimately restrict each user to their own dataset. I know that I need to create a secret API key, but I'm unsure when and how. Can I create an API key when the user is created, and then just re-use the key, or should I generate a new key for each query?

Are there any Laravel Scout tutorials using the generateSecuredApiKey?

kvnkrft left a reply on ToSearchableArray() In My User Model Isn't Being Used

I figured out that when I disable the queuing 'queue' => env('SCOUT_QUEUE', false) in the config/scout.php file, the override in my User model works. This isn't really a solution, but at least I can continue developing while I try to find an answer for this.

16 Feb
1 year ago

kvnkrft started a new conversation ToSearchableArray() In My User Model Isn't Being Used

I'm trying to modify what's being indexed by Algolia and thought I could accomplish that by overwriting toSearchableArray() in my User model, but it's not working. As in, nothing is added to the Aloglia index for my User model... I don't think my toSearchableArray() is even being accessed. Thoughts?

public function toSearchableArray()
    {
        $full_name = $this->first_name.' '.$this->last_name;
        return $this->toArray() + ['full_name' => $full_name, 'viewable_by' => [1,4,5]];
    }
14 Feb
1 year ago

kvnkrft started a new conversation Laravel Scout, Algolia, Secured API Key, And Viewable_by

I'm trying to limit searches by user, but haven't figured out how to do it using Laravel Scout... with Algolia, Secured API Key, and populating viewable_by...

Any pointers would be REALLY appriciated.

11 Feb
1 year ago

kvnkrft left a reply on Search Without Algolia?

@topvillas I am asking what people's thoughts are on Angolia.

kvnkrft started a new conversation Search Without Algolia?

I'm curious what everyone's thought is on Algolia. I watched some of the Laracasts videos, and Algolia looks amazing, but I'm keen to (a) keep data in my database, and (b) not use an API for some of this core functionality -- like searching. I also do much of my development while I'm offline, and relying on third-party services becomes a problem.

kvnkrft left a reply on Question About Horizon:snapshot

Oh wow @bobbybouwmann Totem looks really interesting. I will do some research, it seems like it doesn't replace Horizon, but rather, works with Horizon, right? Because Horizon is for management of queues not schedules...

10 Feb
1 year ago

kvnkrft left a reply on Cashier - HandleInvoicePaymentSucceeded Not Working

Hi @bobbybouwmann it's working now, on the development server, after I added CASHIER_ENV=testing to the env file. I can't find any documentation on CASHIER_ENV=testing and I'm hoping that, it will work in production, without CASHIER_ENV=testing.

kvnkrft left a reply on Question About Horizon:snapshot

Hi @bobbybouwmann thanks for your help. I think I've got it all working. It would be great to see more information as to which scheduled task ran, and which didn't. I've added some logging... not the best, but it will do for now.

09 Feb
1 year ago

kvnkrft left a reply on Weekly()->fridays() Executed On Thursday

Okay, so the answer is: The timezone is not determined by the timezone set on the server, but int he config/app.php. I decided to leave the timezone set to UTC and instead added the ->timezone('America/Swift_Current') to my scheduled tasks.

kvnkrft left a reply on Weekly()->fridays() Executed On Thursday

Why did my job run in UTC when I configured the server to CST? I don't get it. Help me understand.

kvnkrft started a new conversation Weekly()->fridays() Executed On Thursday

I have a task scheduled:

$schedule->command('do:send-reminder-emails')->weekly()->fridays();

But it was triggered/executed on Thursday, because I received the emails on Thu, Feb 8, 2018 at 6:00 PM.

I checked the server time, and it's set to now (Fri Feb 9 15:49:34 CST 2018), so it shouldn't be a server timezone issue.

Any ideas? Thoughts?

kvnkrft left a reply on Cashier - Webhooks - Route In 5.5 Docs Correct?

It's working, but I don't understand the logic :)

kvnkrft started a new conversation Question About Horizon:snapshot

The docs at https://laravel.com/docs/5.5/horizon#metrics state that adding $schedule->command('horizon:snapshot')->everyFiveMinutes(); to the schedule should create a Horizon Snapshot, but shouldn't it be $schedule->command('php artisan horizon:snapshot')->everyFiveMinutes()? What am I missing?

kvnkrft started a new conversation Cashier - HandleInvoicePaymentSucceeded Not Working

Good morning all,

Any thoughts as to why the invoice.payment_succeeded POST from Stripe isn't "going into" my handleInvoicePaymentSucceeded method?

I checked the docs, and things look right, I just can't figure out what I'm doing wrong (https://laravel.com/docs/5.5/billing#handling-stripe-webhooks)

<?php

namespace App\Http\Controllers\Cashier;

use \Laravel\Cashier\Http\Controllers\WebhookController as BaseController;
use Log;

class WebhookController extends BaseController
{
    // When a first-time or recurring payment is successful

    function __construct()
    {
        Log::debug('In Custom Webhook Controller');
    }

    // Stripe Event: invoice.payment_succeeded
    public function handleInvoicePaymentSucceeded($payload)
    {

        // Problem: Stripe POST does not go into this method
        Log::debug('In handleInvoicePaymentSucceeded');

        // If in production
        // TODO: change 'dev' to 'production'
        if (App::environment('dev')) {

            // Debug Log
            Log::debug('Webhook Notification Received from Stripe');
            Log::debug('Webhook Payload: '.implode( ", ", $payload ) );

            // Look thins up, depending on payload

            // Send details to Google Analytics

            return response('Webhook Handled', 200);
        }


    }

}
08 Feb
1 year ago

kvnkrft started a new conversation Cashier - Webhooks - Route In 5.5 Docs Correct?

I'm a bit confused. Looking at the Cashier docs for 5.5 (https://laravel.com/docs/5.5/billing#handling-stripe-webhooks) the route for the webhook points to \Laravel\Cashier\Http\Controllers\[email protected] but I'm pretty sure that I don't have this directory, but rather my WebhookController is in /vendor/laravel/cashier/src/Http/Controllers/WebhookController.php.

What am I missing? Is there some Laravel magic that I'm not aware of?

01 Feb
1 year ago

kvnkrft left a reply on Supporting Content-Security-Policy

Yea it sure looks like a nightmare.

BePsvPT/secure-headers (https://github.com/BePsvPT/secure-headers) did a great job, but it requires some pretty intense configuration - intense for me.

So each JS and CSS file needs a hashed token with it? Sounds like something that should be automated somehow?

kvnkrft left a reply on Supporting Content-Security-Policy

Hi @martinbean thanks. I am just going to take it all out and stick with the B grade for now. I had issues with all the VUE bits. I think this would be a maintenance nightmare.

kvnkrft left a reply on Supporting Content-Security-Policy

I just wanted to provide an update.

I found this package:

BePsvPT/secure-headers https://github.com/BePsvPT/secure-headers

And I found this great post:

https://barryvanveen.nl/blog/35-how-to-configure-security-headers-for-laravel

It turns out to be quite a project to get everything in there, especially when trying to get third party scripts working.

I may abandon this for now.

kvnkrft started a new conversation Supporting Content-Security-Policy

Good morning,

I am trying to resolve this warning from a site scan: Content Security Policy (CSP) header not implemented but solving this doesn't seem to be an easy task.

Has anyone dealt with this?

Kevin

31 Jan
1 year ago

kvnkrft left a reply on Redis Stuck (Horizon Shows Task With Pause)

I figured it out. I was looking through the config/horizon.php file and noticed that there was configuration for local and production but the name of my development environment is development. I copied the production block, pasted it in, and renamed it to development. Now it seems to work.

kvnkrft left a reply on Redis Stuck (Horizon Shows Task With Pause)

Hi @bashy thanks for your help. Yea, I just tried it and php artisan queue:work worked and processed the queue. I had also tried php artisan horizon which I thought "replaces" the queue:work command once I'm using Horizon.

What does this tell us? The horizon daemon is running... hm.

kvnkrft started a new conversation Redis Stuck (Horizon Shows Task With Pause)

I'm very confused and don't know how to trouble shoot this.

Tasks in the redis queue seem to be stuck, showing a "pause" icon. The tasks did not get processed, the emails aren't being sent. It works locally, and i've got the queue driver set to redis in my env file.

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=11520
QUEUE_DRIVER=redis

Horizon Screenshot

Any ideas?

28 Jan
1 year ago

kvnkrft left a reply on Scheduling Q: Would $schedule->command('##')->mondays() Execute Monday Morning?

Thanks @jryd I don't want to set a time, just want to run first thing on Monday. Let's see if that works.

kvnkrft started a new conversation Scheduling Q: Would $schedule->command('##')->mondays() Execute Monday Morning?

I'm trying to schedule tasks at the beginning of the week, so once Sunday is DONE I need the task to execute. Would I use ->mondays()?

22 Jan
1 year ago

kvnkrft left a reply on Customizing Cashier Invoices

@Cronix that worked like a charm, thank you!

kvnkrft left a reply on Customizing Cashier Invoices

Thanks @Cronix could I just manually create that folder? Would that work too?

kvnkrft started a new conversation Customizing Cashier Invoices

Hi all, is there a way that I can customize the Cashier invoices? Or does it require me to come up with a "custom" thing?

kvnkrft left a reply on Filling The <title>... Controller? Routes?

@martinbean thanks a bunch, that works great. Just did that for all my views. I wasn't sure where to store this, but it probably makes most sense to store this in the views. It's mostly for Google Analytics, so I can see things by Page Title, it makes reporting a bit friendlier.

kvnkrft started a new conversation Error: Your Local Changes... Would Be Overwritten By Merge...

Good morning all, I'm getting an error message on Laravel Forge - and I have NO idea how to resolve it. Everything is committed...

Mon Jan 22 14:15:33 UTC 2018
From bitbucket.org:###
 * branch            master     -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
    package-lock.json
    package.json
Please, commit your changes or stash them before you can merge.
Aborting
Updating 122a1f1..ccd8435

kvnkrft left a reply on Filling The <title>... Controller? Routes?

Hi @Jaytee, thank you. It sounds like there is not 1 right way to do it. I wasn't sure, Laravel and all it's magic, I am trying to stick to much of the "framework" as possible without trying to cook up my own scariness.

21 Jan
1 year ago

kvnkrft started a new conversation Filling The <title>... Controller? Routes?

Any thoughts on how I should pass a proper title value to the tag that's in the app.balde.php? I was thinking to just pass the value to the view from the controllers, but maybe there is a better way? Maybe from the web.php/routes?

13 Jan
1 year ago

kvnkrft left a reply on Cashier Battle Continues - No Such Customer

I've got it all working now. Here is what I did...

#Changed the user_id column in the subscriptions table to company_id #Used createAsStripeCustomer() before creating the subscription.

kvnkrft started a new conversation Cashier Battle Continues - No Such Customer

I've been through the Laracast video on Cashier, which is outdated, but some people had mentioned that not that much has changed since then. Anyhow, I'm getting an error when I try to create a subscription -- and I'm starting to think that I need to create a Stripe customer first, and use a customer token instead of the token from the check out. If that is the case, then... but I can't find anyone hinting that this is the case.

Here's my code to create the subscription, I didn't use User, but instead used the Company model for my project:

// https://laravel.com/docs/5.5/billing#stripe-configuration
$company->newSubscription('10 Users', '10-monthly')->create($stripeToken);

And here is the error message I see in the logs:

[2018-01-13 11:28:47] local.ERROR: No such customer: tok_1BjnBkLrP3RyeWsmPmbKc7Dn {"userId":21,"email":"[email protected]","exception":"[object] (Stripe\Error\InvalidRequest(code: 0): No such customer: tok_1BjnBkLrP3RyeWsmPmbKc7Dn at /vendor/stripe/stripe-php/lib/ApiRequestor.php:124)
[stacktrace]
11 Jan
1 year ago

kvnkrft left a reply on Stripe Question

Incase someone else comes across the same issue, here's what is working for me. I got help from someone - not on here - thank you.

<div class="row">
            <div class="col-md-4"><h2>Subscription</h2></div>
            <div class="col-md-8">

                <button class="btn btn-primary" id="purchase-button">Purchase</button>

                @push('scripts')
                    <script src="https://checkout.stripe.com/checkout.js"></script>
                    <script>
                        const handler = StripeCheckout.configure({
                            key   : 'pk_test_4CGhk########Po7RWVM',
                            image : 'https://stripe.com/img/documentation/checkout/marketplace.png',
                            locale: 'auto',
                            token : function (token) {
                                console.log(token);
                            }
                        });

                        document.getElementById('purchase-button').addEventListener('click', function (e) {
                            // Open Checkout with further options:
                            handler.open({
                                name       : 'Company Name',
                                description: 'Service Description',
                                amount     : 2000, // 
                                currency   : 'usd',
                                locale     : 'auto',
                            });
                            e.preventDefault();
                        });

                        // Close Checkout on page navigation:
                        window.addEventListener('popstate', function () {
                            handler.close();
                        });
                    </script>
                @endpush

            </div>
        </div>