hjortur17

hjortur17

Grindavík

Hire Me

Member Since 1 Year Ago

Experience Points 10,940
Experience
Level
Lessons Completed 88
Lessons
Completed
Best Reply Awards 0
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 Nov
1 month ago

hjortur17 left a reply on Google Gmail SMTP

@YUWIN - So I already tried going to into setting and allowed Less Secured Apps, but the link you provided works, so thank you!

hjortur17 left a reply on Google Gmail SMTP

@ARTHVRIAN - Yes it's Gsuite

10 Nov
1 month ago

hjortur17 left a reply on Google Gmail SMTP

The TLS didn't work :(

hjortur17 left a reply on Google Gmail SMTP

@CRONIX - May I ask what service you use?

hjortur17 left a reply on Google Gmail SMTP

@cronix this is what the log file says:

[2018-11-10 17:28:59] production.ERROR: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required " {"exception":"[object] (Swift_TransportException(code: 530): Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required " at /home/forge/default/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457) [stacktrace]

hjortur17 left a reply on Google Gmail SMTP

I've already allowed less secured apps to access accounts

hjortur17 left a reply on Google Gmail SMTP

Whoops, something went wrong on our servers.

hjortur17 started a new conversation Google Gmail SMTP

Hi, I'm trying to use Google Gmail SMTP to receive an ​email from my site, but I when I try to send email from the form I get 500 error. Can anybody help me figure this out :)

The .env file:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=MYPASSWORD
MAIL_ENCRYPTION=ssl

The ContactController

public function store(Request $request)
    {
        $this->validate(request(), [
                     'name' => 'required',
                     'email' => 'required|email',
                     'message' => 'required|min:20'
              ]);

              $data = array(
                'name' => request('name'),
                'email' => request('email'),
                'website' => request('website'),
                'bodyMessage' => request('message')
              );

              Mail::send('mails.contact', $data, function ($message) use ($data) {
                $message->from($data['email']);
                $message->to('[email protected]');
                $message->subject('New message from contact form');
              });

        return back()
                     ->with('flash', 'I will here from you soon!');
    }
23 Oct
1 month ago

hjortur17 left a reply on Unable To Deploy To Server

What do you mean?

hjortur17 left a reply on Unable To Deploy To Server

I can upload it, no problem, but still, Laravel Forge says We were unable to deploy to server

hjortur17 left a reply on Unable To Deploy To Server

This what I get:

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)

modified:   public/css/app.css
modified:   public/js/app.js

no changes added to commit (use "git add" and/or "git commit -a")

hjortur17 left a reply on Unable To Deploy To Server

Nope, only one branch

hjortur17 left a reply on Unable To Deploy To Server

On branch master Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

hjortur17 left a reply on Unable To Deploy To Server

I get this when I commit:

On branch master Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

hjortur17 left a reply on Unable To Deploy To Server

Done that, I do always do:

git add . git commit -m "message" git push

hjortur17 started a new conversation Unable To Deploy To Server

Hi, so I'm uploading my files to GitHub and Laravel Forge picks that up and works with it to display my website. But for some reasons, Laravel Forge is Unable to deploy to server, and when I try to git push, it says Already up to date. Does the same when I try to git pull. Can anyone help me with this one?

Here is the error message from the Laravel Forge dashboard:

Tue Oct 23 14:09:56 UTC 2018
From github.com:hjortur17/nfs
 * branch            master     -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
    package-lock.json
    package.json
    public/css/app.css
    public/js/app.js
    resources/js/bootstrap.js
Please, commit your changes or stash them before you can merge.
Aborting
Updating 90d1692..325c61b

Thanks again!

hjortur17 left a reply on Just Published My Laravel Project And Vue Is Not Working

Just needed to run npm install

hjortur17 started a new conversation Just Published My Laravel Project And Vue Is Not Working

Hi, I just published my Laravel project (nfs.is) and everything works except Vue. It's just printing out the tag for the component, not the template which is in it. Please help!

The error from Safari:

