mathishuettl

mathishuettl

Member Since 2 Years Ago

Experience Points 3,430
Experience Level 1

1,570 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 2
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.

25 Apr
1 year ago

mathishuettl started a new conversation Strange BelongsToMany Problem

Hello,

I have users that has roles, so I created a Migration for role_user pivot - this works fine.

Schema::create('role_user', function (Blueprint $table) {
    $table->increments('id');
    $table->integer("role_id")->unsigned();
    $table->integer("user_id")->unsigned();
    $table->timestamps();
});

// user model
public function roles() {
    return $this->belongsToMany(Role::class);
}

But i also have categories that could only be accessed from allowed users so i also created a role_category Migration and set the relation in the category model:

Schema::create('role_category', function (Blueprint $table) {
    $table->increments('id');
    $table->integer("role_id")->unsigned();
    $table->integer("category_id")->unsgined();
    $table->timestamps();
});

// category model
public function roles() {
    return $this->belongsToMany(Role::class);
}

This works perfect:

$user->roles()->attach($role);

But this don't

$category->roles()->attach($role);

I get the error Base table or view not found: 1146 Table 'downloads.category_role'

Why is the name here turned around? in the users the users was automaticly role_user why is eloquent trying to find the table category_role not role_category?

I know i can easy set the second parameter of belongsToMany to the Table name but i just wonder why the names have not the same schema

20 Apr
1 year ago

mathishuettl started a new conversation Category Tree

Hello,

I have a simple Category-Table with (ID, Title, parent) if it's a root category the parent is 0. Now I want to build a category tree with a dash (-) for each level like this:

Products -Old Products --Cheap Products ---... ----.... --Expensive Products -New Products

How can i realize this?

13 Mar
1 year ago

mathishuettl started a new conversation Rest API Is To Slow - What You Say About My Idea?

Hello Guys,

I have a big site that contains multiple posts and comments from multiple different sites. Every single site publishs the posts and comments (insert, update, delete) to the portal page via a rest api.

But the process needs to long time (insert about 10 sec, because images gets downloaded and uploaded to the portal page, ..) so i decide to make a "middleman" that only stores the requests so the single site gets an instant feedback.

The delay from a publish on the single site and the publish on the portal site should be max. 30 seconds - is this realizeable?

What do you think about my idea?

The big problem I have at the moment is when the admin of a single site release a comment it needs about 6 seconds. (really big database on the portal page and some queries) so the admin has to wait 6 seconds to realease a single comment and then release the next and this is really annoying.

07 Mar
1 year ago

mathishuettl started a new conversation Check In Database If Ster_date Overlaps

Hello,

In my Schema i have two dates (start_date, end_date) now when i create a new record I want to check if the new record overlaps with an existing.

Example:

Database:

ID | start_date | end_date
1      2018-01-01   2018-01-31

I want to add this record but it overlaps with a existing one start_date: 2018-01-15 end_date: 2018-06-06

mathishuettl left a reply on Add A Class When Array Validation Failed

@wilk_randall

Doesn't work:

Notice: Undefined property: stdClass::$room 
06 Mar
1 year ago

mathishuettl started a new conversation Add A Class When Array Validation Failed

Hello,

I send a php array over an api endpoint from a wordpress site to laravel and if the validation fails I send the validation errors back with json.

Everything works fine, but I want to add a css-class to the field thats validation failed. With "normal" (non array-fields) it works easy with

echo (isset($errors->firstname) ? 'has-error' : null); 

But when I try this with an array field I get a error

echo (isset($errors->room.1.personcount) ? 'has-error' : null); 

Parse error: syntax error, unexpected '.0' (T_DNUMBER), expecting ',' or ')'
05 Mar
1 year ago

mathishuettl started a new conversation What's The Benefit Of A Pivot?

Hello,

it's probably a stupid question, but I want to know what's the difference between these two schemas and what are the pro and contras. Can you solve this?

https://imgur.com/Pgq6Tk0

28 Feb
1 year ago

mathishuettl started a new conversation V-For Pass Object

Hello,

I'm new with Vue. I have an array of products and want to create my custom "" element foreach product in my array, but how can i use attributes out of the product-object in the array? (e.g. product.title)

<template>
    <div class="products">
        <Product v-for="product in products" :key="product" v-bind:title="product.title"></Product>
    </div>
</template>

<template>
    <div class="product">
        <div class="product-header">
            <h3>{{ title }}</h3>
        </div>

        <div class="product-image"></div>

        <div class="product-description">

        </div>

        <div class="product-footer">
            <a href="#">Add to Cart</a>
        </div>
    </div>
</template>

22 Feb
1 year ago

mathishuettl left a reply on Auth Problem With Passport

fuc* i forgot to save :D thanks!!!

mathishuettl left a reply on Auth Problem With Passport

yes i've done both!

