EmilMoe

Software Engineer at Online

Member Since 5 Years Ago

Phnom Penh

Experience Points
34,680
Total
Experience

320 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.

Level 7
34,680 XP
Oct
12
5 days ago
Activity icon

Started a new conversation Passport For A Package

I would like to create a package others can install in their Laravel, which will communicate with my app.

I thought I would do that by using Laravel Passport, but I feel the authorization step will be a problem here?

I know many developers will simply ask you to add secret and client_id to .env. Should I simply use skipsAuthorization and let my package gather a token and keep it up to date?

Oct
08
1 week ago
Activity icon

Replied to Multiple Databases

@martinbean

I agree that is a better approach, unfortunately the setup has been developed for 1 client and it will require a lot of work and testing to ensure that the database works for multiple clients. It might be good to migrate towards this in the long run, but it's also a time consuming migration unfortauntely.

Activity icon

Started a new conversation Multiple Databases

How would you handle multiple databases in Laravel?

I want to use the same codebase for several clients, but they will be on different databases. I thought first I could override the env from Apache, but then I don't see how I can run migrations? So I need to be able to set up different databases for different clients (they can be identified by the domain they access from, as they will be on different subdomains), and it must also work with migrations.

I could add DB_CONNECTION=mysql_client1, DB_CONNECTION=mysql_client2 and so on, but that would give a lot of repetitive code and some maintenance when clients are created or removed. Could I maybe have an initial database and retrieve the client data from there or how would you solve this?

Jun
19
3 months ago
Activity icon

Replied to 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.

Activity icon

Replied to 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.

May
30
4 months ago
Activity icon

Replied to 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?

May
29
4 months ago
Activity icon

Replied to 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.

Activity icon

Replied to Sudden Error In Composer

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

Activity icon

Replied to Sudden Error In Composer

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

Still same error.

Activity icon

Replied to Sudden Error In Composer

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

Activity icon

Replied to Sudden Error In Composer

@MUNAZZIL - Unfortunately they both result in the same error

Activity icon

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.                         
Jan
11
9 months ago
Activity icon

Replied to Lock Column For Row

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

Activity icon

Replied to 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

Activity icon

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.

Dec
11
10 months ago
Activity icon

Replied to Run Artisan Command From Composer Post-update

I can see I can use PHPs readline()

Activity icon

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.

Nov
21
10 months ago
Activity icon

Replied to 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.

Activity icon

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.

Aug
08
1 year ago
Activity icon

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?

Jun
03
1 year ago
Activity icon

Replied to 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.

May
17
1 year ago
Activity icon

Replied to Hot Reloading Not Creating Any Files

That works completely differently?

Activity icon

Replied to 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.

May
16
1 year ago
Activity icon

Replied to Hot Reloading Not Creating Any Files

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

Activity icon

Replied to Hot Reloading Not Creating Any Files

They both work without problems

Activity icon

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');
May
01
1 year ago
Activity icon

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)

Apr
30
1 year ago
Activity icon

Replied to 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")));
Activity icon

Replied to 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")));
Activity icon

Replied to 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?

Uhmm.. Nevermind, I guess this will work, I will try it :-)

$default = config('db.strict');
Config::set('db.strict', false);
// SQL
Config::set('db.strict', $default);
Apr
29
1 year ago
Activity icon

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

Apr
16
1 year ago
Activity icon

Replied to 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

Activity icon

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?

Apr
15
1 year ago
Activity icon

Replied to Execute Code (last) On Every Page

@Cronix true, thanks.

I have implemented as this:

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

Replied to 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?

@Cronix exactly. But it's 50% there though :-)

Activity icon

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.

Apr
11
1 year ago
Activity icon

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.

Feb
20
1 year ago
Activity icon

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?

Feb
12
1 year ago
Activity icon

Replied to 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?

My mistake about the Ubuntu version, that refers to the Docker version. However still doesn't solve it.

Activity icon

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?

Dec
11
1 year ago
Activity icon

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.

I assume that attempts should increase or the job removed or something.

Nov
18
1 year ago
Activity icon

Replied to Testing In Laravel Doesn't Persist In Method

I found the error. Bummer. It was a 40

Nov
17
1 year ago
Activity icon

Replied to Testing In Laravel Doesn't Persist In Method

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

Activity icon

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?

Nov
10
1 year ago
Oct
23
1 year ago
Activity icon

Replied to GitLab Pipeline Failed

No problem :-)

Activity icon

Replied to GitLab Pipeline Failed

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

Oct
22
1 year ago
Activity icon

Replied to 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 :-)

Oct
21
1 year ago
Activity icon

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