Hawkleaf

Junior Web Developer at Pneunet & Pieter Smit Media

Experience

48,350

19 Best Reply Awards

  • Member Since 1 Year Ago
  • 348 Lessons Completed
  • 0 Favorites

17th November, 2017

Hawkleaf left a reply on Video Freezes Until Mouse Moved • 3 days ago

Is it just on Laracasts or are you having this problem on youtube and the like as well?

15th November, 2017

Hawkleaf left a reply on Route::view Dynamically Not Working • 5 days ago

It is recommended to use controllers and such, they provide much more features.

23rd October, 2017

Hawkleaf left a reply on The Visual Studio Code Thread • 4 weeks ago

@neovive Wow, thanks for the detailed explanation! I'm definitely going to be checking out vscode now!

Hawkleaf started a new conversation Uploaded Image Is Rotated When Uploaded Via Mobile • 4 weeks ago

I have this really weird issue where if one of my clients uploads an image from his phone it gets rotated.

I've done some research and stumbled upon a few threads mentioning some data that needs to be read from the image. I currently save the image like this:

public function store(StoreImageRequest $request)
    {
        $image = Image::create([
            'user_id' => auth()->id(),
            'attachable_id' => $request->attachable_id,
            'attachable_type' => $request->attachable_type,
            'path' => $request->file('image')->store('images', 'public'),
            'title' => $request->title,
        ]);

        return $this->setItem($image)->respond();
    }

What I need to do is check the image to see if that data is available and then rotate it depending on that. Does anyone have any experience with this kind of issue? I can't seem to find a simple solution to this problem myself.

Hawkleaf left a reply on The Visual Studio Code Thread • 4 weeks ago

@jlrdw lol that's quite the statement. I've been using netbeans for school and I can say for sure that wouldn't be able to associate Vscode with netbeans in any way.

What makes you dislike vscode tho?

Hawkleaf started a new conversation The Visual Studio Code Thread • 4 weeks ago

I figured someone would have to start talking about this sudden uprising of Visual studio code in the editor world. I've seen some podcasts go towards discussing it and I'd like to see how many people use it on the laracasts forum.

Do you use visual studio code? Why do you use it over any other editor of choice? If you'd have to give some advice to someone wanting to start using it for laravel/vue development, what would you say? (think about user settings and plugins for example)

10th October, 2017

Hawkleaf left a reply on Allow API Read Only From One Address/project? • 1 month ago

I recommend using passport too, I've been using it for my API and it works like a charm. It's a little hard to get into (As easy as @TaylorOtwell makes it look, it's hard to grasp for a beginner)

Have patience and thou shall prevail!

Hawkleaf left a reply on How To Go To A Profile On The List Using Axios With Dynamic IDs • 1 month ago

If you're a beginner I don't recommend using Quasar, I'm using it myself and I find I struggle a lot even after about a year of vue js experience.

I'd advice to build a regular laravel application first, or atleast completely finish the Vuecasts on this website. I guarantee you'll be able to build it if you do all the tutorials available here.

Why are you using quasar in the first place? You want to make an android app?

Hawkleaf left a reply on Template Balde To PDF • 1 month ago

Wrap your page in a div maybe?

4th October, 2017

Hawkleaf left a reply on Downloading An Excel Sheet Over An API • 1 month ago

I just found a nice library that helps with this, you can use downloadjs together with axios to download the file. Thanks for your time @36864

Hawkleaf started a new conversation Downloading An Excel Sheet Over An API • 1 month ago

Hey guys,

I'm currently developing a Quasar application that is connected to my API using passport. My client requested a feature where he wants to download an excel sheet from the server. I set it up so that it responds with response()->download('pathtofile');

However when I hit it I get an exception that route('login') is not defined. (I'm hitting it through an Iframe because I can't simply open it in a new tab)

Can I use axios to hit this endpoint? Or is there another solution?

28th September, 2017

Hawkleaf left a reply on Auth()->id() Doesn't Work; But If I Hardcode It, It Does • 1 month ago

Can you try it like so?

$data['user_id'] = auth()->id();
$data['rest of data'] = '';

Activity::create($data);

Hawkleaf left a reply on Laravel 4.2 Query To Database • 1 month ago

I believe you should use this:

DB::table('target table')->select(DB::raw('insert big query here'))->get();

Hawkleaf left a reply on How I Can Pass Variable On Javascript Html Object • 1 month ago

Everything between the {{}} is PHP, you won't be able to use your javascript variable there. You'd be better off just typing out the route url manually. Unless you have the id javascript variable available in your php, then you could

var $iframe=$('<object data="{{ route('browserview', $id) }}" width="100%" height="600px"></object>'); 

Hawkleaf left a reply on Auth()->id() Doesn't Work; But If I Hardcode It, It Does • 1 month ago

Are you using anything like passport? I used to have this issue as well. I believe I had to specify the auth guard to use. So that'd be 'api' or 'web' I think

Hawkleaf left a reply on Laravel Model Permanently Deleting Model(Events) • 1 month ago

I don't know of any such event, what you could do is run a check on the deleted_at column (there's also a property on the model that should indicate if it is already soft-deleted). Then you can proceed to completely delete the model if you desire.e

