nickclicksco

nickclicksco

Member Since 1 Year Ago

Experience Points
1,140
Total
Experience

3,860 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
3
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.

Level 1
1,140 XP
May
31
1 year ago
Activity icon

Started a new conversation Laravel Unable To Return Nested Data From Guzzle With Json_decode Ask

I'm having an issue with accessing data that is nested within an array.

Here is an example of my Guzzle request and how I am decoding it and returning it:

      $raw_response = $client->request('GET', 'https://api.com/endpoint');
    
      $body = $raw_response->getBody();
      $body_content = json_decode($body, true);
    
      $body_collection = collect($body_content);
    
      return $body_collection[0]['instances'][0]['spec'];

This unfortunately doesn't work however if I return it without ['spec']:

    return $body_collection[0]['instances'][0]

I actually get some data returned:

    {
        "platform": {
            "browserName": "Electron",
            "browserVersion": "59.0.3071.115",
            "osCpus": null,
            "osMemory": null,
            "osName": "linux",
            "osVersion": "Debian - 8.10",
            "osVersionFormatted": "Debian - 8.10"
        },
        "createdAt": "2018-05-30T02:05:44.648Z",
        "claimedAt": null,
        "completedAt": "2018-05-30T02:05:59.694Z",
        "error": null,
        "failed": 0,
        "id": "d941be0c-27a7-41e9-b26f-bdaaedc494be",
        "machineId": null,
        "passed": 1,
        "pending": 0,
        "status": "passed",
        "stdout": null,
        "skipped": null,
        "spec": "/root/app/cypress/integration/api/intent-match_spec.js",
        "wallClockDuration": 2785,
        "wallClockStartedAt": null,
        "wallClockEndedAt": null,
        "videos": null,
        "screenshots": null
    }

However when I try and access the spec element it returns nothing in Postman. If I dump like so:

    dd($body_collection[0]['instances'][0]['spec']);

Then the data is returned when I use Postman: "/root/app/cypress/integration/api/intent-match_spec.js"

Here is a dump of the whole $body_content, I've set a lot of the data as null as it can't be shared. Also the parent array usually returns 30 other arrays but I've shortened this.

    array:30 [
      0 => array:26 [
        "ci" => array:3 [
          "url" => null
          "provider" => null
          "buildNumber" => "15718"
        ]
        "commit" => array:6 [
          "authorName" => null
          "authorEmail" => null
          "message" => null
          "branch" => "master"
          "sha" => null
          "url" => null
        ]
        "id" => null
        "projectId" => null
        "projectName" => null
        "buildNumber" => 39399
        "cypressVersion" => "2.1.0"
        "totalPassed" => 1
        "totalFailed" => 0
        "totalPending" => 0
        "totalSkipped" => null
        "totalDuration" => 15228
        "completedAt" => "2018-05-30T02:05:59.727Z"
        "createdAt" => "2018-05-30T02:05:44.499Z"
        "updatedAt" => "2018-05-30T02:05:59.727Z"
        "status" => "passed"
        "specPattern" => null
        "runUrl" => null
        "projectUrl" => null
        "specIsolation" => false
        "loadBalancing" => false
        "instances" => array:1 [
          0 => array:19 [
            "platform" => array:7 [
              "browserName" => "Electron"
              "browserVersion" => "59.0.3071.115"
              "osCpus" => null
              "osMemory" => null
              "osName" => "linux"
              "osVersion" => "Debian - 8.10"
              "osVersionFormatted" => "Debian - 8.10"
            ]
            "createdAt" => "2018-05-30T02:05:44.648Z"
            "claimedAt" => null
            "completedAt" => "2018-05-30T02:05:59.694Z"
            "error" => null
            "failed" => 0
            "id" => "d941be0c-27a7-41e9-b26f-bdaaedc494be"
            "machineId" => null
            "passed" => 1
            "pending" => 0
            "status" => "passed"
            "stdout" => null
            "skipped" => null
            "spec" => "/root/app/cypress/integration/api/intent-match_spec.js"
            "wallClockDuration" => 2785
            "wallClockStartedAt" => null
            "wallClockEndedAt" => null
            "videos" => null
            "screenshots" => null
          ]
        ]
        "failedTests" => null
        "orgId" => null
        "orgName" => null
        "orgDefault" => false
      ]
    ]

Can you think of any reason why this might be happening?

May
29
1 year ago
May
27
1 year ago
Activity icon

Started a new conversation Using Api.php Routes Without The Need For An Access Token

Hi guys, I want to use the api.php file so that I can turn my Spark dashboard into an SPA.

