mr.teapot

mr.teapot

Member Since 3 Years Ago

Experience Points 15,040
Experience Level 4

4,960 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 145
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.

28 Jul
2 years ago

mr.teapot left a reply on Gettype() On My Request Input Returns String When It Is An Array

$this->data['tags'] = json_decode($this->data['tags']);

It works when I do that, I thought Laravel did that under the hood.

mr.teapot started a new conversation Gettype() On My Request Input Returns String When It Is An Array

Hey!

I am making a request with postman with the key tags and the value ["ypvNLEKDAkRornVD", "ypvNLEKDAkRornVD"]

When I use gettype(request->input('tags') is says that it is a string, the validation also fails and says that it must be an array.

Why is it not an array and how can I make it one before I validate?

Kind regards, Teapot

27 Jul
2 years ago

mr.teapot left a reply on FindOrFail Not Throwing 404 Exception

Thanks for the response. I just realized that I am using the Hashids package to create uids that are unpredictable, and when I decode a uid that doesn't exist, it returns an empty array, which I try to use in the findOrFail instead of an integer id. I guess that is why there is unexpected behavior.

mr.teapot started a new conversation FindOrFail Not Throwing 404 Exception

Hey!

I have this code in my project, and when it fails to find an industry, it just continues and then I get an error when I try to access a property of a non-object.

$industry = Industry::findOrFail($id)->first();

Should this not throw a ModelNotFound exception with 404 response code, and prevent the rest of the code from executing?

Kind regards, Teapot

10 Jul
2 years ago

mr.teapot left a reply on Laravel Does Not Update Image.

Maybe it is your php settings restricting the file size of uploads, try increasing it in your php.ini.

mr.teapot started a new conversation Rest Api Asset Authentication

Hey!

I am looking into how to require authentication for viewing images and videos through a rest api.

Lets say I have a Laravel rest api with JWT authentication, and a vue-js app consuming it. I only want get-requests with a valid token to be able to fetch the images and videos.

Are there any best practices for doing this? Do I send the token as a query string in the img src and then handle the response as a file response in a controller if the token is valid?

Can you help me find tutorials on what to do?

Thanks in advance

/Teapot

08 Jul
2 years ago

mr.teapot left a reply on Dropzone And Laravel - Some JPGs Fail To Upload

The upload_max_filesize in the php.ini was indeed causing these issues. Weird that the mime-type was changed when I echoed back the request.

I hope someone will search and find this thread if they have the same problem =)

mr.teapot left a reply on Dropzone And Laravel - Some JPGs Fail To Upload

I removed the "required" validation from the controller, now I get a FileNotFoundException when I upload the failing images. This happens with postman as well so I can rule out and any problems with dropzone.

All the failing files have a size > 2MB. A file with size 2MB is successfully uploaded.

mr.teapot left a reply on Dropzone And Laravel - Some JPGs Fail To Upload

Hi!

One of the failing images have .JPG, but two other failing images have .jpg so I don't think that is the problem.

The only thing the failing images have in common is that the 'mimeType' => 'application/octet-stream' in the post request.

mr.teapot started a new conversation Dropzone And Laravel - Some JPGs Fail To Upload

Hey!

I've got a local installation of Laravel and I am using dropzone to upload images to the application.

However, some of the JPGs fail to upload.

The requests for the images that works has a mime-type of 'mimeType' => 'image/jpeg', while those that fail have 'mimeType' => 'application/octet-stream'. Yet they are all jpgs. I get a 422 response for the failed uploads.

All images from unsplash.com fail.

Does anyone have any idea why this is happening?

Thanks in advance,

/Teapot

29 Nov
2 years ago

mr.teapot left a reply on Laravel On AWS Elastic Beanstalk

Yeah! Just make sure that you zip all the files in the directory that has your application by selecting them all, and not the entire directory. This way, you will have composer.json in the root directory and it will run upon deployment. I.e, that your zip-file has /composer.json and not /projectname/composer.json.

I also had this file in .ebextensions for migrations:

container_commands: 01-migration: command: "php /var/app/ondeck/artisan --env=staging migrate:refresh" leader_only: true 02seed: command: "php artisan db:seed --force"