Hawkleaf left a reply on Auth()->id() Doesn't Work; But If I Hardcode It, It Does • 1 month ago

Is User_id fillable?

Hawkleaf left a reply on Dd Is Not Preformatted • 1 month ago

Do you have any chrome extensions that might mess with the tags? Also, see if it doesn't work in incognito

25th September, 2017

Hawkleaf left a reply on Laravel Forge: Class Not Found When Hitting An Endpoint • 1 month ago

Turns out it was indeed the typo. Weird that it didn't fail on my mac but failed on the server.

Thanks for your time!

24th September, 2017

Hawkleaf started a new conversation Laravel Forge: Class Not Found When Hitting An Endpoint • 1 month ago

I've recently deployed my API to forge and I'm getting a weird error. On bugsnag I get this error: https://puu.sh/xI0Jn/2192beaaf9.png

I can't make any sense of it, tests that use the class work fine locally. I can use them through my app locally too. I also have the correct configuration for loading the Api folder in my composer.json

It seems to be a production related issue, any ideas?

18th September, 2017

Hawkleaf left a reply on How To Start With Lumen And Vue? • 2 months ago

I feel like your best bet is still using Laravel, I don't know the specifics on what lumen has or not but you're not losing anything by choosing laravel, especially if you're building a traditional web app. If you are building just the API I would totally go for lumen.

You don't have to use vue router, you can just use traditional routing if you don't mind page reloads. I like using both blade and vue components.

VueX? Nah, don't really need it unless your application is going to be huge. If it is going to be huge I would still doubt really needing it.

I wouldn't know the answer to your last question but since it's Lumen specific using Laravel will be your best bet.

2nd September, 2017

Hawkleaf left a reply on Laravel Horizon Not Loading In Production, Showing 'Parse Error' In WaitTimeCalculator.php • 2 months ago

Might be worth checking the horizon github issue list to see if someone else has encountered this aswell, sounds like something you might want to create an issue for.

27th August, 2017

Hawkleaf left a reply on How Do I Use Route() With Vue? • 2 months ago

Take it a step further, use Ziggy!

https://github.com/tightenco/ziggy

23rd August, 2017

Hawkleaf left a reply on User Policy On User Model Not Working • 2 months ago

@ganicus Wow, been stuck on this for hours.... Thanks!

22nd August, 2017

Hawkleaf started a new conversation Testing Policies • 2 months ago

I'm currently building my Authorisation layer, I'm done setting up a test for my policy but it doesn't seem to work. I can't find where the issue lies.

First some setup,

I registered my Report model in my authserviceprovider to a ReportPolicy with this code:

{
    use HandlesAuthorization;

    public function before($user, $ability)
    {
        return $user->hasRole('admin', 'operator');
    }

    public function view(User $user, Report $report)
    {
        return $user->hasPermit('view', $report);
    }
}

This takes care of authorization for me, I have this concept of permits, I bind a resource to this with a polymorphic relation together with a keyword specifying their 'Action' which is now permitted, in this case viewing the model.

This is my test

    /** @test */
    public function a_user_with_a_permit_can_view_a_report()
    {
        $user = create(User::class);
        $report = create(Report::class);

        $this->be($user);

        $report->addPermit($user, 'view');

        $this->assertTrue($user->can('view', $report));
    }

And unfortunately it is returning false, All my other tests are unharmed, so it's an isolated case.

Any idea's?

21st August, 2017

Hawkleaf left a reply on SQL HY000 Error When Seeding Phpunit Tests • 2 months ago

thanks @alatui , saved my setup!

17th August, 2017

Hawkleaf left a reply on API Authorization On Models • 3 months ago

Ohh wow, everything is starting to fit together, thanks @Erik ! I didn't initially think about gates!

Hawkleaf started a new conversation API Authorization On Models • 3 months ago

Hello everyone,

I've been stubbing my toe during the planning of a feature in my current project.