At the moment I have tried using this:

Route::group([
    'prefix' => 'v1',
    'middleware' => 'auth:api',
], function () {
    Route::get('/hello', function () {
        return response()->json(["hello" => "there"]);
    });
}); 

If I hit this api/v1/hello route it will redirect me to the home route unless I set an access token within the dashboard. When I include the access token as a parameter in the URL the route starts to work.

This is no good for me though. I just want to check if a user is logged in and if they are then serve the response from the API route.

I have tried using:

'middleware' => 'auth'

instead of using:

'middleware' => 'auth:api'

However this didn't work, I was just redirected when I tried to visit the route.

Any help would be great, thanks.

May
20
1 year ago
Activity icon

Started a new conversation Using The GRPC Extension With Homestead

Hi everyone, I'm trying to install an extension from this guide:

https://cloud.google.com/php/grpc

The reason I need this extension is because I'm trying to install the Google Firestore DB here: https://firebase.google.com/docs/firestore/quickstart

So far I have done the following...

I've added extension=grpc.so to my after.sh file within my Homestead folder and ran vagrant up --provision. This doesn't work, as when I run Composer and try to install Cloud Firestore I get:

  Problem 1
    - Installation request for google/cloud-firestore ^0.9.1 -> satisfiable by google/cloud-firestore[v0.9.1].
    - google/cloud-firestore v0.9.1 requires ext-grpc * -> the requested PHP extension grpc is missing from your system.

  To enable extensions, verify that they are enabled in those .ini files:
    - /usr/local/etc/php/7.1/php.ini
    - /usr/local/etc/php/7.1/conf.d/ext-mongodb.ini
    - /usr/local/etc/php/7.1/conf.d/php-memory-limits.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Any idea how I can resolve this?

Thanks

May
19
1 year ago
Activity icon

Started a new conversation Setting Up Spark To Be An SPA?

I'm a little bit confused by the Spark 6.0 app set up. I'm seeing Vue sprinkled all over the Spark application however why doesn't it use VueRouter out of the box? Without the VueRouter my Spark application is pretty old school with the need to use Laravel routes. Surely if you were going to use Vue then you'd most likely be building an SPA right?

Seems like it's not that easy to move Spark from Laravel routes to VueRouter. Does anybody have an example of how they changed a Spark installation from using Laravel routes to using the VueRouter?

Thanks, Nick

Apr
24
1 year ago
Activity icon

Started a new conversation Does Laravel Dusk Have A Failure Event Handler?

Hi all, when a test fails in Laravel Dusk I want to send a Slack notification. I can't find any documentation about an event handler being available for failures. Has anybody here successfully done this and do you have an example?

Thanks

Apr
04
1 year ago
Activity icon

Started a new conversation PATCH Doesn't Seem To Work With Postman

Hi all, I'm just wondering why my patch route doesn't work.

Here is my routes/api.php file:

Route::group(['prefix' => 'v1', 'middleware' => 'auth:api'], function () {
    Route::post('/failure', '[email protected]');
    Route::patch('/failure', '[email protected]');
});

My controller:

public function update(Request $request, TestFailure $testFailure)
{
  $this->validate(request(), [
    'name' => 'required',
  ]);
  return 'Yeyyy';
}

My POST route works fine however when I use PATCH it returns this error:

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
No message

Here is an example of my Postman config I have set.

Image of Postman

Any idea why this is happening? I tried using _method = PATCH as an entry in my form-data however this also did not work.

Thanks

Apr
02
1 year ago
Activity icon

Replied to Using Vue.js Components Within Other Components With Spark

@rin4ik I've just tried this and I seem to get exactly the same result as before.

Activity icon

Replied to Using Vue.js Components Within Other Components With Spark

@rin4ik When I try removing all the code from the ExampleComponent.vue file I get exactly the same error.

Activity icon

Started a new conversation Using Vue.js Components Within Other Components With Spark

I'm having a bit of trouble understanding how I can use child components, here is an example of my app.js file:


require('spark-bootstrap');

require('./components/bootstrap');

Spark.forms.register = {
    company: ''
};

import ExampleComponent from './components/ExampleComponent.vue';
Vue.component('example-component', ExampleComponent);

Vue.component('home', {
    components: {
      ExampleComponent
    },

    props: ['user'],

    mounted() {
        //
    }
});

const app = new Vue({
    mixins: [require('spark')]
});

As you can see I am importing a component called ExampleComponent and then attaching it to my home component as a child. In my home.blade.php file the ExampleComponent works fine outside of the home component however when I put it inside like so:

