Junior Web Developer at Pneunet & Pieter Smit Media



19 Best Reply Awards

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

18th September, 2017

Hawkleaf left a reply on How To Start With Lumen And Vue? • 6 days 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 • 3 weeks 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? • 4 weeks ago

Take it a step further, use Ziggy!


23rd August, 2017

Hawkleaf left a reply on User Policy On User Model Not Working • 1 month ago

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

22nd August, 2017

Hawkleaf started a new conversation Testing Policies • 1 month 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);


        $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 • 1 month ago

thanks @alatui , saved my setup!

17th August, 2017

Hawkleaf left a reply on API Authorization On Models • 1 month 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 • 1 month 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?


15th August, 2017

Hawkleaf left a reply on What Is A Complex/nasty Queue Related Situation You've Ever Faced? • 1 month 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? • 1 month 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 • 1 month 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 • 1 month 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';


export default new VueRouter({
  routes: [{
      path: '',
      component: Load.layout('landing/main'),
      beforeEnter: (to, from, next) => {
        if (Auth.check()) {
        } else {
      children: [{
        path: '/',
        name: 'login',
        component: Load.page('auth/create'),
      }, ],
      path: '',
      beforeEnter: (to, from, next) => {
        if (!Auth.check()) {
        } else {
      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 • 1 month 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... • 1 month 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



When I render them out on the page they are completely invisible, https://puu.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">

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

<style lang="stylus">

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 • 1 month 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.


Hawkleaf left a reply on Tutorial Por Spark Vue Forms? • 1 month 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 • 1 month 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? • 1 month 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? • 1 month 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"
      <validation-errors field-name="email" :form-errors="errors"></validation-errors>

      <input v-model="form.password"
      <validation-errors field-name="password" :form-errors="errors"></validation-errors>

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


import auth from 'helpers/auth/auth';
import Form from 'helpers/forms/form';

export default {
  data() {
    return {
      form: new Form({
        email: '',
        password: ''

<style lang="css">

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>

export default {
  props: ['formErrors', 'fieldName']

<style lang="css">

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:


20th July, 2017

Hawkleaf left a reply on Get Pivot Data From Another Model As Query Scope. • 2 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)
            ->wherePivot('credit' ,1);
class Register 
    public function users_with_credit()
        return $this->belongsToMany(User::class)
            ->wherePivot('credit' ,1);

And then the query scope:

class Accreditation
    public function scopeWithCredit($query)
        return $query

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. • 2 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)

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

Hi everyone,

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


  • belongsToMany Users withPivot 'credit'


  • belongsToMany Registers withPivot 'credit'


  • 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? • 2 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? • 2 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. • 2 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 • 2 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

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? • 2 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 • 2 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 • 2 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.

Hawkleaf left a reply on I Need A Route • 2 months ago

Don't we all?

All kidding aside though, Give us something to work with, what are you struggling with? ^^

Hawkleaf left a reply on Pagination • 2 months ago

Yeah exactly, If you're still using find() in your view that might mean you have to do something extra in your controller, like only load the languages you need

Hawkleaf left a reply on Spatie Permission Package Testing • 2 months ago

Well, please send us the code for the controller function and any other logic you're testing perhaps. It hurt to send us your setup for testing as well. (the test case you are extending for example)

Don't forget to do a series of dd()'s on the endpoint you're testing.

27th June, 2017

Hawkleaf left a reply on How Return HasOne The Model • 2 months ago

You can use it as a magic property!

class model {
public function user()
return $this->hasOne('App\Models\User');

public function render_html()
    return $someHtml;

//use it like this

I would advise you to look into presenters or blade templates to get rid of the render_html function on the model

Hawkleaf left a reply on Spatie Permission Package Testing • 2 months ago

What is the status variable in your session? Did you write something as an addition to the laravel Auth or something of the sort?

I'm curious as I don't see anything one two three that is wrong with your code ;-)

Hawkleaf left a reply on Laravel Conditional Nested Query • 2 months ago

If target_university is a foreign_key I'd suggest looking a bit more into the magic you can do using eloquent. Not only does it make your code more readable but it's also easier to write.

I'm not sure how the query would look but assuming sold_to_user is also a relation you can use this section of the documentation to kind of construct it.


26th June, 2017

Hawkleaf left a reply on Including Php Snippet In Blade • 2 months ago

I don't think the snippet from the blade file came through properly?

Hawkleaf left a reply on Eager Loading In Show Method • 2 months ago

You use a different method

public function show(Course $course)

        return view('course.single', compact('course'));

Hawkleaf left a reply on Function Does Not Exist • 2 months ago

Yeah or you could just pass the controller name and function as second parameter without the key value based array.

Route::get('home/login', '[email protected]');

Always check the documentation!


Hawkleaf left a reply on How I Can Read And Write User Details In Laravel 5.3 Passport • 2 months ago

If you are using passport you'll first have to login using passport itself, you can't just visit the url in the browser as this won't pass authentication.

Try using postman together with its oauth features to test your passport powered application.

Hawkleaf left a reply on Can You Reset The Attempts On A Job? • 2 months ago

Why would you want to reset the number of attempts?

23rd June, 2017

Hawkleaf left a reply on How To Load Huge Data In Html Table Using Laravel And Data Table • 3 months ago

@phpMick It's always good to expand further possibilities, his purpose is loading a large set of data without it weighing too much on loading times.

22nd June, 2017

Hawkleaf left a reply on How To Load Huge Data In Html Table Using Laravel And Data Table • 3 months ago

I feel you, loading loads of data is hard. Take a look at this debugbar, its widely used in the community as a handy tool for seeing what happens in the request:


If you ever decide to load relational data that comes from a booking do not forget to eager load said data.


If you feel at home in Javascript you could also use Vue Js to easily create and customize a table that loads as you scroll using your own API endpoint.

Good luck!

21st June, 2017

Hawkleaf left a reply on Excluding An Item And Prevent Another User From Borrowing It • 3 months ago

You can check if the user has an open application to block him from doing some stuff.

public function hasOpenApplication()
    //check if user has application that has not been approved or dissaproved

Then use that at places like deciding to show a button to book a car. Or you could go as far as writing a middleware that you can apply to certain endpoints a user with an open application shouldn't be able to access.

26th May, 2017

Hawkleaf left a reply on How To Auth With Laravel 5.4 • 3 months ago

@nmeri17 Are you using the standard scaffolded login form for your login? If not you probably forgot putting

{{ csrf_field() }} 

inside your form field. It is required for a form to be accepted and processed by laravel.

I do recommend you don't alter any source code, especially when you don't fully understand the framework yet. It only makes it harder to search for solutions as our problem becomes way too specific.

24th May, 2017

Hawkleaf left a reply on How To Auth With Laravel 5.4 • 4 months ago

I agree with @Snapey . Try a new installation and just take it slow like it says in the documentation.

Also, most of the things you are trying to do are covered in Jeffrey's laravel tutorials, according to your profile you haven't watched a single tutorial... A good way to start would be the Laravel From Scratch series.

Hawkleaf left a reply on Package Development How To Install Package Requirements • 4 months ago

composer install should work just fine. I recommend watching the "Laravel from Scratch" Series as Jeffrey slightly touches upon installing dependencies there.

Hawkleaf left a reply on MethodNotAllowedHttpException In RouteCollection.php Line 251 Only On Live Server • 4 months ago

You are making an AJAX call, is the route registered in api.php or web.php? It should work if you put it in api.php.

Hawkleaf left a reply on How To Secure API Endpoints For An App That Doesn't Have A Login? • 4 months ago

Like @gustav1105 said, setup some IP restrictions. I did the same thing for my laravel app. I didn't know how to use passport but I did want to leverage Vue with ajax functionality. I basically just hosted it locally without any API protection at all.

However I don't know if it's the safest thing ever as I'm not an expert when it's about security, though I think you should be fine if the information displayed in the app itself isn't very confidential.

Hawkleaf left a reply on How To Find The Insertion Of Which Row Fails In A Bulk Or Array Of Records Insert • 4 months ago

Depends, do you want to use the value in your code or do you want to use it for solving some issue? Mostly if a query fails it'll show on the error page which also contains the value's for said row.

Edit Your Profile

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