Basically the project has a few different roles (Defined with spatie's laravel-permissions package).

Operators, Engineers and clients

Operator's can create projects for companies. The idea is that Operators then give project access to engineers, and view-only access to clients.

I have a simple API standing right now that allows me to get all the data I need, and building in role access for CRUD actions should be easy.

I can't seem to figure out how and where I should define access to certain models. With laravel-permissions you can make permissions but they seem to broad, I need to specify a specific model's ID.

As you can see it's all still quite chaotic, do you have any resources/articles or idea's that might enlighten me?

Thanks,

15th August, 2017

Hawkleaf left a reply on What Is A Complex/nasty Queue Related Situation You've Ever Faced? • 3 months ago

Might be silly, but maybe something like performance statistics? This can vary greatly per server but I'd love some indication of when to scale hardware up.

I haven't really had much experience using queue's but I can see myself using performance statistics for scaling my servers.

Hawkleaf left a reply on Deleting Notifications For A Deleted Model? • 3 months ago

I have no idea myself, I'd like to know the answer to this though as this sounds like something that would be pretty crucial.

Hawkleaf left a reply on Auth()->check() Inside Error Template • 3 months ago

Hmm, sounds like the AuthServiceProvider code hasn't run yet. Causing the user not to be logged in, atleast, the application doesn't know yet because it didn't get to check.

Why would you want to run abort in a service provider and then still have your application work?

9th August, 2017

Hawkleaf started a new conversation Vue Router Blank Page Using BeforeEnter • 3 months ago

I'm building an app with quasar and want to check on some routes if the user is logged in or not. If they are not they should be redirected to the login page. If they try to access the login page while logged in they should be redirected to the homepage. Right now it's working when I'm logged out, I visit '/home' and it redirects me. However, when I'm logged in it doesn't seem to work at all! I just get a blank page...

import Load from 'helpers/system/load-component';
import Vue from 'vue';
import VueRouter from 'vue-router';
import Auth from 'helpers/auth/auth';

Vue.use(VueRouter);

export default new VueRouter({
  routes: [{
      path: '',
      component: Load.layout('landing/main'),
      beforeEnter: (to, from, next) => {
        if (Auth.check()) {
          next('/home')
        } else {
          next()
        }
      },
      children: [{
        path: '/',
        name: 'login',
        component: Load.page('auth/create'),
      }, ],
    },
    {
      path: '',
      beforeEnter: (to, from, next) => {
        if (!Auth.check()) {
          next('/')
        } else {
          next()
        }
      },
      children: [{
        path: '',
        component: Load.layout('home/main'),
        children: [{
            path: '/home',
            name: 'home',
            component: Load.page('home/index'),
          },
          {
            path: '/audits',
            name: 'audits',
            component: Load.page('audits.index'),
          }
        ],
      }, ]
    }

  ],
});

7th August, 2017

Hawkleaf left a reply on Vue SPA Vs MPA/SSR • 3 months ago

I'd definately take @martinbean 's advice into account. If you are indeed in the environment where you could seperate your front and back-end I recommend using Quasar if you need other platforms aswell. Otherwise I'd just stick with one laravel app that uses standard blade views with vue components in them. If you want a SPA kind of feel you could always go with turbolinks.

Hawkleaf started a new conversation SVG's, Matter.js, Vuejs And Some Unexpected Behaviour... • 3 months ago

I'm currently working on a project where I have to create some objects in a 2d physics element to simulate balls falling down. I've got SVG's for the balls themselves and I've got some nice JS classes helping with the logic. However, I'm stuck at loading the SVG's into the DOM.

Check out this SVG: https://paste.laravel.io/bkg8p

If I load it into the browser directly from the .svg file it displays. Weirdly enough it isnt in the top left corner either. I received them from a client who saved them as .ai out of photoshop. I then used a simple converter to get them into SVG format, followed by the svgo converter

(https://github.com/svg/svgo)

data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgaWQ9InN2ZzIiCiAgIHZlcnNpb249IjEuMSI+PG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhOCI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczYiPjxjbGlwUGF0aAogICAgICAgaWQ9ImNsaXBQYXRoMTgiCiAgICAgICBjbGlwUGF0aFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHBhdGgKICAgICAgICAgaWQ9InBhdGgxNiIKICAgICAgICAgZD0iTSAwLDU5NS4yOCBIIDQxOS41MyBWIDAgSCAwIFoiIC8+PC9jbGlwUGF0aD48L2RlZnM+PGcKICAgICB0cmFuc2Zvcm09Im1hdHJpeCgxLjMzMzMzMzMsMCwwLC0xLjMzMzMzMz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.sh/x3O9K/6810120c08.png

I load them in like so:

<template lang="html">
  <div id="bingoBalls">
    <img v-for="i in 24" :src="path(i)" :id="i">
  </div>
</template>

<script>
export default {
  methods: {
    path(number) {
      return require('../../../../assets/images/balls/' + number + '.svg');
    }
  }
}
</script>

<style lang="stylus">
</style>

I'm dying from the inside trying to find out what I'm doing wrong, the SVG's should be fine...

Hawkleaf left a reply on Need Help With Routes • 3 months ago

Is the news stored in the database or in HTML files? If it's stored in HTML files you should go with the approach Stevenson posted.

If you are planning on putting it the database I'd suggest using the built-in pagination features of laravel.

https://laravel.com/docs/5.4/pagination

Hawkleaf left a reply on Tutorial Por Spark Vue Forms? • 3 months ago

To be honest I think your best bet is doing the Vue js tutorials right here at Vuecasts.com . He'll talk a lot about vue at first but then starts talking about forms and how to nicely tuck them away.

I just used the tutorials myself last week to get some nice JS classes in there for easy Axios forms!

I don't know about the Spark tie in but it should definitely help you understand.

2nd August, 2017

Hawkleaf left a reply on Eloquent Relations On Models With 2 Databases • 3 months ago

Ehh, I checked my git commits but I an't find anything useful except for the fact that I specified the connections on each model with the $connection property. Even if it is on your default connection, It's the only thing I can think of right now

27th July, 2017

Hawkleaf left a reply on Vee Validate, Why Is My Setup Not Working As Expected? • 3 months ago

Turns out the errors object is not passed with the methods. I ended up using one property that would contain a boolean and just passing through the errors for said input.

This has me typing both errors.has('fieldname') and errors.collect('fieldname') each time although it's the only way it works.

I might just send one prop through with an object of some sorts that contains the data, might be easier.

Hawkleaf started a new conversation Vee Validate, Why Is My Setup Not Working As Expected? • 3 months ago

Hello everyone,

I'm trying to create some abstract components form a Quasar app that I'm making. The form classes are mostly from jeffrey's series. Except I need my app to work offline, hence the reason I'm using Vee Validate and not just simply returning laravel's validation errors.

This is my current setup:

// Create.vue
<template lang="html">
  <div class="card width-2of3">
    <div class="card-content column group">
      <input v-model="form.email"
        placeholder="Email"
        v-validate="'required|email'"
        name="email">
      <validation-errors field-name="email" :form-errors="errors"></validation-errors>

      <input v-model="form.password"
        placeholder="********"
        v-validate="'required'"
        name="password"
        password>
      <validation-errors field-name="password" :form-errors="errors"></validation-errors>

      <button class="primary" @click="authenticate()">Log In</button>

    </div>
  </div>
</template>

<script>
import auth from 'helpers/auth/auth';
import Form from 'helpers/forms/form';

export default {
  data() {
    return {
      form: new Form({
        email: '',
        password: ''
      })
    }
  },
}
</script>

<style lang="css">
</style>

The validation-errors component:

// validationErrors.vue
<template lang="html">
  <div class="form-errors" v-if="formErrors.has(fieldName)">
    <span class="text-red" v-for="error in formErrors.collect(fieldName)"><i>error_outline</i> {{error.msg}} </span>
  </div>
</template>

<script>
export default {
  props: ['formErrors', 'fieldName']
}
</script>

<style lang="css">
</style>

In theory this should work, I'm properly giving it the errors and showing it based on the errors.

Any idea's? Am I missing something?

Ohh, here's the documentation for VeeValidate:

http://vee-validate.logaretm.com/

20th July, 2017

Hawkleaf left a reply on Get Pivot Data From Another Model As Query Scope. • 4 months ago

Ok i figured it out. Here's the solution i found:

I added these relations

class User 
{
    public function registers_with_credit()
    {
        return $this->belongsToMany(Register::class)
            ->withPivot('credit')
            ->withTimestamps();
            ->wherePivot('credit' ,1);
    }
class Register 
{
    public function users_with_credit()
    {
        return $this->belongsToMany(User::class)
            ->withPivot('credit')
            ->withTimestamps();
            ->wherePivot('credit' ,1);
    }

And then the query scope:

class Accreditation
{
    public function scopeWithCredit($query)
    {
        return $query
            ->has('user.registers_with_credit')
            ->has('register.users_with_credit');
    }

It's weird and very specific but maybe this will save someone a headache at some point.

Hawkleaf left a reply on Get Pivot Data From Another Model As Query Scope. • 4 months ago

This method on the Accreditation model is the closest i've come to what i want:

public function credit()
{
    return $this->user->registers
        ->where('id', $this->register_id)
        ->first()['pivot']['credit'];
}

But this can't be used as a query scope, only to filter an existing collection. This would work fine but it doesn't allow for pagination, unfortunately.

19th July, 2017

Hawkleaf left a reply on Get Pivot Data From Another Model As Query Scope. • 4 months ago

No that is a model that has an id of both other models. I don't have a model representing the pivot table. My pivot table is register_users and it has column called credit.

Now let's say it has a record like register_id = 1 user_id = 2 credit = 0

And i have a record in my accreditations table where register_id = 1 user_id = 2

I want to scope my query by the credit value of the pivot table.

Hawkleaf started a new conversation Get Pivot Data From Another Model As Query Scope. • 4 months ago

Hi everyone,

I'm struggling with a bit of an odd query. my models are as follows:

Register

  • belongsToMany Users withPivot 'credit'

Users

  • belongsToMany Registers withPivot 'credit'

Accreditation

  • belongsTo User
  • belongsTo Register

So i can access both ids from the Accreditation model.

I'm trying to make a query scope where only records with credit = 1 will show up. So far i managed to get it to work by making an extra method and filtering by that with Collections, but i'd really like to chain this with other query methods.

I would appreciate any suggestions.

17th July, 2017

Hawkleaf left a reply on Is Spark Is The Best Way To Start A Project? • 4 months ago

Let's not forget to mention the ability to learn from spark, if you need to implement it differently spark is maybe not a good starting point. If you want to find out how you can achieve a good starting point spark might be the resource.

I don't own spark myself but I've heard a lot of talk about the fact that you can learn a lot from just reading through it.

30th June, 2017

Hawkleaf left a reply on Isn't Using Blade Template A Bad Practice? • 4 months ago

Interesting viewpoint.

My personal experience is to base this off of your clients requirements. If they only require a simple web application or a webshop then using blade is fine! It isn't that much slower if it is at all. Basically I make a rest API for my projects if I feel the front-end requires some complex logic.

It is indeed easier to build an API for multiple environments to use at the same time, generally I build an API and use blade for page layout and giving data to my Vue components. Then my vue components interact with the API to prevent page loads and allow for said complex front-end logic.

If you are building a bigger infrastructure containing multiple apps I'd build a main API in laravel and hook em all up with Laravel Passport.

Disclaimer: I don't have that much practical experience with huge setups but I've seen projects where this structure worked perfectly fine.

Ohh and, I love blade either way.

29th June, 2017

Hawkleaf left a reply on Collect.js: Use Laravel Collections API In JavaScript. • 4 months ago

Great work, this makes my life much easier as I'm not really used to manipulating data with javascript.

Now it's not that much of an issue anymore ^^

I'd like to know the answer to @polarcubs question also, it doesn't matter that much but I do think it'd be interesting to know.

Hawkleaf left a reply on Laravel - Changing Object Attributes Not Working • 4 months ago

I assume you're changing the attributes of a model, if you want these changes to persist either pass an array to the update method with the properties you'd like to change or use the save method to persist the changes on the object itself.

if ($item->post_title == '') {
                $post = $this->findPostId($item);
                $item->post_title = $post->post_title;
                $item->url = $post->guid;
                $item->slug = $post->slug;
                $item->setAttribute('post_id', $post->ID);

        //Executes a query to save the changes to the database
        $item->save();
            } 

The changes won't be reflected if you change them without running save, otherwise eloquent would have to run a query each time a property changes.

28th June, 2017

Hawkleaf left a reply on Looping Through Custom Pagination Result Works Only For First Page Not The Other Page? • 4 months ago

Try using dd() at every line to see where the weird behaviour starts.

Hawkleaf left a reply on Vuejs Textarea Escaping Htmlchars Prefilled With Laravel • 4 months ago

You're setting the value of content by actually passing in the variable in the textarea with blade? I'm not sure if that way of passing through variables might be causing it.

If you are using components try passing it through via properties for more success.

Hawkleaf left a reply on Needing Your Thoughts On Adding And Removing Team Users In Spark • 4 months ago

If you dont like editing the source code then using the roles does sound kind of okay to me. It's not the best way to go about it but I feel you if that's a trade-off you wish to make.

I would just have the active role and leave the inactive role out, assuming that if there is no 'active' role present that the account is inactive anyway.

I haven't got any experience using spark so there might be an easier way of going about this. Not sure.

Edit Your Profile
Update

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