Hagbard

Hagbard

Member Since 2 Years Ago

Experience Points 370
Experience Level 1

4,630 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 0
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.

21 Aug
3 weeks ago

Hagbard left a reply on Fresh Installation Of Brew With MySQL. Can't Connect

Not sure if I had to run it with specific version. Nonetheless, the service is started. If i run brew services list, it appears as running.

Hagbard left a reply on Fresh Installation Of Brew With MySQL. Can't Connect

The service is both started using brew brew services start mysql and just mysql.server start

Hagbard started a new conversation Fresh Installation Of Brew With MySQL. Can't Connect

I have a fresh installation of homebrew. I wanted to install MySQL, so I ran:

brew install [email protected]

After this, I tried connecting using Sequel Pro and 127.0.0.1 for host, and root for user. This gave me this error:

Unable to connect to host 127.0.0.1, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Access denied for user 'root'@'localhost'

If I try to run mysql -uroot in terminal, i also get access denied error.

09 Sep
2 years ago

Hagbard started a new conversation Using Trait To Typehint Model In Resource Controller

Is it possible to typehint a trait, in a resource controller?

I wan't to accomplish this to reduce the amount of files and code I have.

For example:

I my routes, i have the this:

Route::resource('order.comment', 'CommentController')
Route::resource('fulfillment.comment', 'CommentController')

Here, i want to both comments to a order and fulfillments sent to the same controller, because the code would be the same anyway.

To do this, i have created a trait containing the methods for Morphing comments. See here:

use App\Comment;

trait Commentable
{
    /**
     * Get the model's comments.
     *
     * @return \Illuminate\Database\Eloquent\Relations\MorphMany
     */
    public function Comments()
    {
        return $this->morphMany(Comment::class, 'commentable')->orderBy('created_at', 'DESC');
    }
}

In my Order and Fulfillment i use this trait.

In my CommentController, i typehint the trait like this:

public function store(CreateCommentRequest $request, Commentable $commentable)

Then, I could just save comments like this:

$commentable->Comments()->save(new Comment($data))

However, when i post comments using the route, I get the following exception:

Illuminate\Contracts\Container\BindingResolutionException
Target [App\Models\Morphs\Commentable] is not instantiable.

Is it possible to make this work?

14 Apr
2 years ago

Hagbard left a reply on Laravel Valet Share Debug Log

Ignore this. It got 500 because of Token Mismatch. (For obvious reasons :D)

Hagbard started a new conversation Laravel Valet Share Debug Log

Hello,

I am currently testing my application where external send data to me. When i share the site using Valet Share command, i can see the calls are getting an error code 500, but my debug log is empty.

The debug log is working when i make errors browsing the site locally.

How can i see the errors?

28 Jan
2 years ago

Hagbard left a reply on Laravel 5.4 New TrimStrings Middleware Not Working

Yes. That is in my controller.

But it is mostly an issue in my request validation, because the rules doesn't check the transformed values.

Hagbard left a reply on Laravel 5.4 New TrimStrings Middleware Not Working

Seem to my by own fault here, but weird behaivor in Laravel.

$request->input('my_string') => Untrimmed

request('my_string') => Trimmed

Hagbard left a reply on Laravel 5.4 New TrimStrings Middleware Not Working

All the middlewares are running. TrimStrings, ConvertEmptyStringsToNull and my own BuildURL.

dump-autoload doesn't fix this issue.

Hagbard started a new conversation Laravel 5.4 New TrimStrings Middleware Not Working

Hello,

I recently upgraded from Laravel 5.3 to 5.4. I've added the new middleware "TrimStrings" to my global middleware stack.

protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
    \App\Http\Middleware\TrimStrings::class,
    \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
    \App\Http\Middleware\BuildURL::class
];

However, it doesn't seem to work. String doesn't get trimmed. I've tried to make a similar middleware which transforms requests (BuildURL), and i notice it is running and returning the new string, but it doesn't get applyed to the request.

You can see my own middleware here:

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\TransformsRequest;

class BuildURL extends TransformsRequest
{
    /**
     * Build URL.
     *
     * @param string $key
     * @param mixed $value
     * @return mixed
     */
    protected function transform($key, $value)
    {
        if ($key === 'url') {
            if (substr($value, 0, 5) !== 'https' and substr($value, 0, 4) !== 'http') {
                $value = 'https://' . $value;
            }

            if (substr($value, -1, 1) !== '/') {
                $value = $value . '/';
            }

            return $value;
        }

        return $value;
    }
}

Is this a bug, or do i need to update something in my code?

24 Dec
2 years ago

Hagbard started a new conversation Vue2 + Locotus

Hey! How can i implement Locotus (https://github.com/kvz/locutus). I want to use functions like this in my Vue templates:

{{ nl2br(MyHTML) }}

I am using Webpack and single file components.