EmilMoe

EmilMoe

Software Engineer at Online

Phnom Penh

Hire Me

Member Since 4 Years Ago

Experience Points 34,220
Experience
Level
Lessons Completed 163
Lessons
Completed
Best Reply Awards 11
Best Answer
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.

11 Dec
6 hours ago

EmilMoe left a reply on Run Artisan Command From Composer Post-update

I can see I can use PHPs readline()

EmilMoe started a new conversation Run Artisan Command From Composer Post-update

Is it possible to run an Artisan command from a Composer script like post-update?

I would like to prompt for some input in the console.

21 Nov
2 weeks ago

EmilMoe left a reply on Migrate App Before Packages

I was looking further into it. It seems there's an error with the package, someone has, for some reason, made it change name during migration.

EmilMoe started a new conversation Migrate App Before Packages

How can I migrate the app before the packages? I have a folder called /packages that contains some migration files.

The problem is that Laravel tries to migrate those packages before the default location, that means it gives me errors as the "default" migrations contains the structure the packages rely on.

The time stamps are correct. The default migrations start from 2016 and the packages are 2018, so it must be because Laravel is looking in the packages folder before it tries the "root" migrations.

08 Aug
4 months ago

EmilMoe started a new conversation Inlined Vue JS Arrays In Trouble With IE

I am getting awfully many errors on Internet Explorer (11) and I suspect it's because that IE cannot handle multi-line inlined arrays..?

Is there any way in Laravel to tackle this, it's all processed, so maybe a feature exists to skip line breaks?

03 Jun
6 months ago

EmilMoe left a reply on GDPR - For Those Of You Building Apps With Laravel

To clarify: Not everything needs to be encrypted, only high risk data such as social security numbers and bank information.

17 May
6 months ago

EmilMoe left a reply on Hot Reloading Not Creating Any Files

That works completely differently?

EmilMoe left a reply on Hot Reloading Not Creating Any Files

Thanks. However it still doesn't work, that's why I thought the missing files was the problem.

I run npm run dev and it's as expected. Then npm run hot but changes are not pushed through to the browser, not even when I refresh the page.

16 May
6 months ago

EmilMoe left a reply on Hot Reloading Not Creating Any Files

But that's not really going to make hot reloading working.

EmilMoe left a reply on Hot Reloading Not Creating Any Files

They both work without problems

EmilMoe started a new conversation Hot Reloading Not Creating Any Files

When I run npm run hot it takes a while and then no files where created in the public folder except for the manifest and a file called hot.

Why isn't it creating my CSS and JS files? I have reset my mix configuration to default but still no success.

I'm using Windows 10.

let mix = require('laravel-mix')

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');
01 May
7 months ago

EmilMoe started a new conversation Hot Reload Not Working In Windows (Chrome)

I have got hot reloading to work fine on my Mac, I think (although it seems I still need to refresh the page?).

But on my Windows it doesn't even work after I reload it.

On my Mac in the DevTools console I noticed these 2 lines:

[HMR] Waiting for update signal from WDS...
[WDS] Hot Module Replacement enabled.

Which doesn't appear on my Windows, so I suspect there's a problem about there?

Running npm run hot just tells me it's set up fine.

I'm using Windows 10 and Chrome 65 or something (newest)

30 Apr
7 months ago

EmilMoe left a reply on STR_TO_DATE Always Returns NULL, But Only In Laravel

Reconnect solved it :-)

$strict = config('database.connections.'. config('database.default') .'.strict');
Config::set('database.connections.'. config('database.default') .'.strict', false);
DB::reconnect();
dd(DB::select(DB::raw("SELECT STR_TO_DATE('2017M05', '%YM%m') as testdate")));

EmilMoe left a reply on STR_TO_DATE Always Returns NULL, But Only In Laravel

I tried this, but altough when testing the strict mode is set to false, then it still returns null. However if I change the settings manually, then it works. Shouldn't thtis override the config?

$strict = config('database.connections.'. config('database.default') .'.strict');
Config::set('database.connections.'. config('database.default') .'.strict', false);
dd(DB::select(DB::raw("SELECT STR_TO_DATE('2017M05', '%YM%m') as testdate")));

EmilMoe left a reply on STR_TO_DATE Always Returns NULL, But Only In Laravel

Thanks @AlexDemin and @Cronix very well spotted. Do you know if I can change this within the code without having to run non-strict all the time?

29 Apr
7 months ago

EmilMoe started a new conversation STR_TO_DATE Always Returns NULL, But Only In Laravel

I want to test a date format up against the database standards, so I run a query like this:

DB::select(DB::raw("SELECT STR_TO_DATE('2017M05', '%YM%m') as testdate"))

But why does it always give me null ? If I execute the same query in the database directly, it gives me 2017-05-00

