HCK

HCK

Member Since 2 Years Ago

Lima

Application engineer at Optima Energía

Experience Points 20,900
Experience Level 5

4,100 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 206
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 Feb
4 months ago

HCK started a new conversation Database Connection With A AWS Server Created With Forge.

Hello, I've added my AWS keys and created a server with Forge (region: Virginia). Then, I created a site and added it the repository to pull the code from. So good so far. The thing is, I didn't activate quick deploy in that moment.

By the way, I created a database when creating my site.

Now I push my code and needed to run mi migrations.. but I got this message:

We were unable to deploy to server (MY_SERVER_NAME).


  Exception trace:

  1   PDOException::("SQLSTATE[HY000] [2002] Connection refused")
      /home/forge/lumen.optimaee.com/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  2   PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=my_db_name", "my_db_user", "my_db_password", [])

Now, this is the first time that I use AWS. I did all this things on DigitalOcean and haven't had a problem until now.

I checked my .ENV file and my keys are configured like this:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1       // <---- this is the actual value
DB_PORT=3306       // <---- this is the actual value
DB_DATABASE=my_db_name
DB_USERNAME=my_db_user
DB_PASSWORD=my_db_password

Are this DB_HOST/DB_PORT keys appropiate when using AWS? I've tried to search information about it but so far nothing.

Thanks in advance.

14 Jan
6 months ago

HCK started a new conversation Laracasts Membership Pricing

Hi,

I've check my past invoices and I was paing $9/mo. Now the site says $15/mo but in the "My Suscription" section of my account it keeps saying $9/mo.

Is it because I have an active membership that will keep charging me that amount until I decide to cancel my account? or there is another explanation?

Thanks in advance.

13 May
1 year ago

HCK started a new conversation Not Receiving The $message Variable In View From A Laravel HTML Mailable (NON Markdown)

Hello,

First of all, I've read several similar questions related to this problem but all refer to Markdown mailables.

I'm trying to send inline images in the mailables but I haven't found a way to do it properly (Laravel 5.5).

The documentation says this:

Inline Attachments

Embedding inline images into your emails is typically cumbersome; however, Laravel provides a convenient way to attach images to your emails and retrieving the appropriate CID. To embed an inline image, use the embed method on the $message variable within your email template. Laravel automatically makes the $message variable available to all of your email templates, so you don't need to worry about passing it in manually:

<body>
    Here is an image:

    <img src="{{ $message->embed($pathToFile) }}">
</body>

But, when doing that I receive this error:

Undefined variable: message (View: /path/to/project/resources/views/mails/new_user_welcome.blade.php)

I know that this has a limitation when using a Markdown message but I'm not using one.

This are the related files:

Mail/NewUserWelcomeEmail.php

    class NewUserWelcomeEmail extends Mailable implements ShouldQueue
    {
        use Queueable, SerializesModels;
    
        public $user;
    
        public function __construct(User $user)
        {
            $this->user = $user;
        }
    
        public function build()
        {
            return $this->view('mails.new_user_welcome');
        }
    
        public function onQueue($queue)
        {
            return 'low';
        }
    }

Resources/views/mails/new_user_welcome.blade.php

    @extends('layouts.mail')
    
    @section('content')
    
        <img class="Feature__element__image" 
        src="{{ $message->embed(url("storage/images/emails/find_fields.png")) }}" 
        alt="Find fields" />
    
    @endsection

App/Http/Controllers/UserController.php

    public function register(NewUserRequest $request)
    {
        $data = $this->getUserData($request);
        $user = $this->userRepository->create($data);
        $token = JWTAuth::fromUser($user);
        $user->attachRole('user');
    
        Mail::to($user)->send(new NewUserWelcomeEmail($user));
    
        return response()->json([
            "message" => "The user has been successfully registered.",
            "data"    => [
                "token_type"   => "Bearer",
                "access_token" => $token
            ]
        ], Response::HTTP_CREATED);
    }
28 Feb
1 year ago

HCK started a new conversation Test Methods Fail Using Storage. Illuminate\Http\Testing\imagepng() In Laravel

