EmilMoe

Software Engineer at Online

Hire Me

Experience

33,770

11 Best Reply Awards

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

16th April, 2018

EmilMoe left a reply on Install Composer Package From Private Gitlab • 1 week 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 • 1 week 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 • 1 week 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 • 1 week 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 • 1 week 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 • 1 week 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 • 2 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 • 2 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 • 2 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 • 4 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 • 5 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 • 5 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 • 5 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. • 5 months ago

What is registerConfigs?

23rd October, 2017

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

No problem :-)

EmilMoe left a reply on GitLab Pipeline Failed • 6 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 • 6 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 • 6 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? • 6 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? • 6 months ago

Okay.. ?

EmilMoe started a new conversation How To Add Relationship While Creating The Object? • 6 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 • 6 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 • 6 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 • 6 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 • 6 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 • 6 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 • 6 months ago

It takes time to update a huge old project

EmilMoe started a new conversation Vue Packages Version Mismatch • 6 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?) • 6 months ago

I see, thanks !

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

Someone else must have hit this problem?

EmilMoe started a new conversation Compile JavaScript To IE11 (ES5?) • 6 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 • 7 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 • 7 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 • 7 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 • 7 months ago

Turned out PHP7.0 wasn't activated.

EmilMoe left a reply on Upgrade To 5.5 Failed On Server • 7 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 • 7 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 • 9 months ago

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

EmilMoe started a new conversation NPM Run Dev Error • 9 months ago

I get an error when running this and I'm pretty sure I have an error in one of my Vue files, however it seems to me that npm run dev doesn't explain where the error occurs like gulp did?

npm ERR! Linux 4.9.0-3-amd64
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "development"
npm ERR! node v6.11.0
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @ development script 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs 
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/project/npm-debug.log

npm ERR! Linux 4.9.0-3-amd64
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.11.0
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev script 'npm run development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs 
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/project/npm-debug.log

21st June, 2017

EmilMoe left a reply on :style="{'box-shadow': BoxShadow}" Is Ignored • 10 months ago

Fixed it. The ; messed it up:

'0 0 10px 0 rgba(0,0,0,0.05)

EmilMoe left a reply on :style="{'box-shadow': BoxShadow}" Is Ignored • 10 months ago

@Snapey That's in a .vue component file

20th June, 2017

EmilMoe started a new conversation :style="{'box-shadow': BoxShadow}" Is Ignored • 10 months ago

I have a strange error regarding box-shadow. It's completely ignored in the output where it should have been set to '0 0 10px 0 rgba(0,0,0,0.05);'.

Are there any restrictions on the styles I set?

:style="{
    'background-color': color,
    'box-shadow': boxShadow,
    'color': fontColor
}">

9th June, 2017

EmilMoe left a reply on Npm Run Dev, Not Output Files, Fresh Installation • 10 months ago

I had node_modules symlinket, that caused the troubles.

EmilMoe left a reply on How Can I Change Md5 Passwords To Bcrypt In Laravel 5.4? • 10 months ago

There's a login event, maybe you can catch the password there: https://laravel.com/docs/5.4/authentication#events

EmilMoe left a reply on How Can I Change Md5 Passwords To Bcrypt In Laravel 5.4? • 10 months ago

You mean this?

$user = User::where('username' => $username)->where('md5_password', md5($password)->firstOrFail();

$user->update(['bcrypt_password' => Hash::make($password)]);

EmilMoe left a reply on Npm Run Dev, Not Output Files, Fresh Installation • 10 months ago

If I add gibberish to webpack.mix.js it doesn't complain, it's like that file is never loaded.

EmilMoe left a reply on How Can I Change Md5 Passwords To Bcrypt In Laravel 5.4? • 10 months ago

@alexhiggins sure you can, or bruteforce with rainbow tables, but not really a reliable solution.

@sufuninja if understand you correct you need to bcrypt the origin value. Normally you would ask every user to change password.

EmilMoe left a reply on How Can I Change Md5 Passwords To Bcrypt In Laravel 5.4? • 10 months ago

What do you mean? You can't convert a hash to another hash

EmilMoe started a new conversation Npm Run Dev, Not Output Files, Fresh Installation • 10 months ago

I'm trying to do npm run dev on a fresh installation, but it doesn't handle my scss and js files, what can possible be wrong? Nothing is outputtet to the public folder.

 DONE  Compiled successfully in 76ms                                                                                                                                                         11:08:11 PM
                                                                                                                                                                                                       Asset      Size  Chunks             Chunk Names
mix-manifest.json  26 bytes          [emitted]
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')
    .version()
    .sourceMaps();
Edit Your Profile
Update

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