EmilMoe

Member Since 4 Years Ago

Phnom Penh

Software Engineer at Online

Experience Points 34,470
Experience Level 7

530 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 163
Lessons
Completed
Best Reply Awards 11
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.

19 Jun
3 weeks ago

EmilMoe left a reply on How To Create A Pin Like Passsword?

You can specify custom fields to verify your users by, if that's what you mean: https://laravel.com/docs/5.8/authentication#authenticating-users

If you want to "pin auth" them after they log you could create a middleware called something like Verified or AuthWithPin or what you would like. So that when a user is authed, but not yet with a pin, this will be triggered. (You need to store the pin status in a session).

Easiest option is of course to include the extra parameter at login.

The reset part is a matter of generating a token, call the column pin_tokenand send an email to the user with a token link that will reset the pin.

EmilMoe left a reply on Vue - Parse JSON String

The more logically setup would be that every node is a row, not a column. From there you could either have named properties or just iterate, but you should have a schema for the table setup that describes the number of columns and maybe their header.

30 May
1 month ago

EmilMoe left a reply on Convert SQL Raw Query To Laravel ORM Or Query Builder

I'm supposing that you are using this for a log?

use App\Logger;
use Carbon\Carbon;

[..]

$log = Logger::whereDay'visited_time', Carbon::now()->day)
    ->whereMonth('visited_time', Carbon::now()->month)
    ->whereYear('visited_time', Carbon::now()->year)
    ->get();

$log->first()->browser;

What you mean about distinct id I'm not sure, isn't that always distinct?

29 May
1 month ago

EmilMoe left a reply on Sudden Error In Composer

@DEVFREY - Yeah.. It must be something I changed when I started with private packages.

I would like to click you as best answer, but the button currently doesn't work in Chrome on Mac. It's flickering.

EmilMoe left a reply on Sudden Error In Composer

@DEVFREY - Thanks! It gave a lot of downgrades, but it works now.

EmilMoe left a reply on Sudden Error In Composer

@devfrey I assume you mean like this: https://pasteboard.co/IgVSUOGs.png

Still same error.

EmilMoe left a reply on Sudden Error In Composer

@MUNAZZIL - Install worked, but when I run update after, it fails again.

EmilMoe left a reply on Sudden Error In Composer

@MUNAZZIL - Unfortunately they both result in the same error

EmilMoe started a new conversation Sudden Error In Composer

Yesterday I suddenly started to get this error in composer, I know it references one of my private packages, but that has been granted ssh access and added as VCS - I have several other private too. My minimum stability is set to dev and it worked without problems yesterday morning and nothing was changed in the code from it worked till it didn't yesterday evening.

Hope anyone can help me sort out what has went wrong

  [Composer\DependencyResolver\SolverProblemsException]                                                               
  Problem 1                                                                                                           
      - Installation request for laravel/framework 5.8.* -> satisfiable by laravel/framework[5.8.x-dev].              
      - laravel/framework 5.8.x-dev requires symfony/debug ^4.2 -> no matching package found.                         
    Problem 2                                                                                                         
      - laravel/framework 5.8.x-dev requires symfony/debug ^4.2 -> no matching package found.                         
      - emilmoe/wiseflow dev-master requires illuminate/support ~5.8 -> satisfiable by laravel/framework[5.8.x-dev].  
      - Installation request for emilmoe/wiseflow * -> satisfiable by emilmoe/wiseflow[dev-master].                   
                                                                                                                      
  Potential causes:                                                                                                   
   - A typo in the package name                                                                                       
   - The package is not available in a stable-enough version according to your minimum-stability setting              
     see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.                               
   - It's a private package and you forgot to add a custom repository to find it                                      
                                                                                                                      
  Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.                         
11 Jan
6 months ago

EmilMoe left a reply on Lock Column For Row

@EQUALIZEE - Unfortunately it looks like transaction locking, mine is more an application infrastructure than database I guess.

EmilMoe left a reply on Lock Column For Row

In case no feature in Laravel supports this, here's a reference on how to do it for anyone else:

https://stackoverflow.com/questions/32021282/laravel-5-record-editing-check-in-check-out-functionality-locking

EmilMoe started a new conversation Lock Column For Row

Does a build-in functionality exists where I can lock a set of column for a row? Like the feature with Soft Delete.

I want to lock certain values from being changes, but only after other things have been performed, so at first for a while it can be modified.

11 Dec
7 months 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
7 months 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
11 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
1 year 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
1 year 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
1 year 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
1 year 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
1 year 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
1 year 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
1 year 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
1 year 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
1 year 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
1 year 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
1 year 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']));
    });
}