16 Apr
7 months ago

EmilMoe left a reply on Install Composer Package From Private Gitlab

Thanks. I know about ssh keys and deploy keys, but what I don't know about is the configuration in composer

EmilMoe started a new conversation Install Composer Package From Private Gitlab

I have been struggling a bit getting it to work to delegate some of my features to a private gitlab repo. I am not sure how I should configure it in my composer.json.

Seems like I'm messing something up with a token or ssh key. As far as I can tell it would be easiest with at token, when I am going to distribute the code to several servers?

15 Apr
7 months ago

EmilMoe left a reply on Execute Code (last) On Every Page

@Cronix true, thanks.

I have implemented as this:

$router->aliasMiddleware('log', DefaultLog::class);
$router->pushMiddlewareToGroup('web', 'log');

EmilMoe left a reply on Execute Code (last) On Every Page

Thanks @Snapey , do you know if I can force it to on routes so I don't have to configure every route manually?

EmilMoe started a new conversation Execute Code (last) On Every Page

How can I execute a piece of code on every page?

I want to set logging per default, but it should be overridable by custom logs, so a default log is only done when no other logs are written.

I'm using Spatie/ActivityLog, it's for logging user actions not Laravel bugs etc.

I have an observer that can be called to set hasLoggedand the default log can check against that. The problem is that the default log check should be enforced to execute after everything else, as if it runs first of course no where else a log was created.

11 Apr
8 months ago

EmilMoe started a new conversation Hot Reload

I am running Laravel 5.6 on Docker (Ubuntu). I have tried to execute npm run hot but it seems to just get stuck there. Can anyone help me out how I can run hot reload?

I have open port 8080 in Docker.

20 Feb
9 months ago

EmilMoe started a new conversation API And Access Permission In Package

With some packages I'm creating there's an API along. Some of these APIs are not for the public so I want to restrict access somehow, possibly with Password?

The problem is that I don't know the exact setup where the package is installed, so hard coding permissions might not be the right way to do it? Do you have any good ideas how I can implement this?

I'm not very familiar with Passport, maybe it has some good ways to generate a token that my package listens for?

12 Feb
9 months ago

EmilMoe left a reply on Ubuntu And PHP 7.1

I'm trying to install it with Docker, the Ubuntu is version Version: 17.06.1-ce and it says Unable to locate package php7.1 but maybe I should try 7.2 instead then?

EmilMoe started a new conversation Ubuntu And PHP 7.1

I can see that Laravel 5.6 requires PHP 7.1, but it looks to me that the latest version available for Ubuntu is only 7.0 or am I wrong?

11 Dec
1 year ago

EmilMoe started a new conversation Queue, Nothing Happens

I have migrated the jobs table and trying to create a queue on the database driver (local run). But when I run either queue:listen or queue:work absolutely nothing happens.

I have a job or 2 in the database of course.

18 Nov
1 year ago

EmilMoe left a reply on Testing In Laravel Doesn't Persist In Method

I found the error. Bummer. It was a 40

17 Nov
1 year ago

EmilMoe left a reply on Testing In Laravel Doesn't Persist In Method

Thanks. I'm not sure though that I can see what I should look for there.

EmilMoe started a new conversation Testing In Laravel Doesn't Persist In Method

I have this testing method:

public function testCanResetPassword()
{
    $this->call('POST', '/password/reset', [
        'email'  => '[email protected]',
        '_token' => csrf_token(),
    ])->assertStatus(200);

    $token = DB::table('password_resets')->where('email', '[email protected]')->first()->token;

    $response = $this->call('POST', '/password/generate', [
        'token'  => $token,
        '_token' => csrf_token(),
    ])->assertStatus(200);

    $password = $response->content();

    $this->assertTrue(Auth::check());
    $this->assertTrue(Hash::check($password, User::where('email', '[email protected]')->first()->password));
}

Which fails at the last 2 lines, because the reset password isn't stored in my generate method:

public function generatePassword(Request $request)
{
    try {
        $user = $this->getUserFromToken($request->input('token'));
    }
    catch (\Exception $e) {
        return response('Token not found', 400);
    }

    $password = str_random(8);

    $user->password = Hash::make($password);
    $user->save();

    $this->authenticate($user->email, $password);

    return $password;
}

Everything seem to work when it's in non-testing environment. $this->authenticate doesn't authenticate either as $password is not really stored. I must be missing some details here? As far as I know the password should be saved until the end of the testing method?

10 Nov
1 year ago
23 Oct
1 year ago

EmilMoe left a reply on GitLab Pipeline Failed

No problem :-)

EmilMoe left a reply on GitLab Pipeline Failed

@druc it looks like you are running your own GitLab server where I'm using their hosted solution?

