matt_panton

matt_panton

Member Since 4 Years Ago

Experience Points 49,705
Experience Level 10

295 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 472
Lessons
Completed
Best Reply Awards 13
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.

05 Dec
9 months ago

matt_panton left a reply on How To Create A Blank Object For Return JSON Response?

return response()->json(new \StdClass);
24 Nov
9 months ago

matt_panton left a reply on File Uploads With Axios - Having Trouble

I assume you've done a console.log(this.file) just before making the axios request to check it's not null for some reason?

The only other thing I can think of is that whenever I've used axios to upload files, I've never had to set the Content-Type header so maybe remove that and give it a go

matt_panton left a reply on File Uploads With Axios - Having Trouble

Have you checked your upload_max_filesize and post_max_size in yourphp.ini file?

Perhaps try uploading a small file and see if request()->file('video') is still null?

09 Oct
11 months ago

matt_panton left a reply on I Got Csrf Error With Http-tests

The field for the CSRF token should be _token not csrf_token

27 Sep
11 months ago

matt_panton left a reply on Can't Pass Array To Vue.

Because associative arrays in php convert to javascript objects when JSON encoded. Only non associative php arrays will convert to javascript arrays when JSON encoded.

29 Aug
1 year ago

matt_panton left a reply on Search Column With Json Gives Access Violation (mariadb-10.2.16)

If you are using mysql version >= 5.7, you could use the JSON_EXTRACTfunction to read the properties column as json and search through it that way.

This might help: https://stackoverflow.com/questions/30411210/how-to-search-json-data-in-mysql

28 Aug
1 year ago

matt_panton left a reply on How To Download Apk File On Laravel?

Does response()->download() not work?

matt_panton left a reply on Laravel User Registration After Unsuccessful Authorization

You could use the Illuminate\Foundation\Auth\RegistersUsers trait in your controller and call the register method, passing through the request.

You'll probably need to update the validator for the RegistersUsers trait because it'll expect a password confirmation field.

17 Aug
1 year ago
14 Aug
1 year ago

matt_panton left a reply on Injected Model In Middleware

You should take a look at using laravel's authorization to handle this kind of check. https://laravel.com/docs/5.6/authorization

09 Aug
1 year ago

matt_panton left a reply on Pivot Table Attach() Without Auto Sort

Would it work if you add timestamps to your pivot table and then use the withTimestamps() function when defining the belongsToMany relationship?

03 Aug
1 year ago

matt_panton left a reply on Redirecting To /home After Registration With No Response !

Have you checked the laravel.log file?

23 Jul
1 year ago

matt_panton left a reply on Why Use With()/load()

If you have a HasMany relation for example and you loop trough the relations in a view it will run a new query each time which can become slow. By eager loading the relations, you only run 2 sql queries regardless of how many models are related through the HasMany relationship.

26 Jun
1 year ago

matt_panton left a reply on Carbon Create Date Range June 1st - May 31st

There's no need to make Carbon object, you can just do a simple whereBetween query.

Take a look at the example given here: https://stackoverflow.com/questions/33361628/laravel-eloquent-date-range-query-between-two-dates

22 Jun
1 year ago

matt_panton left a reply on Array_merge In Laravel Not Working

Try looking at your phpinfo(). There might be a file size or post size restriction.

27 Mar
1 year ago

matt_panton left a reply on Filling Forms With Vue After User Input

Take a look at this video, it should get you started with AJAX in Vue. https://laracasts.com/series/learn-vue-2-step-by-step/episodes/18

16 Mar
1 year ago

matt_panton left a reply on Auto Popup Modal When Session Expires In Laravel Without Clicking In The Web?

Could you just have a javascript timeout method that starts on pageload?

18 Dec
1 year ago

matt_panton left a reply on Custom Rule Validation

Try passing all the validation methods as separate array items instead of separated by a pipe.

 'email' => ['required', 'email', 'max:255', 'unique:users', new EmailRule()]
13 Dec
1 year ago

matt_panton left a reply on Middleware Group Always Going To The Last Group And Ignoring The First Two