[Error] [Vue warn]: Unknown custom element: <avatar-form> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

22 Oct
1 month ago

hjortur17 left a reply on Vue Is Not Defined

Figured that out! Thank you. I need this in my file:

window.App = {!! json_encode([ 'csrfToken' => csrf_token(), 'user' => Auth::user(), 'signedIn' => Auth::check() ]) !!};

hjortur17 left a reply on Vue Is Not Defined

Yes like this, with Laravel Blade

{{ $profileUser->name }}

{{ '@' . $profileUser->username }}

hjortur17 left a reply on Vue Is Not Defined

@D9705996 Could you help me with something? I'm trying to create the autherize function but I'm getting a error when trying to use user.

Here is the error message from chrome:

[Vue warn]: Error in render: "TypeError: Cannot read property 'user' of undefined" found in

---> at resources/js/components/AvatarForm.vue

Here is how the AvatarForm.vue file looks like:

            <form v-if="canUpdate" method="POST" enctype="multipart/form-data">
                <div class="file">
                    <label class="file-label">
                        <input class="file-input" type="file" name="avatar">
                        <span class="file-cta">
                            <span class="file-icon">
                                <i class="fas fa-upload"></i>
                            </span>
                            <span class="file-label">
                                Choose a file…
                            </span>
                        </span>
                    </label>
                </div>

                <button type="submit">Senda inn</button>
            </form>
        </div>
    </div>
    <p class="m10t">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
        consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
        cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
        proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
</div>

export default { props: ['user'],
    data() {
        return {
            avatar: ''
        }
    },

    computed: {
        canUpdate() {
            return this.authorize(user => user.id === this.user.id)
        }
    }
}

hjortur17 left a reply on Vue Is Not Defined

That worked! Thank you!

hjortur17 left a reply on Vue Is Not Defined

Thanks! @D9705996 that got the terminal start running, but still chrome is giving my the same error message

app.js:24924 Uncaught ReferenceError: vue is not defined at Object.VERSION (app.js:24924) at webpack_require (app.js:20) at Object. (app.js:24862) at webpack_require (app.js:20) at Object. (app.js:24847) at webpack_require (app.js:20) at app.js:63 at app.js:66

hjortur17 started a new conversation Vue Is Not Defined

Hi, I'm trying to use Vue with my Laravel application. But I get a error message.

This is the error message from terminal:

95% emitting                                                                      

 ERROR  Failed to compile with 1 errors                                                                                                18:28:03

 error  in ./resources/js/components/AvatarForm.vue

(Emitted value instead of an instance of Error) 
  Error compiling template:
  
  <div class="floating-image-box">
    <div class="box">
        <img :src="avatar">
        
        <form v-if="canUpdate" method="POST" enctype="multipart/form-data">
            <div class="file">
                <label class="file-label">
                    <input class="file-input" type="file" name="avatar">
                    <span class="file-cta">
                        <span class="file-icon">
                            <i class="fas fa-upload"></i>
                        </span>
                        <span class="file-label">
                            Choose a file…
                        </span>
                    </span>
                </label>
            </div>
  
            <button type="submit">Senda inn</button>
        </form>
    </div>
  </div>
  <p class="m10t">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  </p>
  
  - Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.


 @ ./resources/js/components/AvatarForm.vue 6:23-260
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js ./resources/sass/app.scss

And this is from Chrome:

Uncaught ReferenceError: vue is not defined
        at Object.VERSION (app.js:24900)
        at __webpack_require__ (app.js:20)
        at Object.<anonymous> (app.js:24862)
        at __webpack_require__ (app.js:20)
        at Object.<anonymous> (app.js:24847)
        at __webpack_require__ (app.js:20)
        at app.js:63
        at app.js:66

I added this to my bootstrap.js file:

window.Vue = require('vue');

vue.prototype.authorize = function(handler) {
    let user = window.App.user;

    return user ? handler(user) : false;
}; 

This is my app.js file:

require('./bootstrap');

window.Vue = require('vue');

