JackRobertson

JackRobertson

Member Since 3 Years Ago

Experience Points 20,280
Experience Level 5

4,720 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 182
Lessons
Completed
Best Reply Awards 2
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.

30 Jun
1 month ago

JackRobertson left a reply on New Laravel Media Package

Hi @jaytee

Thanks for your feedback.

We use this package at my place of work for all of our CMS applications. The reason we decided against Spatie's package and went with a "many to many" approach is because it felt awkward to manage media independently from other models in our system. In a traditional media manager you'd expect media to be uploaded first, and attached / manipulated later - and this package solves that problem. Maybe this should be better reflected in the docs?

Spatie may use image intervention, but they don't expose it's api to be used directly. They require their own manipulation library, which depends on glide, which ultimately depends on image intervention as well as a bunch of other packages.

I like the idea to create a client side library, we already have a "media manager" GUI built in Vue that we could open source if anyone would be interested in that.

29 Jun
1 month ago
28 Jun
1 month ago

JackRobertson left a reply on New Laravel Media Package

@TY - Thank you, I'm trying to get people to pull it down and test it out to try and find any hidden bugs before I publish version 1 :)

JackRobertson started a new conversation New Laravel Media Package

Hi everyone,

Not sure if this is the right place to put this, but I'm coming really close to releasing V1 of a new laravel media package I've been working on...

It's a combination of spatie's media library and plank's mediable package.

It allows you to attach media to your eloquent models in a "many to many" fashion, it also lets you manipulate images before media is attached (using image intervention) which makes it the perfect engine for a front end media manager.

I'd really appreciate some feedback (maybe even a star if you like what you see!). The package can be found here: https://github.com/optixsolutions/laravel-media

Many thanks, Jack

20 Jul
2 years ago

JackRobertson left a reply on Guzzle Http Post Request Not Working.

replace csrf_field() with csrf_token() :)

JackRobertson left a reply on Guzzle Http Post Request Not Working.

Make sure you're sending the csrf token with your request.

25 Jun
2 years ago

JackRobertson left a reply on Change The Authentication Router

You need to change the logic of the unauthenticated method in the App\Exceptions\Handler class.

If the user tries to go to a route they do not have access to, an AuthenticationException is thrown and it will hit the endpoint above.

It should be changed to match the method below:

protected function unauthenticated($request, AuthenticationException $exception)
{
    if ($request->expectsJson()) {
        return response()->json(['error' => 'Unauthenticated.'], 401);
    }

    return redirect()->guest('admin/access');
}

However, it's probably best if you remove the auth routes from your routes and enter them manually - because if someone goes to /login, the login form will still be shown.

JackRobertson left a reply on Change The Authentication Router

I'm pretty sure all you have to do is override the route named login.

So in your web routes before the Auth::routes() method call, write the following:

Route::get('access', 'Auth\[email protected]')->name('login');

JackRobertson left a reply on Depending On Date, Add A Class To A Blade View From A Partial

If the dates are always grouped together, you might want to consider querying a date range vs a list of dates.

For example:

if (current date is between start date and end date) {
    append success class
} elseif (date is before start date) {
    append warning class
}
21 Jun
2 years ago

JackRobertson left a reply on Artisan Make:model Specify The Directory And Namespace?

Another option would be to override laravel's ModelMakeCommand if you're lazy like me and don't want to type your app's default namespace every time you make a model.

Just make a command new command like so:

<?php

namespace App\Console\Commands;

use Illuminate\Foundation\Console\ModelMakeCommand as Command;

class ModelMakeCommand extends Command
{
    protected function getDefaultNamespace($rootNamespace)
    {
        return "{$rootNamespace}\Entities";
    }
}

Then register it in the Kernel:

protected $commands = [
    Commands\ModelMakeCommand::class
];

Now when you run the make:model command it will default into the app/Entities directory.

31 Jan
2 years ago

JackRobertson left a reply on Vue.js Href

You need to tell blade not to parse the data in your curly braces. You can do this by prefixing them with an @. For example:

<tr v-for="user in users">
    <td><a href="/profile/@{{ user.slug }}">@{{ user.name }}</a></td>
</tr>
30 Jan
2 years ago

JackRobertson left a reply on Using Foreign Keys In Blade

I'm sorry, your create method should be as follows:

public function create()
{
    $domaines = Domaine::pluck('name', 'id');
    return view('projects.create', compact('domaines'));
}

JackRobertson left a reply on Using Foreign Keys In Blade

Change your create method in your projects controller to...

public function create()
{
    $domaines = Domaine::pluck('name', 'id');
    return view('projects.create', compact('domaines'));
}

Change the output in the create view to...

    <select class="form-control" name="domaine_id">
        @foreach($domaines as $domaine)
          <option value="{{$domaine->id}}">{{$domaine->name}}</option>
        @endforeach
    </select>

Relationships help you access the data that is connected to your model. For example, calling $project->domaine would return the record in the domaines table that is connected to your selected project.

JackRobertson left a reply on Using Foreign Keys In Blade

In order to access "related" data from another table in eloquent you need to define a relationship.

https://laravel.com/docs/5.4/eloquent-relationships#one-to-many

In your case, a project would "belong to" a domaine, and a domaine can "have many" projects.

To access this related data all you need to do is call $project->domaine->exampleProperty

JackRobertson left a reply on Login/register Pages Not Loading Properly

You need to bcrypt the auth attempt password input.

Change this 'password' => $request['password'] to 'password' => bcrypt($request['password'])

I think that should do it.

JackRobertson left a reply on Login/register Pages Not Loading Properly