22 Oct
1 year ago

EmilMoe left a reply on GitLab Pipeline Failed

Thanks for the suggestion @Daveismyname however what I am mainly looking for is automated testing.

You should also consider limiting that script to GitLabs server only :-)

21 Oct
1 year ago

EmilMoe started a new conversation GitLab Pipeline Failed

Anyone knows what this error means? I can't see what the problem is

\App\Providers::AppServiceProvider
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  3/  3)
\App\Providers::AuthServiceProvider
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  2/  2)
\App\Providers::EventServiceProvider
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  2/  2)
\App\Providers::RouteServiceProvider
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 14/ 14)
section_end:1508582118:build_script
section_start:1508582118:after_script
section_end:1508582119:after_script
ERROR: Job failed: exit code 1

15 Oct
1 year ago

EmilMoe left a reply on How To Add Relationship While Creating The Object?

What more information do you need?

The pivot data is sent as an array, where the property id is one.

EmilMoe started a new conversation How To Add Relationship While Creating The Object?

I'm using this magic set attribute to handle relation models, however the problem of course occur when you want to associate the relationship during create as the object doesn't exist yet resulting in trying to create a relation between a table and an unknown record.

Any good suggestions how I tackle that this is postponed to after the object is created? I tried to use boot() and created but unfortunately the roles attribute are not available to that method.

public function setRolesAttribute($roles)
{
    $this->roles()->detach();

    collect($roles)->each(function ($role) {
        $this->roles()->save(Role::findOrFail($role['id']));
    });
}
13 Oct
1 year ago

EmilMoe left a reply on Only And Except Doesn't Not Work With ResourceCollection

What I am, or trying to, ask is if I can filter the output properties in the resource from the collection.

Resource Collections
If you are returning a collection of resources

EmilMoe left a reply on Only And Except Doesn't Not Work With ResourceCollection

I think you confusde Resource and Collection, @martinbean ? A collection spans several resources, correct?

12 Oct
1 year ago

EmilMoe left a reply on Only And Except Doesn't Not Work With ResourceCollection

@martinbean you mean filter my resource then .. ?

Would you recommend me creating 2 resources then? And do you have a genius naming convention for that.

EmilMoe left a reply on Only And Except Doesn't Not Work With ResourceCollection

pluck will give name => description if I'm righit?

`Model::get`` will unfortunately leave empty resources null, which I'm not interested in.

11 Oct
1 year ago

EmilMoe started a new conversation Only And Except Doesn't Not Work With ResourceCollection

I'm trying to figure out how for a specific Resource calling a ResourceCollection, I can filter to only some properties. only and except doesn't seem to work, probably because what's returned is an AnonymousResourceCollection.

You can see the structure is wrapped in different resource collections, and I think that could be the issue?

AnonymousResourceCollection {#584 ▼
  +collects: "App\Http\Resources\User"
  +collection: Collection {#544 ▼
    #items: array:2 [▼
      0 => User {#583 ▼
        +resource: User {#622 ▼
~~~~
27 Sep
1 year ago

EmilMoe left a reply on Vue Packages Version Mismatch

It takes time to update a huge old project

EmilMoe started a new conversation Vue Packages Version Mismatch

I get this error when running webpack

- [email protected]
- [email protected]

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using [email protected]>=10.0, simply update vue-template-compiler.
If you are using [email protected]<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.

However when I try to install [email protected] it says

npm install [email protected]
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected]
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

How can I solve this mismatch?

I tried to ask on GitHub but apparently they don't want to help with version 1 requests.

26 Sep
1 year ago

EmilMoe left a reply on Compile JavaScript To IE11 (ES5?)

I see, thanks !

EmilMoe left a reply on Compile JavaScript To IE11 (ES5?)

Someone else must have hit this problem?

EmilMoe started a new conversation Compile JavaScript To IE11 (ES5?)

I have a Laravel project where I have some JavaScript files that are ES6 written, for instance I use let. How can I compile this to be compliant to IE11? I assume I need to convert/compile it into ES5.

I came across this

npm install babel-preset-es2015

But I'm not sure if that's it and how to use it in Laravel mix?

18 Sep
1 year ago

EmilMoe started a new conversation NPM To Work In IE

Can I do something so the transpiled script from npm run works in IE?

I would like to write in ES6, but IE only supports ES5 so things like let fails and forEach(). What are the best solutions to fix that?

04 Sep
1 year ago

EmilMoe started a new conversation Update Prop With Lodash

I am struggling to get my prop updated once it exists. The deep object is not existing before runtime so I need to handle that somehow.

I have tried with lodash, but it doesn't seem to be reactive:

:counter="_.get($store.state.bindings, 'group.count', 0)"
~~~~