Vue.component('avatar-form', require('./components/AvatarForm.vue'));

const app = new Vue({
    el: '#app'
});

And this is my AvatarForm.vue file:

<template>
    <div class="floating-image-box">
        <div class="box">
            <img :src="avatar">
            
            <form v-if="canUpdate" method="POST" enctype="multipart/form-data">
                <div class="file">
                    <label class="file-label">
                        <input class="file-input" type="file" name="avatar">
                        <span class="file-cta">
                            <span class="file-icon">
                                <i class="fas fa-upload"></i>
                            </span>
                            <span class="file-label">
                                Choose a file…
                            </span>
                        </span>
                    </label>
                </div>

                <button type="submit">Senda inn</button>
            </form>
        </div>
    </div>
    <p class="m10t">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
        consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
        cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
        proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
</template>

<script>
    export default {
        props: ['user'],

        data() {
            return {
                avatar: ''
            }
        },

        computed: {
            canUpdate() {
                return this.authorize(user => user.id === this.user.id)
            }
        }
    }
</script>

hjortur17 left a reply on UserPolicy

@lostdreamer_nl I figured it out! Thanks for letting me know of the log file! I just needed to run composer update in my terminal!

hjortur17 left a reply on UserPolicy

Okay, here you go:

[2018-10-22 15:28:04] local.ERROR: ReflectionFunction::__construct() expects parameter 1 to be string, array given (View: /Users/hjorturfreyrlarusson/website/nfs/resources/views/profiles/show.blade.php) {"exception":"[object] (ErrorException(code: 0): ReflectionFunction::__construct() expects parameter 1 to be string, array given (View: /Users/hjorturfreyrlarusson/website/nfs/resources/views/profiles/show.blade.php) at /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php:387, Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): ReflectionFunction::__construct() expects parameter 1 to be string, array given at /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php:387) [stacktrace] #0 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(47): Illuminate\View\Engines\CompilerEngine->handleViewException(Object(Symfony\Component\Debug\Exception\FatalThrowableError), 1) #1 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/Users/hjorturf...', Array) #2 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\View\Engines\CompilerEngine->get('/Users/hjorturf...', Array) #3 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/View/View.php(125): Illuminate\View\View->getContents() #4 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/View/View.php(90): Illuminate\View\View->renderContents() #5 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Http/Response.php(42): Illuminate\View\View->render() #6 /Users/hjorturfreyrlarusson/website/nfs/vendor/symfony/http-foundation/Response.php(202): Illuminate\Http\Response->setContent(Object(Illuminate\View\View)) #7 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(747): Symfony\Component\HttpFoundation\Response->__construct(Object(Illuminate\View\View)) #8 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(719): Illuminate\Routing\Router::toResponse(Object(Illuminate\Http\Request), Object(Illuminate\View\View)) #9 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(679): Illuminate\Routing\Router->prepareResponse(Object(Illuminate\Http\Request), Object(Illuminate\View\View)) #10 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #11 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #12 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure)) #13 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #14 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #15 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure)) #16 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #17 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #18 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #19 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #20 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #21 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #22 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #23 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #24 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure)) #25 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #26 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #27 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure)) #28 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #29 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #30 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #31 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(656): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request)) #32 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(622): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route)) #33 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(611): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #34 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #35 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request)) #36 /Users/hjorturfreyrlarusson/website/nfs/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #37 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure)) #38 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #39 /Users/hjorturfreyrlarusson/website/nfs/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #40 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure)) #41 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #42 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #43 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure)) #44 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #45 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #46 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure)) #47 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #48 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #49 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure)) #50 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #51 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #52 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure)) #53 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #54 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #55 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #56 /Users/hjorturfreyrlarusson/website/nfs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #57 /Users/hjorturfreyrlarusson/website/nfs/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #58 /Users/hjorturfreyrlarusson/.composer/vendor/laravel/valet/server.php(147): require('/Users/hjorturf...') #59 {main} "}

hjortur17 left a reply on UserPolicy

