EmilMoe

Software Engineer at Online

Hire Me

Experience

34,050

11 Best Reply Awards

  • Member Since 3 Years Ago
  • 163 Lessons Completed
  • 1 Favorite

3rd June, 2018

EmilMoe left a reply on GDPR - For Those Of You Building Apps With Laravel • 1 month ago

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

17th May, 2018

EmilMoe left a reply on Hot Reloading Not Creating Any Files • 2 months ago

That works completely differently?

EmilMoe left a reply on Hot Reloading Not Creating Any Files • 2 months ago

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.

16th May, 2018

EmilMoe left a reply on Hot Reloading Not Creating Any Files • 2 months ago

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

EmilMoe left a reply on Hot Reloading Not Creating Any Files • 2 months ago

They both work without problems

EmilMoe started a new conversation Hot Reloading Not Creating Any Files • 2 months ago

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');

1st May, 2018

EmilMoe started a new conversation Hot Reload Not Working In Windows (Chrome) • 2 months ago

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)

30th April, 2018

EmilMoe left a reply on STR_TO_DATE Always Returns NULL, But Only In Laravel • 2 months ago

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 • 2 months ago

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 • 2 months ago

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?

29th April, 2018

EmilMoe started a new conversation STR_TO_DATE Always Returns NULL, But Only In Laravel • 2 months ago

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

16th April, 2018

EmilMoe left a reply on Install Composer Package From Private Gitlab • 3 months ago

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 • 3 months ago

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?

15th April, 2018

EmilMoe left a reply on Execute Code (last) On Every Page • 3 months ago

@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 • 3 months ago

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 • 3 months ago

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.

11th April, 2018

EmilMoe started a new conversation Hot Reload • 3 months ago

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.

20th February, 2018

EmilMoe started a new conversation API And Access Permission In Package • 5 months ago

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?

12th February, 2018

EmilMoe left a reply on Ubuntu And PHP 7.1 • 5 months ago

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 • 5 months ago

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?

11th December, 2017

EmilMoe started a new conversation Queue, Nothing Happens • 7 months ago

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.

18th November, 2017

EmilMoe left a reply on Testing In Laravel Doesn't Persist In Method • 8 months ago

I found the error. Bummer. It was a 40

17th November, 2017

EmilMoe left a reply on Testing In Laravel Doesn't Persist In Method • 8 months ago

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 • 8 months ago

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?

10th November, 2017

EmilMoe left a reply on Register Filesystem Disk From A Package Service Provider. • 8 months ago

What is registerConfigs?

23rd October, 2017

EmilMoe left a reply on GitLab Pipeline Failed • 8 months ago

No problem :-)

EmilMoe left a reply on GitLab Pipeline Failed • 8 months ago

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

22nd October, 2017

EmilMoe left a reply on GitLab Pipeline Failed • 8 months ago

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

21st October, 2017

EmilMoe started a new conversation GitLab Pipeline Failed • 9 months ago

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

15th October, 2017

EmilMoe left a reply on How To Add Relationship While Creating The Object? • 9 months ago

What more information do you need?

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

EmilMoe left a reply on How To Add Relationship While Creating The Object? • 9 months ago

Okay.. ?

EmilMoe started a new conversation How To Add Relationship While Creating The Object? • 9 months ago

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']));
    });
}

13th October, 2017

EmilMoe left a reply on Only And Except Doesn't Not Work With ResourceCollection • 9 months ago

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 • 9 months ago

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

12th October, 2017

EmilMoe left a reply on Only And Except Doesn't Not Work With ResourceCollection • 9 months ago

@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 • 9 months ago

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

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

11th October, 2017

EmilMoe started a new conversation Only And Except Doesn't Not Work With ResourceCollection • 9 months ago

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 ▼
~~~~

27th September, 2017

EmilMoe left a reply on Vue Packages Version Mismatch • 9 months ago

It takes time to update a huge old project

EmilMoe started a new conversation Vue Packages Version Mismatch • 9 months ago

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.

26th September, 2017

EmilMoe left a reply on Compile JavaScript To IE11 (ES5?) • 9 months ago

I see, thanks !

EmilMoe left a reply on Compile JavaScript To IE11 (ES5?) • 9 months ago

Someone else must have hit this problem?

EmilMoe started a new conversation Compile JavaScript To IE11 (ES5?) • 9 months ago

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?

18th September, 2017

EmilMoe started a new conversation NPM To Work In IE • 10 months ago

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?

4th September, 2017

EmilMoe started a new conversation Update Prop With Lodash • 10 months ago

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)"
~~~~

EmilMoe started a new conversation Prop Update When Value Updated • 10 months ago

I have this piece of code I wanna use to connect 2 components with each other:

    methods: {
        bind(property, value = null) {
            if (! value)
                return _.get(this.bindings, property, null)

            _.set(this.bindings, property, value)
        }
    }
~~~~

It works very well for the sender that emits an event:

~~~~
@update="bind('some.property', $event.value)
~~~~

However for the receiving property it doesn't work so well, I have tried this:

~~~~
:counter="bind('some.property')"
~~~~

But it just sticks with the initial `null`.

Normally a component will have an `$on` listener for these things, but I don't want to tighten it up with events.

Do you have any suggestions how I can bind the `:counter` and prevent it's tight coupled?

30th August, 2017

EmilMoe left a reply on Upgrade To 5.5 Failed On Server • 10 months ago

Turned out PHP7.0 wasn't activated.

EmilMoe left a reply on Upgrade To 5.5 Failed On Server • 10 months ago

I also tried to delete all in the sub folders to storage/framework and everything in bootstrap/cache.

Then I ran composer du and php artisan cache:clear and composer install

Still fails.

EmilMoe started a new conversation Upgrade To 5.5 Failed On Server • 10 months ago

I upgraded to Laravel 5.5, but it fails on my server. I'm running Debian 9.0 with PHP7.0

[Wed Aug 30 14:32:09.730972 2017] [:error] [pid 23514] [client ***:51692] PHP Parse error:  syntax error, unexpected '?' in /var/www/***/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233, referer: http://***/

Any ideas what is going wrong here? I tried removing the vendor folder and install again, but same error. Works fine on my local computer.

4th July, 2017

EmilMoe left a reply on NPM Run Dev Error • 1 year ago

I failed completely to see it was above all these messages and the chunk names information.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.