mathishuettl started a new conversation Auth Problem With Passport

Hello,

I want to login into my api, so I installed passport and followed the instructions on the documentation (https://laravel.com/docs/master/passport).

I created a second user-type called "customers"

  1. Created a migration for customers
Schema::create('customers', function (Blueprint $table) {
            $table->increments('id');
            $table->string('email')->unique();
            $table->string('password');
            $table->enum("gender", ["male", "female"]);
            $table->string("firstname");
            $table->string("lastname");
            $table->string("mobile");
            $table->rememberToken();
            $table->timestamps();
        });
  1. config/auth.php created a new guard for my customers
'customer' => [
            'driver' => 'session',
            'provider' => 'customers',
        ],
  1. created a customer model
<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;

class Customer extends Authenticatable
{
    use HasApiTokens, Notifiable;

    protected $guard = "customer";
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'firstname', 'lastname', 'mobile'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function setPasswordAttribute($value) {
        $this->attributes["password"] = bcrypt($value);
    }
}

When I try to login first i have to get an access_token so i do a POST-Request to /oauth/token with the following params:

client_id: 2
client_secret: secret
grant_type: password
scope: *
username: username
password: password

so I get back the access token perfectly.

But now when i try to enter a protected route i get the following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token' in 'where clause'

Does i have to create a api_token field in my migration and if yes who fills this field?? What am i missing?

20 Feb
1 year ago

mathishuettl started a new conversation Get Laravel Users From Wordpress Page

Hello,

I'm planing a project that has a Wordpress as CMS and as CRM Backend it uses Laravel (Manage Customers, Manage Invoices, ...) - what do you general think about this architecture?

The second thing I want to do is, that the Website has a Booking-Form with a Login function so i want to send the username & password to laravel to check if a user with this credencials exist and give back the data (Name, Adress, ...) to Wordpress and back to Laravel when the customer submits the booking-form.

Is this possible? What is the best practice for this purpose?

09 Dec
1 year ago

mathishuettl left a reply on Access Denied For User 'forge'@'localhost'

yes i think so, because when he couldn't read any value the key would be missing and the app wouldn't work or i'm wrong?

mathishuettl left a reply on Access Denied For User 'forge'@'localhost'

i changed the db_unsername in the config - so it really looks like laravel couldn't load the .env file sometimes.

07 Dec
1 year ago

mathishuettl left a reply on Access Denied For User 'forge'@'localhost'

Hello,

yeah this solved the problem! But how can this be?

06 Dec
1 year ago

mathishuettl started a new conversation Access Denied For User 'forge'@'localhost'

Hello,

i have some select fields that gets their options via a GET request. Sometimes (when i refresh the page often) i get a 500 Error. In the laravel.log i found this line:

Access denied for user 'forge'@'localhost'

the thing is, that i doesn't use forge. My .env file looks like that:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=islandprofi
DB_USERNAME=root
DB_PASSWORD=

config/database.php:

'default' => env('DB_CONNECTION', 'mysql'),

mathishuettl left a reply on Laravel 5.5 On Synology NAS

i already tryed this solution, but when i hit composer install i get error messages that i need php 7

04 Dec
1 year ago

mathishuettl started a new conversation Object Of Class Closure Could Not Be Converted To String

Hello,

I have a search form and want to search by the lastname.

$queryBuilder->doesntHave("booking", function($q) use ($request) {
        $q->whereHas("customer", function($qq) use ($request)  {
            $qq->where("lastname", "LIKE", "%" . $request->input("lastname") . "%");
         });
});

30 Nov
1 year ago

mathishuettl left a reply on Laravel 5.5 On Synology NAS

Nobody has a solution?

24 Nov
1 year ago

mathishuettl started a new conversation Laravel 5.5 On Synology NAS

Hello,

I try to run Laravel on a synology NAS, but I have big troubles with the PHP-Version. I already installed php 7.0 over the PackageManger but when I login via SSH and type

php -v

it shows me, that php 5.6 (cli) is installed. how can i change the cli version???? I searched about 3h for a solution but nothing worked yet... please help me!! :(

mathishuettl left a reply on Problems With Search Form

@tisuchi Thanks man!!

This is my solution:

if ($request->filled("lastname")) {
                $queryBuilder->whereHas("inquiry", function($q) use ($request) {
                    $q->whereHas("customer", function($qq) use ($request)  {
                        $qq->where("lastname", "LIKE", "%" . $request->input("lastname") . "%");
                    });
                });
            }

mathishuettl started a new conversation Problems With Search Form

Hello Community,

I created a really nice Application with the help of Laravel, but there are a few things that I couldn't solve. I hope you can help me.

Here is a simplificated Screenshot of my DB-Schema: https://imgur.com/ItUeDgN

The relations are following:

Customer:

public function inquiries() {
    return $this->hasMany(Inquiry::class);
}

Inquiry:

public function booking() {
    return $this->hasOne(Booking::class);
}
public function customer() {
    return $this->belongsTo(Customer::class);
}

Booking:

public function inquiry() {
    return $this->belongsTo(Inquiry::class);
}

My Questions:

  1. How can I get all inquiries that have no Booking?
  2. How can I create a search-form that looking for Customers that have made a Booking?
25 Oct
1 year ago

mathishuettl left a reply on Problem With Caching During Development

where can i get answers when i have problems when not here??

20 Oct
1 year ago

mathishuettl left a reply on Problem With Caching During Development

still the same problems...

19 Oct
1 year ago

mathishuettl started a new conversation Problem With Caching During Development

Hello,

I have a big problem with caching during my developmet process... Since my project is on my Server everytime I change something in a View I have manually call

php artisan view:clear
`` `

to get my view updated.

And also with my Assets I got big problems. When I change something in my JS or SCSS files the app.css / app.js file gets generated in /public/css/app.css or /public/js/app.js but this files are also really hard cached.

The only way that worked was to rename the app.js file and include the renamed file... but thats a pain during development so please how can I solve this?
10 Oct
1 year ago

mathishuettl left a reply on Cors Error

Yes With Thema Same result

mathishuettl left a reply on Cors Error

Any tipps for my i searched the whole day for a solution :-/

mathishuettl started a new conversation Cors Error

Hello,

I use Laravel as Backend (localhost:80/mybackend) and a external app as frontend (localhost:8080) and I want to communicate with the API of the backend.

I use Passport as API Authentification and use https://github.com/barryvdh/laravel-cors to allow CORS, but i get the following error-message (using axios)

Failed to load http://backend.dev/oauth/token: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Origin 'http://localhost:8080' is therefore not allowed access.

03 Oct
1 year ago
30 Sep
1 year ago

mathishuettl left a reply on Where Clause On Two Relationships

no also the same error :(

mathishuettl left a reply on Where Clause On Two Relationships

okay thanks, but this doesn't solve the problem because i still get a methodnotfound exception

mathishuettl left a reply on Where Clause On Two Relationships

Thanks guys, but i get a errormessage

BadMethodCallException Call to undefined method App\Customer::has()

29 Sep
1 year ago

mathishuettl started a new conversation Where Clause On Two Relationships

Hello,

I got a Database like this:

Customers: id, name

Inquiries: id customer_id

Bookings: id inquiry_id

Now i want to search all customers who made a booking, but i don't know how... can you help me?

27 Sep
1 year ago

mathishuettl started a new conversation $request->has("fieldname") Returns Everytime True!

Hello,

when i do $request->has("myfieldname") it returns every time true.

Here my example:

if ($request->has("title")) {
    $rules["title"] = "alpha|max:50";
}

below you can see dd($request->all);

https://imgur.com/X7rYxM7

mathishuettl left a reply on MimeTypeGuesser -> FileNotFoundException

help me please guys...

26 Sep
1 year ago

mathishuettl started a new conversation MimeTypeGuesser -> FileNotFoundException

Hello,

I have a strange problem on a project. There is a file-upload function where users can upload images and videos. Sometimes this problem appears and sometimes it doesn't. It's only when the user uploads a video. that is greater then about 2 mb

https://imgur.com/VsZVrrDff

public function upload(Request $request) {
      $rules = [
          "tags" => "required",
          "accept_rules" => "required|in:true"
      ];

      $mime = $request->file("file")->extension();
      if ($mime == "png" || $mime == "jpg" || $mime == "jpeg") {
          $rules["file"] = "required|file|mimes:jpeg,jpg,png,webm,mp4|max:1024";
      } elseif ($mime == "mp4" || $mime == "webm") {
          $rules["file"] = "required|file|mimes:jpeg,jpg,png,webm,mp4|max:32768";
      } else {
          $rules["file"] = "required|file|mimes:jpeg,jpg,png,webm,mp4|max:32768";
      }

      if ($request->has("link")) {
          $rules["link"] = "url";
      }

      
      switch ($request->file("file")->extension()) {
          case "png":
          case "jpg":
          case "jpeg":
              $post->type = "image";
              $post->media = $request->file("file")->store("uploads");

              $image = Image::make($request->file("file")->path());
              $thumb_path = "thumbs/" . md5($request->file("file")->getClientOriginalName() . time()) . "." . $request->file("file")->extension();
              $image->fit(300, 300)->save(storage_path("app/public/") . $thumb_path);
              $post->thumb = $thumb_path;
              break;
          case "mp4":
          case "webm":
              $post->type = "video";
              $post->media = $request->file("file")->store("uploads");
    
              $video_thumb_url = "thumbs/" . md5($request->file("file")->getClientOriginalName() . time()) . ".png";
              $video_thumb_path = storage_path("app/public/") . $video_thumb_url;
              $mov = new \ffmpeg_movie(storage_path("app/public/") . $post->media);
              $frame = $mov->getFrame(10);
              if ($frame) {
                  $gd_image = $frame->toGDImage();
                  if ($gd_image) {
                      imagejpeg($gd_image, $video_thumb_path);
                      imagedestroy($gd_image);
                      $post->thumb = $video_thumb_url;
                  }
              }
              break;
      }
}
30 Aug
1 year ago

mathishuettl started a new conversation Handle PostTooLargeException

Hello,

how can it be done that when I try to upload a file that is bigger than my post_max_size that the controller handles this error? It doesn't look very nice for the user when this error gets thrown.

I already have a validation rule for my upload:

"required|file|mimes:jpeg,jpg,png,webm,mp4|max:1024";

But when I select a 300mb file as example then the controller should validate this not laravel itself. You know what i mean?

01 Aug
1 year ago

mathishuettl left a reply on Set Cookie With Username On Login

I want to check if the user is a "superadmin" with javascript and only show a button when he is a "superadmin" for sure i will check it on the server again, that i don't have security issues.

mathishuettl started a new conversation Set Cookie With Username On Login

Hello,

how can I set a cookie with the username when the user logs in and delete it when the user logs out? I use onboard Laravel Auth package.

28 Jul
1 year ago

mathishuettl started a new conversation OrderBy Relationship

Hello,

Model Farvorite ID, user_id, post_id

Post ID, Title, created_at

User hastMany Farvorite Farvorite belongsTo Post

So how can i sort by Posts created_at field?

11 Jul
1 year ago

mathishuettl started a new conversation How To Handle Dynamic Select Options

Hello,

I want to add dynamic select options to my application. Let's imagine I want to assign a color to a car-model. The "color" select-field has dynamic options. So i can add / remove colors.

When I have 5 colors with the color "red" in my Database what should happen when the user want to delete the color-option "red"?

And what is the best practice for dynamic select options in laravel?

04 Jul
1 year ago

mathishuettl started a new conversation Price Should Be Valid On With Specific Date

Hello,

I have a price-table that includes some rates it has the following structure:

ID, key, valid_from, price

Everytime when the price rises (most on 1st January) I want to add a record to the Table with a different valid_from and a different price. The Key should be the Same.

Because when I reprint an old invoice I want to have the same price then it was on the invoice date.

Does i need two Tables or can i use the group_by functionality here? Can someone give me an example if group_by is possible in my case?

I would solve it like this, but i think it's a bad solution:

I have a Table called Tariffs with the following structure: ID, key,

Then I have a Table called tarif_dates with the following structure: ID, tariff_id, valid_from, price

So my Tariffs hasMany tarif_dates.

03 Jul
1 year ago

mathishuettl left a reply on QueryBuilder Relation Where

wow thanks this solved my problem!

mathishuettl started a new conversation QueryBuilder Relation Where

Hello,

I have a search form to find models in my App. So i use the Querybuilder for getting the results. But I don't know how to search in a relation?


$queryBuilder = Class::query();

        if ($request->has("user_id")) {
            $queryBuilder->where("user_id", "=", $request->user_id);
        }
        if ($request->has("lastname")) {
           // this line doesn't work - it's just an example.
            $queryBuilder->with(["members"])->where("lastname", "=", $request->lastname);
        }
12 Jun
2 years ago

mathishuettl left a reply on Notification System

Hello,

this works pretty good! But can i group them with the object id? So i know how many likes / disliked for each post?

mathishuettl started a new conversation Notification System

Hello,

I need to build a notification-system similar to facebook. When somebody up / down votes a picture i want to notify the user.

The hard part here is, when as example 12 People liked a Picture I don't want to show 12 entrys i just want to tell the user "12 People liked your photo" but how can I do this with laravel / eloquent?

I already read about grouping but I don't understand this..

My Table looks like that:

$table->increments('id');
$table->integer("user_id")->unsigned();
$table->integer("object_id")->unsigned();
$table->boolean("red")->default(false);
$table->enum("type", ["post_like", "post_dislike", "tag_like", "tag_dislike", "comment_like", "comment_dislike"]);
$table->integer("sender_id")->unsigned();
$table->timestamps();

Do you have any sources or tipps for my purpose?

08 Jun
2 years ago

mathishuettl left a reply on Get Position Or Row With OrderBy

i show the users position and show the top three leaderboard.

http://imgur.com/a/26pIw

07 Jun
2 years ago

mathishuettl left a reply on Blank Page And Log Is Empty

okay and what does this mean? what can i try?

mathishuettl left a reply on Blank Page And Log Is Empty

hello, good idea but I already tried this. And no there is still no log-entry. But for sure I did "chmod -R 777 storage"