Okay @lostdreamer_nl , what are you talking about the "Full stack trace from your log file?"

But here is my show.blade.php file

@extends ('layouts.profiles')

@section ('header')
    <section id="profile">
        <header id="profile-header" class="has-background-image" style="background-image: url('/css/img/nature.jpg');">
            <div id="icon-left-corner">
                <a href="/"><i class="fal fa-home"></i></a>
            </div>
            <div id="icon-right-corner">
                @if (Auth::id() === $profileUser->id)
                    <a title="Útskrá" href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit()">
                        <i class="fal fa-sign-out"></i>
                    </a>

                    <form id="logout-form" action="{{ route('logout') }}" method="POST">
                        @csrf
                    </form>
                @endif
            </div>
        </header>
        <div class="status-bar">
            <div class="container">
                <div class="columns">
                    <div class="column"></div>
                    <div class="column">
                        {{-- <div class="columns">
                            <div class="column has-text-centered">
                                <h4>Athugasemdir</h4>
                            </div>
                            <div class="column has-text-centered">
                                <h4>Fylgir</h4>
                            </div>
                            <div class="column has-text-centered">
                                <h4>Fylgendur</h4>
                            </div>
                            <div class="column has-text-centered">
                                <h4>Likes</h4>
                            </div>
                        </div> --}}
                    </div>
                    <div class="column">
                        @if (Auth::id() === $profileUser->id)
                            <a href="#" class="is-button is-right">Stillingar</a>
                        @endif
                        {{-- <a href="#" class="is-button is-right">Fylgja</a> --}}
                    </div>
                </div>
            </div>
        </div>
        <div class="container m5t">
            <div class="columns">
                <div class="column is-4">
                    <div class="floating-image-box">
                        <div class="box">
                            <img src="/css/img/profiles/default.png">
                            @can ('update', $profileUser)
                                ADD FORM HERE
                            @endcan
                        </div>
                    </div>
                    <p class="m10t">
                        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                        consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                        cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                        proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                    </p>
                </div>
                <div class="column">
                    <h1 class="section-title">{{ $profileUser->name }}</h1>
                    <p class="username">{{ '@' . $profileUser->username }}</p>
                </div>
            </div>
        </div>
    </section>
@endsection

hjortur17 started a new conversation UserPolicy

Hi, i'm having trouble update-ing the signedInUser. Does anyone have idea why I'm getting this error message:

ReflectionFunction::__construct() expects parameter 1 to be string, array given (View: /Users/hjorturfreyrlarusson/website/nfs/resources/views/profiles/show.blade.php)

My UserPolicy looks like this:

/**
     * Determine whether the user can update the model.
     *
     * @param  \App\User  $user
     * @param  \App\User  $signedInUser
     * @return mixed
*/
public function update(User $user, User $signedInUser)
{
        return $signedInUser->id === $user->id;
}

My AuthServiceProvider looks like this:

protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
        'App\User' => 'App\Policies\UserPolicy',
];

My ProfilesController looks like this:

class ProfilesController extends Controller
{
    public function show(User $user)
    {
        return view('profiles.show', [
            'profileUser' => $user
        ]);
    }
}

My show.blade.php file looks like this:

@can ('update', $profileUser)
    ADD FORM HERE
@endcan
10 Oct
2 months ago

hjortur17 left a reply on Argument 1 Passed To App\Http\Controllers\RepliesController::store() Must Be An Instance Of App\Thread, String Given

Found out the problem, forgot to the $channelId in the store method.

public function store($channelId, Thread $thread) { $thread->addReply([ 'body' => request('body'), 'user_id' => auth()->id() ]);

          return back();
}
09 Oct
2 months ago

hjortur17 left a reply on Argument 1 Passed To App\Http\Controllers\RepliesController::store() Must Be An Instance Of App\Thread, String Given