01 Nov
2 years ago

mr.teapot left a reply on Vue-router Appends #/ In The Address Bar

Thanks!

It works now :D

mr.teapot started a new conversation Vue-router Appends #/ In The Address Bar

Hi!

I'm trying to learn how to create single page applications using Vue. I just got my first two pages to work, however, vue is appending #/ in the adress bar and I am completely confused why it does that. For Example, visiting contact makes it look like this: http://localhost:3000/#/contact and visiting the start page looks like http://localhost:3000/#/

Do you have any idea why this is happening?

import VueRouter from 'vue-router';
import VueResource from 'vue-resource';

var home = Vue.component('home', require('./components/home.vue'));
var contact = Vue.component('contact', require('./components/contact.vue'));

Vue.use(VueResource);
Vue.use(VueRouter);

const router = new VueRouter({
    routes: [
      { path: '/', component: home },
      { path: '/contact', component: contact }
    ]
})

// 4. Create and mount the root instance.
// Make sure to inject the router with the router option to make the
// whole app router-aware.
const app = new Vue({
  router
}).$mount('#app')
27 Sep
2 years ago

mr.teapot started a new conversation Laravel On AWS Elastic Beanstalk

Hello!

I'm trying to deploy a Laravel application on AWS using Elastic Beanstalk CLI. I have created an application and an environment, and created an RDS instance. I have added some .ebextension scripts to run migrations and seed the database.

All works fine when I zip the entire application directory and upload the zip-file, however, when I write "eb deploy", it doesn't work. The deployment works and has green health, but I get two "Whoops, it didn't work"-errors when I try to access the site.

I think composer isn't running on beanstalk as it should, it should run automatically, right? I've made sure that /vendor is in the gitignore and that composer.json isn't in gitignore.

How can I run composer as a script on deployment? Maybe that could fix it. Any other ideas about this?

Thanks in advance,

Kind regards, Teapot

30 Aug
2 years ago

mr.teapot started a new conversation Easiest Way To Only Patch With Submitted Inputs

Hi!

When I create forms to patch an existing record/model in the database I find myself doing this in the update-method of the resource controllers:

<?php
 if (isset($request['name']) && !empty($request['name'])) {
    $this->customer->name = $request['name'];
?>

I do this for every field I want to update and eventually type:

<?php
$this->customer->update();
?>

Using this quick method overwrites existing fields with empty values:

<?php
$this->customer->update($request->all());
?>

What is the easiest way to only add the newly submitted information to the record without having to do my if-statement for every input?

Thanks in advance,

Kind regards Teapot

26 Aug
2 years ago

mr.teapot left a reply on Laravel 5.3 Multi Auth - How Can I Make It Work?

Thanks for all the answers!

I think I managed to get it to work by overriding the AuthenticatesUsers trait in the auth controllers, so I can show specific views for my other authenticable model. And updating the auth.php config file ofc.

Modifying the trait itself is a problem when you update and such. But what is wrong with just overriding it with my own methods? What do you say about the @Hesto? Any future headaches?

I think multi auth is a very important feature, all of my projects require it. I believe there should be an artisan make-command for it. Maybe you should be able to type "php artisan make:model Customer --auth" and get authentication for that model out of the box? What do you think?

25 Aug
2 years ago

mr.teapot started a new conversation Laravel 5.3 Multi Auth - How Can I Make It Work?

Hello!

I'm new to Laravel and I would like to find out how to how make multiple authenticable user models. I've searched a lot and haven't found anything that works well. I'm using 5.3 now and there always seems to be a different directory structure from what I have in every tutorial I find. (2 files instead of 4 in the AuthController-folder for example). This makes it messy for me.

I would like to have an employee and customer model, and each can login from a different view (employee/login and customer/login). Another question I have is how to use the Auth-facade with multi auth. What will Auth::user() return depending on which type is signed in?

I don't think it makes sense to have one user model and then employee/customer roles since they will store completely different information on the object and have other relations.

Do you know any good tutorials for this and how to implement this in laravel 5.3? What are the best practices?

Thanks in advance. All answers are very appreciated.

Kind regards, Teapot