Hello, I'm doing TDD to test my development, my tests were passing until I decided to reinstall php to repair the sqlite driver for testing (the main driver is mysql). So when I run my hole suite of tests this error shows in every method that uses the storage:

    Error : Call to undefined function Illuminate\Http\Testing\imagepng()
     {laravel}/framework/src/Illuminate/Http/Testing/FileFactory.php:46
     {laravel}/framework/src/Illuminate/Support/helpers.php:1038
     {laravel}/framework/src/Illuminate/Http/Testing/FileFactory.php:49
     {laravel}/framework/src/Illuminate/Http/Testing/FileFactory.php:31
     {laravel}/tests/Feature/FacilityTest.php:38

This one is a method that throws the above error (the line 38 is signaled):

    /**
     * @test
     * Test for: a Facility can be registered by an admin.
     */
    public function a_facility_can_be_registered_by_an_admin()
    {
        /** Given a correct information for a facility */
        \Storage::fake('public');

       // Next line is 38 the problematic one:
        $data = ["name" => "Facility A", 'image' => UploadedFile::fake()->image('facility-a.jpg')];
    
        /** When the request is made by an admin */
        $admin = $this->createUser([], 'admin');
        $response = $this->apiAs($admin, 'POST', '/api/v1/manage/facilities', $data);
    
        /** Then the facility should be registered */
        $response->assertStatus(Response::HTTP_CREATED);
    }

I really don't know why.

If this helps, this is my phpunit file:

phpunit.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <phpunit backupGlobals="false"
             backupStaticAttributes="false"
             bootstrap="vendor/autoload.php"
             colors="true"
             convertErrorsToExceptions="true"
             convertNoticesToExceptions="true"
             convertWarningsToExceptions="true"
             processIsolation="false"
             stopOnFailure="false">
        <testsuites>
            <testsuite name="Feature">
                <directory suffix="Test.php">./tests/Feature</directory>
            </testsuite>
    
            <testsuite name="Unit">
                <directory suffix="Test.php">./tests/Unit</directory>
            </testsuite>
        </testsuites>
        <filter>
            <whitelist processUncoveredFilesFromWhitelist="true">
                <directory suffix=".php">./app</directory>
            </whitelist>
        </filter>
        <php>
            <env name="APP_ENV" value="testing"/>
            <env name="CACHE_DRIVER" value="array"/>
            <env name="SESSION_DRIVER" value="array"/>
            <env name="QUEUE_DRIVER" value="sync"/>
            <env name="DB_CONNECTION" value="sqlite"/>
        </php>
    </phpunit>

Thanks in advance.

27 Jul
1 year ago

HCK started a new conversation Integrating Laravel Passport With Socialite To Consume From Android/iOS App

I want to add Laravel Socialite to let user to login to my Android app, now i'm using Passport for auth (Passwpord Grant Token) so i want to login users and return the token so the app could make the rest of the api calls.

How could I achieve this? I've searched but unlucky atm.

Don't know what to add to the Callback function to return the a regular Passport response, something like this:

{
    "token_type": "Bearer", // or other method
    "expires_in": 31536000,
    "access_token": "eyJ0eXAiOiJKV....WaYC14FGOPuhViVIE",
    "refresh_token": "XhZKHr2S2Ikp...wMKWfmksñT/MxVQvg="
}
25 May
2 years ago

HCK started a new conversation Customize Responses With Middlewarae

Hi guys, i'm trying to build a middleware to transform the response into json if the request is made from one of my api routes, but can't "extract" de data from the response. How can I accomplished this? I found a "solution" on the net but doesn't work for me:

// inside my middleware class
public function handle($request, Closure $next)
{
    $response = $next($request);
    return response()->json($response->getData());
}   

But it returns an error "getData()" doesn't exist. And it is true.

Btw, the reason why i'm doing this is because i want to use the same controllers for Web and API calls so, for default i return a view, but if the call is made from an api route it should return it as a json. If there is a better aproach is welcome!

Thanks in advance