It seems like the user is not getting authenticated and the auth middleware is preventing you from viewing this page.

Instead of accessing your request properties via array key ($request['foo']), either access it by $request->input('foo') - or simply $request->foo.

JackRobertson left a reply on Login/register Pages Not Loading Properly

You'll need to make a new route then, for example...

Route::get('addmoney', function(){
    return view('wallet.addmoney');
});

JackRobertson left a reply on Login/register Pages Not Loading Properly

You are redirecting to a route that doesn't exist, the addmoney route that you have defined catches a post request. If you want to return back to the page where you submit the form, you should return redirect()->back().

29 Jan
2 years ago

JackRobertson started a new conversation How To Have Relationships From A Polymorphic Pivot Table

I have a "regionables" table which is a standard polymorphic pivot table.

I need to be able to call a different relationship from this table depending on the type.

For example, if the record is of App\Module type - I need to be able to get the related records from my "module_contents" table, whereas if the record is of App\Component type, I need to get the related records from my "component_contents" table.

Thanks.

26 Jan
2 years ago

JackRobertson started a new conversation Get Different Types Of Content From Single Pivot Table

I have a Page, Component and a Module model, as well as a PageContent model which acts as a pivot table.

I need to find a way to get all of the modules and components that belong to a page in one relationship.

I have read a little bit about polymorphic relationships but I am a little bit confused about how I would implement a polymorphic relation in this circumstance.

Any help is appreciated! :)

30 Oct
2 years ago

JackRobertson left a reply on ForEach With Every 10th And 2nd Changes

@kickthemooon The foreach loop iterates over all of the chunked items - so if a 50 item collection was chunked into groups of 10, the foreach would be repeat 5 times. Hope this helps :)

JackRobertson left a reply on ForEach With Every 10th And 2nd Changes

    <div class="coupons">
        @foreach($coupons->chunk(10) as $chunk)
            <div class="page">
                <div class="subpage">
                    <table>
                        @foreach($chunk->chunk(2) as $pair)
                            <tr>
                                @foreach($pair as $coupon)
                                    <td>
                                        <span class="coupon">{{ $coupon->code }}</span><br>
                                        <hr>
                                        <span class="name">{{ $coupon->user->name }}</span>
                                    </td>
                                @endforeach
                            </tr>
                        @endforeach
                    </table>
                </div>
            </div>
        @endforeach
    </div>

Untested code, but it should do the trick.

JackRobertson started a new conversation Best Way To Conditionally Wrap Yielded Content?

I'm using blade with the bulma css framework and I'm trying to figure out the best way to wrap the nav in a hero on some pages. I have considered 3 solutions:

#1 - @hasSection directive at the top and bottom of the nav in the default layout:

    @hasSection('hero')
        <section class="hero @yield('hero')">
            <div class="hero-head">
    @endif
    
    @include('shared._nav')

    @hasSection('hero')
            </div>
            <div class="hero-body">
                @yield('hero-body')
            </div>
        </section>
    @endif

My biggest gripe with this solution is the messy markup.

#2 - A single @hasSection directive with an @else

    @hasSection('hero')
        <section class="hero @yield('hero')">
            <div class="hero-head">
                @include('shared._nav')
            </div>
            <div class="hero-body">
                @yield('hero-body')
            </div>
        </section>
    @else
        @include('shared._nav')
    @endif

I'm not a big fan of reusing code in else statements.

#3 - Create a new layout file for the nav wrapped in a hero

I'm not sure on the consensus for creating a new layout containing a fair amount of reused markup, especially as it's likely that I will only be using the hero wrapped nav on a few pages.

In your opinion, or if you have any other solutions - how would you go about doing this? Thanks in advance.

29 Oct
2 years ago

JackRobertson left a reply on How To Define A Blade Closing Directive In Php Storm?

@ejdelmonico yes that plugin is also installed. All the other blade directives work as expected, I only have an issue with "@hasSection". I have added it to the directives list and it's now being recognised by the editor, however it still does not recognise "@endif" as its closing counterpart.

Added @hasSection to directive list

settings

@endif not being recognised as closing directive

editor

JackRobertson left a reply on How To Define A Blade Closing Directive In Php Storm?

@tomi yes it's installed, but for some reason the "@hasSection" directive is not supported.

JackRobertson started a new conversation How To Define A Blade Closing Directive In Php Storm?

I'm using the @hasSection directive in my layout file, however php storm does not recognise it. I've added it to list of existing directives which is working fine, but it still doesnt recognise @endif as it's closing directive... How can I define @endif to be @hasSection's closing directive within php storm?

16 Sep
2 years ago

JackRobertson started a new conversation How To Seed A Many To Many Relationship?

I currently have a many to many relationship between countries and regions due to the fact that some countries fall under multiple regions (e.g Cyprus falls under both Europe and the Middle East). I was wondering what the best method to seed this relationship would be... Should I create a new CountryRegionTableSeeder or should I seed it from the region/country table seeder that already exists? Thanks in advance.

07 Sep
2 years ago

JackRobertson started a new conversation Closed

Question closed

11 Jul
3 years ago

JackRobertson started a new conversation How Can I Update The Front End Of My Application In Real Time When An Asynchronous Event Is Completed?

Hi there,

I have an application that makes use of an external API to get the user's Overwatch avatar when they login via Battle.net OAuth. The process is setup into an event that is triggered upon login, and runs asynchronously using queues and the Redis queue driver. My question is, how can I update the avatar on my applications views in real time so the user doesn't have to refresh or go to another page in order for them to see the changes? I assume this has something to do with event broadcasting?

Thanks in advance!