<home :user="user" inline-template>
  <example-component></example-component>
    <div id="default-app__container" class="container-fluid">
        <!-- Application Dashboard -->
        <div class="row justify-content-center">
            @include('sections.sidebar')
            <div class="content__section">
                <div class="mx-5">
                  <h1>Welcome, @{{ user.name }}</h1>
                </div>
                <div class="card card-default mx-5">
                    <div class="card-header">{{__('Dashboard')}}</div>

                    <div class="card-body">
                        {{__('Your application\'s dashboard.')}}
                    </div>
                </div>
            </div>
        </div>
    </div>
</home>

I get this error in the console:

[Vue warn]: Error compiling template:

<div id="spark-app" class="logged-in" v-cloak="">
        <!-- Navigation -->
                    <!-- NavBar For Authenticated Users -->
<spark-navbar :user="user" :teams="teams" :current-team="currentTeam" :unread-announcements-count="unreadAnnouncementsCount" :unread-notifications-count="unreadNotificationsCount" inline-template="">

    <nav id="navbar" class="navbar navbar-light navbar-expand-md navbar-spark">
        <div class="container-fluid" v-if="user">
            <!-- Branding Image -->
            <a class="navbar-brand" href="/home">
    <img class="logo" src="http://autommerce.local/img/logo.png" alt="logo">
</a>

            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div id="navbarSupp…

Any idea how I can stop this from happening?

I also tried including the template into the blade file like so <example-component inline-template></example-component> however I get this error TypeError: ast is undefined[Learn More]. It seems inline-templates always return this error message, any idea how you can register them?

Mar
15
1 year ago
Activity icon

Started a new conversation Correct Way To Authenticate A POST Request To A Laravel Endpoint?

Hi guys, I will be posting to my Laravel application from a remote application.

I'm trying to create a POST endpoint that can only be send requests if an access token or some form of authentication is matched. I have noticed Laravel Passport but this seems very over-kill for my needs.

What would be the correct way to do this?

Mar
13
1 year ago
Activity icon

Started a new conversation How To Install Scripts On Homestead?

Hi guys, I've found these scripts as I am interested installing the MongoDB driver on Homestead: https://github.com/laravel/homestead/tree/master/scripts

What do I need to do to install these .sh scripts? Sorry I'm a total newbie to Homestead configuration.

Thanks

Mar
11
1 year ago
Activity icon

Replied to Getting Laravel And Homestead To Work With MongoDB

@topvillas So does this need to be installed within Homestead itself and not my local machine?

Activity icon

Replied to Getting Laravel And Homestead To Work With MongoDB

@topvillas Do you mean on homestead itself? I haven't installed anything apart from the composer package.

Activity icon

Started a new conversation Getting Laravel And Homestead To Work With MongoDB

Hi all, I'm getting a quite frustrated by how hard it seems to be to set up MongoDB with Laravel.

So far I have installed the MongoDB composer package to my project:

https://packagist.org/packages/mongodb/mongodb

I have also added my database credentials to my .env file.

Then I tried testing it out by adding this to my web.php route file:

use MongoDB\Client as Mongo;
Route::get('mongo', function(Request $request) {
    $collection = (new Mongo)->mydatabase->mycollection;
    return $collection->find()->toArray();
});

This didn't work as when I visited /mongo I got this error:

 Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class 'MongoDB\Driver\Manager' not found

I'm a little bit confused to how I get this to work, do I need to install it on to homestead and if so how do I do this?

Thanks

Mar
03
1 year ago
Activity icon

Replied to Subdomains On A Laravel App Can't Be Masked By Other Domain

I've got rid of the mask as that was obviously not the right way.

So I've tried changing it so that it uses an A record and CNAME to display the subdomain:

Image