Route::get('/frettir', '[email protected]')->name('threads'); // DISPLAYS ALL THREADS Route::get('/frettir/{channel}', '[email protected]'); // DISPLAYS ALL THREADS ASSOCIATED WITH A CHANNEL Route::get('/frettir/{channel}/{thread}', '[email protected]'); // SHOW A THREAD Route::post('/frettir/{channel}/{thread}/athugasemdir', '[email protected]'); // SHOW A THREAD

hjortur17 started a new conversation Argument 1 Passed To App\Http\Controllers\RepliesController::store() Must Be An Instance Of App\Thread, String Given

Hi, I'm trying to build a reply system into my Laravel application but I got an error.

Argument 1 passed to App\Http\Controllers\RepliesController::store() must be an instance of App\Thread, string given

Here is my code:

Form

<form method="POST" action="{{ $thread->path() . '/athugasemdir' }}">
            @csrf

            <div class="field">
                <textarea class="textarea" name="reply" rows="4" style="resize: none;"></textarea>
            </div>
            <div class="field has-text-right">
                <button class="is-button" type="submit" style="text-transform: uppercase;">Birta</button>
            </div>
        </form>

RepliesController

public function store(Thread $thread)
    {
              $thread->addReply([
                     'body' => request('body'),
                     'user_id' => auth()->id()
              ]);

              return back();
    }

Thread.php

public function replies()
    {
        return $this->hasMany(Reply::class)->orderBy('created_at', 'desc');
    }

    public function addReply($reply)
    {
        $this->replies()->create($reply);
    }

Reply.php

protected $guarded = [];
    
    public function owner()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
30 Sep
2 months ago

hjortur17 left a reply on Foreach Printing Twice The Same Content

I just removed one of the divs "tile is-child box"

hjortur17 started a new conversation Foreach Printing Twice The Same Content

Hi, I'm having trouble with my foreach loop. The loop print's every thread twice!

The Controller: ´´´ public function index() { $popular_threads = Thread::latest()->take(3)->get(); $threads = Thread::latest()->take(3)->get();

    return view('posts.index', compact('threads', 'popular_threads'));
}

´´´

The Blade file: ´´´

{{ $threads->first()->title}}

{{ $threads->first()->body }}

@foreach ($threads as $thread) @if (!$loop->first)

{{ $thread->title }}

{{ $thread->body }}

{{ $thread->title }}

{{ $thread->body }}

@endif @endforeach ´´´
23 Sep
2 months ago

hjortur17 left a reply on Guests_may_not_create_threads

Yeah

Routes

Route::get('/frettir', '[email protected]'); 
Route::post('/frettir', '[email protected]');
Route::get('/frettir/{thread}', '[email protected]'); 
Route::post('/frettir/{thread}/athugasemdir', '[email protected]'); 

Controller

public function index()
       {
              $threads = Thread::latest()->get();
              
              return view('threads.index', compact('threads'));
       }

public function store(Request $request)
       {
              $thread = Thread::create([
                     'title' => request('title'),
                     'body' => request('body'),
                     'user_id' => auth()->id()
              ]);

              return redirect($thread->path());
       }

public function show(Thread $thread)
       {
              return view('threads.show', compact('thread'));
       }

User Model

    protected $fillable = [
        'name', 'email', 'password',
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];