what @challet said. The Route is first matched and then middleware is run. If you want to display different content depending on which type of user is signed in, you'll have to do that logic at the controller level.

matt_panton left a reply on Middleware Group Always Going To The Last Group And Ignoring The First Two

Correct me if I'm wrong but all three of the 'home' pages have the exact same uri of app/home?

How is the route resolver supposed to know which method to trigger if all of the urls are the same?

07 Dec
1 year ago

matt_panton left a reply on Laravel 5.5 - Unintended Implicit Route Binding

In your routes/web.php file, try putting the admin/pages/create route above any other admin/pages/* routes.

matt_panton started a new conversation Best Way To Test Creating Charges With Stripe?

I'm working on a project that requires me to take payments using Stripe. I'm writing some feature tests to check that card declines are handled correctly and I'm currently using the JacobBennet/StripeTestToken to generate fake tokens. The problem is that it's slow to generate these tokens, especially when there's around 10 being generated in my test suite.

What's the best way to approach writing these tests?

Thanks.

29 Nov
1 year ago

matt_panton left a reply on How Can I Update Root Data From Compunent.

If you have an event bus you could emit an event and listen for it on your root.

// app.js
window.event = new Vue();
// Component.vue
    getData() {
        // Get data here
        window.event.$emit('got-data', data);
    }
// Root
    mounted() {
        // Listen for event
        window.event.$on('got-data', data => {
            this.someData = data
        });
    }

matt_panton left a reply on How To Use A Template With A Script Tag Like <script Type="text/template" Id="xxx">

Try just passing a plain javascript object to the Vue.component() method.

Vue.component('test-component', {
    template: '#myid'
});
28 Nov
1 year ago

matt_panton left a reply on How To Use A Template With A Script Tag Like <script Type="text/template" Id="xxx">

Vue only knows about stuff that's inside your #app div. Try moving the template in there.

24 Nov
1 year ago

matt_panton left a reply on How To Pass A Vuejs Varaible To A Url Tag In Laravel

You'll have you use javascript rather than blade interpolation.

Something like this (will probably need changing depending what data is on your vue component):

<a :href="`/invoice/{$invoice.id}/history`" />

matt_panton left a reply on Run Production Mode Hosting

when compiling your assets, run npm run production and it will use the production version of Vue

23 Nov
1 year ago

matt_panton left a reply on Submit Form Within Bootstrap Modal - TokenMismatchException Error

I just tried this code and it works for me:

<form action="" method="post" id="form">
    {{ csrf_field() }}
    <input type="text" name="name">
    <button type="button" onclick="handleSubmit()">Submit</button>
</form>


<script>
function handleSubmit () {
    document.getElementById('form').submit();
}
</script>

matt_panton left a reply on Submit Form Within Bootstrap Modal - TokenMismatchException Error

Okay bit of a long shot but because you're not preventing the default behaviour of the form submission in javascript, it could be that the form is submitting once when you click the button and then straight away after through javascript? perhaps try putting type="button" on the button element or

function form_submit(e) {
    e.preventDefault();
    document.getElementById("my_form").submit();
 }

matt_panton left a reply on Require Confirmation From Admin/owner Before Account Is Given Access

In your App\Http\Controllers\Auth\RegisterController you will want to overwrite the register method that is inherited from the RegistersUsers trait.

You can see that in the register method, the line $this->guard()->login($user); is what logs the user in after registration.

matt_panton left a reply on Submit Form Within Bootstrap Modal - TokenMismatchException Error

The form you're selecting in your javascript is facebook_form but the one in your html has the id of my_form?

07 Nov
1 year ago

matt_panton left a reply on Ordering Many-to-many Relations

You could add an order column to the pivot table. When defining the relationship on Song.php and Playlist.php models, make sure tell eloquent about the additional column in the pivot table:

// Playlist.php
public function songs() {
    return $this->belongsToMany('App\Song')->withPivot('order');
}

The easiest way to then retrieve the order would be to use a collection method

$songs = $playlist->songs->orderBy(function($song) {
    return $song->pivot->order;
});

I haven't tried any of that code so it might not work but that's the general idea of how I'd approach it.

02 Nov
1 year ago

matt_panton left a reply on This Page Size Is 64kb But There Are Two JS Files Which Their Total Size Is Much Larger Than 1 Mb

It might be that the network only transferred 64kb of files because you already had the large js files cached in your browser.

matt_panton left a reply on RefreshDatabase Trait Doesn't Refresh Database

Have you updated you phpunit.xml file to use a different database for testing. E.g an sqlite database?

31 Oct
1 year ago

matt_panton left a reply on Change Language Of Carbon

try setting the locale of Carbon Carbon::setLocale('de');

matt_panton left a reply on Model 'Fillable Fields' Can They Be Named Something Other Than Whats In The Database.

I think it should work because you're only changing the key of the array from a number to string but the value of each item in the array is still the name of column in the database.

matt_panton left a reply on Advice Requested

Could you use a view composer to pass the variables into the layout view?

27 Oct
1 year ago

matt_panton left a reply on Eloquent Model::__construct Error

Which episode number are you currently working on?

25 Oct
1 year ago

matt_panton left a reply on Issue On Separation Of Project Modules

Wouldn't the Admin section be protected by authorisation?

matt_panton left a reply on Return Only Json From Web Routes

try checking whether it's an ajax request first:

public function index(Request $request) {
    $items = Item::orderby('name')->all();

    if($request->ajax()) {
        return items;
    }

    return view('items.index', compact('items'));
}

matt_panton left a reply on Fixing Edit Tag [Property [name] Does Not Exist On This Collection Instance]

Because the $post->tags relation will return a collection. You'll need to loop over them and output the tags individually. E.g:

@foreach($post->tags as $tag)
    <label>
        {{ $tag->name }}
        <input type="checkbox" value="{{ $tag->id }}" name="tags[]">
    </label>
@endforeach

matt_panton left a reply on Validation Must Not Contain String?

You could create a custom validation rule. In your AppServiceProvider.php inside the boot() method.

\Validator::extend('notExtension', function ($attribute, $value, $parameters, $validator) {
    $segments = explode('.', $value);
    $ext = end($segments);

    return !in_array($ext, $parameters);
});

And then use it in a validator like:

    [
        'filename'  => 'required|notExtension:mp3,aac'
    ]

I haven't tried this code myself but it should work in theory...

matt_panton left a reply on Join 2 Array

@hecate0211 You don't actually call the array_merge function, you pass it as the first parameter to the array_map function.

matt_panton left a reply on Join 2 Array

Assuming you have the two arrays in variables $arr1 and $arr2 you could combine them using

$arr3 = array_map('array_merge', $arr1, $arr2);
19 Oct
1 year ago

matt_panton left a reply on Make Get Request With Vuejs On Only Certain Url

You could pass a fetchesProducts prop to the component, then use that to determine whether or not to make the api request.

matt_panton left a reply on Invalid Argument Supplied For Foreach() In (line 36)

What happens if you dd($user->posts) in the controller?

matt_panton left a reply on Save N:1 With Many Data

Something like this might work although isn't ideal.

foreach($request->text as $i => $text) {
    $assistant = new Assistant();
    $assistant->user_id = $request->id;
    $assistant->text = $text;
    $assistant->favorite = $request->favorite[$i];
    
    $assistant->save();
}

matt_panton left a reply on Input Required Dinamically

Have you checked in Vue Dev Toos that the formItem.required property is a boolean value instead of the string "true" or "false"?

29 Sep
1 year ago

matt_panton started a new conversation Err_SSL_Protocol_Error Server Or Client Issue?

Hi all,

I'm having an issue with a website that I built where when it is loaded over someones's virginmedia wifi connection, an SSL error is shown no matter what browser is used. However when viewed on their same device but over a 3g network the site it show fine. The website is encrypted using letsencrypt and hosted on a digitalocean droplet. I don't know too much about encryption so I'm struggling to work out whether this is an issue with the SSL config or the person's internet provider.

link to the website in question

screenshot of error page

Any insight into this issue is greatly appreciated.

Matt :)