Obviously the values shown here are fake but you get the gist. Unfortunately this just shows the root of my app.com domain and not the subdomain :(

Activity icon

Started a new conversation Subdomains On A Laravel App Can't Be Masked By Other Domain

Hi guys, I'm trying to create an application architecture similar to that of Shopify's.

I am running this application from Forge and I've set up the necessary configuration for wildcard DNS to work.

At the moment people can sign up to my Laravel Spark app and then a subdomain will be created dynamically for them at:

Route::group(['domain' => '{company}.app.com'], function () {
    Route::get('/', '[email protected]');
});

So if they register an account and set the company name as Company then they will have a subdomain created at company.app.com. This subdomain returns a view with data related to their account (It pretty much returns a custom website for my user).

I'd like to give users the ability to mirror their site at company.app.com to their own domain address. I have tried setting up a mask within GoDaddy on a spare domain I have to test this however it doesn't seem to work :( I get this error in the console:

Refused to display 'http://company.app.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

So I'm guessing this is definitely not the right way to do it.

After this happened I looked at how other companies managed this and it looks like they create an A record and CNAME that points to the root of their app. Shopify's guide explains that they add their IP as an A record and then the CNAME is set as the shops.myshopify.com domain.

So now I'm left wondering how I can point requests in the right direction when they land on my app. So for example if traffic hits random.com and it has an A record that is equal to my servers IP, plus a CNAME of app.com, then how do I handle the request and redirect it to the correct subdomain whilst keeping the user on their custom domain?

Thanks, Nick

Activity icon

Replied to Where Do I Place Validation & Storage Code When Adding Registration Fields?

Thanks! Found out that the file was within the providers directory: SparkServiceProvider.php

Mar
02
1 year ago
Activity icon

Started a new conversation Where Do I Place Validation & Storage Code When Adding Registration Fields?

I'm looking at this documentation: https://spark.laravel.com/docs/6.0/adding-registration-fields

I've managed to modify the view and added the extra JS needed however I'm having trouble with the 'Validation & Storage' section.

Where do I add the code that is being referenced? For example this example PHP block is given:

Spark::validateUsersWith(function () {
    return [
        'name' => 'required|max:255',
        'age' => 'required|integer|min:1',
        'email' => 'required|email|max:255|unique:users',
        'password' => 'required|confirmed|min:6',
        'vat_id' => 'max:50|vat_id',
        'terms' => 'required|accepted',
    ];
});

I'm just wondering where the correct places are for these bit's of PHP though?

Not sure if this makes much of a difference but I installed Spark via composer as the default installer wouldn't work.

Thanks, Nick

Feb
25
1 year ago
Activity icon

Started a new conversation Creating A Shopify Style Application With Laravel Spark

Hi guys, I'm planning on creating an application similar to Shopify... A user signs up, configures their site from the Spark dashboard. Then a front-end for the site is available at a subdomain on my application, example mysite.app.com.

At the moment I'm thinking of creating some API endpoints that will allow me to send the data to the front end sites for each user. For example app.com/api/username would be the root endpoint for all of the data this user has for the front-end site.

Then I was thinking of developing an isomorphic React website for the front-end sites. I'm wanting the front-end to be it's own repo so that the Laravel/Spark project doesn't get overcrowded and complicated when it comes to the assets etc... The React websites would work like so...

If a traffic hits mysite.app.com then the app.com/api/mysite API is referenced and populates the React website.

I'm wondering if this is possible though... I'm left with a few confusing problems. So usually if I set up dynamic subdomains on a Laravel app I would use something like this:

Route::group(['domain' => '{company_name}.app.com'], function () {
    // I'd set up all my routes in here
    Route::get('/', '[email protected]');
});

Because I'm thinking of developing the front-end as a stand alone React website that handles it's own routes I'm confused to how this could work... I have a feeling if I set up a React route like this: mysite.app.com/contact-us. I have a feeling I'd get a 404 because Laravel is handling the routes.

As I said I'm just trying to create an application with a similar architecture to Shopify. Can somebody explain what they think would be the best way to do this? I have heard of people using a Wildcard DNS however I'd just like some opinions from people who are a little bit wiser than me. If you think that the stand alone React app architecture is a bad idea please let me hear it!

Many thanks, Nick

Feb
24
1 year ago
Activity icon

Replied to Duplication Vs Relationships With Large Amounts Of MySQL Data.

Thanks for all the comments guys, really helped me understand what the architecture should look like.

Feb
23
1 year ago
Activity icon

Started a new conversation Duplication Vs Relationships With Large Amounts Of MySQL Data.

Hi guys, pretty new to modelling MySQL data.

So here is the scenario...

I have a table called houses in this table it has the following columns:

type, door_number, bedroom_number, year_built, value

I'm aware some of this data will be completely unique such as the value field. Some of this data won't be unique, for example... the type will only have a few values such as:

Detached Semi-detached etc...

Would I be correct in saying the type field would be better off as it's own table with a relationship to the houses table? Or would the performance of the database be the same if I duplicated values instead of creating relationships?

I also have a bonus question... if I ran a query on this table that brought back all of the houses records that belongs to a user_id, would this become slower as the records increase into the 10,000's? Or does the amount of records not matter so much?

Thanks, as you can tell I'm a bit of a noob to server side!