Thread Model

    protected $guarded = [];
    
    public function path()
    {
        return '/frettir/' . $this->id;
    }

    public function replies()
    {
        return $this->hasMany(Reply::class);
    }

    public function addReply($reply)
    {
        $this->replies()->create($reply);
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

hjortur17 left a reply on Guests_may_not_create_threads

Not sure, I just followed one of the tutorials. I'm just learning how to use the Test.

But now I'm getting another error.

Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: threads.user_id

hjortur17 started a new conversation Guests_may_not_create_threads

Hi, I'm having trouble getting me tests to run. It always respond with this:

Failed asserting that exception of type "Illuminate\Database\QueryException" matches expected exception "Illuminate\Auth\AuthenticationException". Message was: "SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: threads.user_id

And this is my code:


/** @test */
    function guests_may_not_create_threads()
    {
        $this->expectException('Illuminate\Auth\AuthenticationException');

        $thread = factory('App\Thread')->make();

        $this->post('/frettir', $thread->toArray());
    }
22 Aug
3 months ago

hjortur17 left a reply on Can't Write Image Data To Path

This was suppost to be like this:

$filename = time() . '.' . $image->getClientOriginalExtension();

hjortur17 started a new conversation Can't Write Image Data To Path

Hi, I'm trying to store images to the public folder, but it's telling me that I can't write image data to path. Please help! Here is my code:

if (request()->hasFile('image')) {
                     $image = request()->file('image');
                     $filename = time() . '.' . $image;
                     $path = public_path('images/' . $filename);

                     // if (!file_exists($path)) {
                     //        mkdir($path, 666, true);
                     // }

                     Image::make($image)->resize(128, 128)->encode('jpg', 75)->save($path);

                     Election::create([
                            'image' => $filename
                     ]);
              }
                        

I have tried to do chmod -R 777 public/images/ but that doesn't work

21 Aug
3 months ago

hjortur17 left a reply on Not Same Content On My Server And My Local Site

Thanks, guys. I was pushing to the wrong branch

hjortur17 left a reply on Not Same Content On My Server And My Local Site

And it's not in .gitignore file

hjortur17 left a reply on Not Same Content On My Server And My Local Site

Texts and some lines in app.scss

hjortur17 started a new conversation Not Same Content On My Server And My Local Site

Hi, I'm using Laravel Forge to upload my laravel project and when I push to Github the site changes. But I noticed that some content isn't the same online and on my local site. I've tried to push but GitHub says "Nothing to commit"

Any ideas how to fix this?

26 Jun
5 months ago

hjortur17 left a reply on Database Connections Error

Thanks, that worked!

hjortur17 started a new conversation Database Connections Error

Hi, so I'm trying to get data from my database but I'm getting the error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'portfolio.case_studies' doesn't exist (SQL: select * from case_studies order by created_at desc)

Here is my code:

HomeController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\CaseStudies;

class HomeController extends Controller
{
    public function index()
    {
        $cases = CaseStudies::latest()->get();

        return view('posts.index', compact('cases'));
    }
}

CreateCaseStudieTable

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class CaseStudies extends Model
{
    protected $guarded = [];

    public function path()
    {
         return '/case-studies/' . $this->id;
    }
}

CaseStudies.php

public function up()
    {
        Schema::create('case_studie', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->text('description');
            $table->timestamps();
        });
    }

hjortur17 left a reply on Laravel And Vue

So I'm trying to use this component: https://www.npmjs.com/package/vue-float-label

09 Jun
6 months ago

hjortur17 started a new conversation Laravel And Vue

I'm getting an error when trying to use Vue with Laravel.

RangeError: Maximum call stack size exceeded.
    get — app.js:39067
    Watcher — app.js:39051
    mountComponent — app.js:38715
    _init — app.js:40560
    Vue — app.js:40649
    (anonymous function) — app.js:13889
    __webpack_require__ — app.js:20
    (anonymous function) — app.js:13869
    __webpack_require__ — app.js:20
    (anonymous function) — app.js:63
    Global Code — app.js:64
    http://portfolio.test/js/bootstrap.js.map

You can see my code here:

require('./bootstrap');
window.Vue = require('vue');

import VueFloatLabel from 'vue-float-label'
Vue.use(VueFloatLabel)

Vue.component('float-label', require('./components/FloatLabelComponent.vue'));

const app = new Vue({
    el: '#app'
});
<template>
       <float-label>

       </float-label>
</template>

<script>
       import FloatLabel from 'vue-float-label/components/FloatLabel';

       export default {
              components: {
                     FloatLabel
              }
       }
</script>
<body>
    <div id="app">
        @yield ('header')

        @yield ('section1')

        @include ('partials.contact')
    </div>

    <script src="/js/app.js"></script>
</body>
30 May
6 months ago

hjortur17 left a reply on Mailtrap.io Error

Still getting the error message