bobbybouwmann

Developer at Enrise

Experience

884,065

1046 Best Reply Awards

  • Member Since 3 Years Ago
  • 1066 Lessons Completed
  • 14 Favorites

10th October, 2017

bobbybouwmann left a reply on Angular 2 With Lumen • 1 week ago

I can't create an example for you. However you are asking for something that you need to learn first. Take it step by step. Create a normal application first and then move on to an API and separate front-end application.

bobbybouwmann left a reply on Eagerloading Not Working • 1 week ago

Can you spot the difference between the two relations?

public function monitors() 
{
    return $this->hasMany(Monitor::class,'domain_name','domain_name');
}

public function contacts()
{
    return $this->hasMany(Contact::class);
}

Note that the contacts relation doesn't have the second and third argument filled.

Check the docs for the correct values here: https://laravel.com/docs/5.5/eloquent-relationships#one-to-many

// Example from the docs
return $this->hasMany('App\Comment', 'foreign_key', 'local_key');

bobbybouwmann left a reply on Eager Loading OrderBy Not Working As Expected • 1 week ago

The order by is added only to the relation but not to the query of the end results. If you want to order your users by a certain field of a relation you need to use a join.

Laravel currently doesn't support this.

So if you want to know more about this it's wise to install the laravel debug bar and see which queries are created. You will see that each relation that is fetched has it's own query. You will get something like this

// The query depends on the relation
// I hope you get the idea

select * from users;
select * from roles where user_id in (1, 2, 3);
select * from tabs where role_id in (1, 2, 3);

Laravel will then combine everything into one collection for you

9th October, 2017

bobbybouwmann left a reply on How Best Way To Display The Sequence Number? • 1 week ago

Aah sorry I can't read!

I want to display the serial number of each row of data on two tables, and I want the number to start from one on each table, like the table below

You can simply do this

@foreach ($djs as $count => $dj)
    // Do your thing and echo the count here
    <td>{{ $count + 1 }}</td>
@endforeach 

@foreach ($users as $count => $user)
    // Do your thing and echo the number here
    <td>{{ $count + 1 }}</td>
@endforeach

Note that count starts with 0 since it will use the index of the array!

Let me know if this is what you want! Otherwise I need some more information

bobbybouwmann left a reply on Angular 2 With Lumen • 1 week ago

What have you tried so far?

Note that Lumen is intended for REST api's. So you simply need to provide an API with your Lumen application and create a separate Angular project that consumes this API.

bobbybouwmann left a reply on The Best Way To Display The Sequence Number? • 1 week ago

You can simply use a counter for this using PHP

<?php $number = 0; ?>

@foreach ($djs as $dj)
    // Do your thing and echo the number here
    <td>{{ $number }}</td>

    <?php $number++; ?>
@endforeach 

@foreach ($users as $user)
    // Do your thing and echo the number here
    <td>{{ $number }}</td>

    <?php $number++; ?>
@endforeach

bobbybouwmann left a reply on How To Integrate Facebook Instant Articles In Laravel? • 1 week ago

Not really sure what you mean with instant articles, but Facebook has a great API which you can use for almost anything!

This package can help you with that: https://github.com/SammyK/LaravelFacebookSdk

23rd August, 2017

bobbybouwmann left a reply on How Do I Require A Js File I Will Use Inside A Component? • 1 month ago

You need to include palette as a submodule in your Vue class. However not all javascript can just be included into a component.

import Pallette from 'path/to/pallette';

This only works if your pallette file is actually exporting something.

Can you explain your use case and intentions and what pallette.js is doing?

18th August, 2017

bobbybouwmann left a reply on Call To Undefined Method Illuminate\Database\Query\Builder::save() • 2 months ago

@birendragurung Because your relationship is incorrect.

bobbybouwmann left a reply on Call To Undefined Method Illuminate\Database\Query\Builder::save() • 2 months ago

@thomaskim That's not true, you can also call save on a belongsTo relationship, see the documentation!!

Documentation: https://laravel.com/docs/5.4/eloquent-relationships#the-save-method

bobbybouwmann left a reply on Laravel Homestead Mysq Take Too Much Time • 2 months ago

So for starters, this might have something to do with the amount of memory and CPU power you give the Homestead vagrant box.

Anyway, do you have an example of the query? Are you using indexes? This would speed it up a lot as well!

bobbybouwmann left a reply on Invalid Argument Supplied For Foreach() • 2 months ago

I have no clue what this code is doing. For starters I really don't understand the variables $a and $c. What information do they hold?

You were first talking about two foreach loops but now I see while loops..

bobbybouwmann left a reply on Is There A Newer Laracast Tutorial Version Of How To Upload Multiple Files Than The One Pasted In The Body Of This Question? • 2 months ago

There is no newer tutorial as far as I know. However the concepts used in that tutorial are still valid today.

bobbybouwmann left a reply on Call To Undefined Method Illuminate\Database\Query\Builder::save() • 2 months ago

You have the relation incorrect

A user HAS ONE address and a address BELONGS TO a user

// User.php
public function address()
{
    $this->hasOne(Address::class);
}

// Address.php
public function user()
{
    $this->belongsTo(User::class);
}

I suggest to read through the examples in the documentation again :)

bobbybouwmann left a reply on Why HTTP Redirect Not In Navigation Menu? • 2 months ago

I think they forgot to add it then.. I made a PR to fix this ;)

bobbybouwmann left a reply on Laravel 5.4 Rememeber Me Functionality • 2 months ago

What is the problem?

17th August, 2017

bobbybouwmann left a reply on Invalid Argument Supplied For Foreach() • 2 months ago

$i is the key of the previous array, which means it's not an array. You can only look over iteratables like arrays in a foreach loop

Can you tell us what you are trying to do? This looks really messy!

6th August, 2017

bobbybouwmann left a reply on Logs General Question • 2 months ago

@shez1983 Indeed, you can also use services like Sentry to do this kind of stuff ;)

bobbybouwmann left a reply on Logs General Question • 2 months ago

It's currently not an option but you could create a PR for it ;)

Also a log file can get pretty big in one day. The daily option is a good option for you ;)

bobbybouwmann left a reply on Laravel Can't Find Database Directory • 2 months ago

You have a string somewhere wrong. Could be your composer.json file. Can you search your codebase on the string atabase? You should find the mistake somehow!

bobbybouwmann left a reply on Logs General Question • 2 months ago

It depends on the config of your log. You have multiple options for this. You can find all of this in the documentation

Documentation: https://laravel.com/docs/5.4/errors#log-storage

31st July, 2017

bobbybouwmann left a reply on Using The Putfile Method To Save A Social Media Profile Image, Returning File Does Not Exist • 2 months ago

Did you import the correct File class? I can't see that from your code example!

bobbybouwmann left a reply on Config:cache Makes Functions In Config/helper.php Not Available • 2 months ago

Yes it is. When you cache your config, everything fill be parsed and compiled to one single file. This file can only be read by the framework and not executed, like your methods are.

This improves a lot of the speed, since it only needs to read one file instead of all your config files.

So if you want your helpers to be available you need to place them somewhere else.

What is the exact use case of using functions in your config files? I never had the need for that and could always use a helper.php file with separate functions in for example the app directory.

28th July, 2017

bobbybouwmann left a reply on Plucking Attributes When Counting Related Models • 2 months ago

Pluck doesn't work like that. You should use only here.

])->get()->only(['name', 'absence_count', 'currentabsence_count'])->toArray();

Pluck works best when you want to retrieve a name and an id for example for a select list

$list->pluck('name', 'id');

array:4 [
    12 => 'Donald Duck',
    14 => 'Dagobert Duck,
    // etc
]

24th July, 2017

bobbybouwmann left a reply on Trying To Update From 5.1.46 - 5.2.0 • 2 months ago

Did you read the error message? It looks like you are including two different versions of one dependency!

23rd July, 2017

bobbybouwmann left a reply on Laravel Mix Compiles In A Duplicate Path? • 2 months ago

Yeah you have to do that. I don't have any experience running a custom vagrant box which wasn't able to compile everything!

bobbybouwmann left a reply on Middleware Being Ignored On Api Controller • 2 months ago

Are you sure that middleware is hit? Have you tried turning off all other middlewares for that route so only that middleware is used? It could be that the request is already returned before it hits your middleware!

bobbybouwmann left a reply on I Cannot Publish Post After Adding TinyMCE Editor • 2 months ago

What error do you get? Show your controller as well!

bobbybouwmann left a reply on Laravel Forge Scheduler • 2 months ago

@amirhazz By running it every minute you can easily add any schedule calls to your application without changing the cronjob every time. You of course don't have to do that, but it's a low action for the server, if it can't find any jobs it will simply stop. No performance issues!

bobbybouwmann left a reply on Where Not? Exists This Method? Any Other Approach? • 2 months ago

where not is not a valid mysql call. You can use methods like whereNotIn($field, $values), but that is probably not what you want.

So instead of using where not you can use the opposite of it. Something like this.

$results = User::whereNot(function($query) use ($column) {
    $query->whereIsNull($column)
});

What is the exact query you want to perform?

bobbybouwmann left a reply on Laravel Mix Compiles In A Duplicate Path? • 2 months ago

Are you compiling it in your vagrant(Homestead) box? It looks like that is the problem. You can also compile it outside your box on your host machine. This is also a lot faster ;)

bobbybouwmann left a reply on TypeError: Cannot Read Property 'hasOwnProperty' • 2 months ago

Did you read the error message

Cannot read property 'hasOwnProperty' of undefined

This means that this.errors is not defined. Are you sure this.errors has a value? Or a default value?

bobbybouwmann left a reply on Trying To Update From 5.1.46 - 5.2.0 • 2 months ago

Well the error is pretty clear

laravelcollective/html v5.1.10 requires illuminate/support 5.1.* -> satisfiable by laravel/framework[v5.1.46]

This means when you update Laravel 5.1 to Larafvel 5.2 that you also need to update the laravelcollective/html package to 5.2!

13th July, 2017

bobbybouwmann left a reply on Delete Request Using Guzzle In Laravel Not Working • 3 months ago

What is the error?

11th July, 2017

bobbybouwmann left a reply on Uh-Oh Declined • 3 months ago

Dude seriously? Did you try to contact Jeffrey via de contact page? He usually responds within 48 hours!

9th July, 2017

bobbybouwmann left a reply on Order By • 3 months ago

Please show me what you already tried.

bobbybouwmann left a reply on Getting Null Instead Of Original String From Database. • 3 months ago

Is the activation_token column fillable in your User model?

bobbybouwmann left a reply on Order By • 3 months ago

I can tell you how to do it, but you are not gonna learn from it! Did you watch the following FREE series?

https://laracasts.com/series/laravel-from-scratch-2017

bobbybouwmann left a reply on How To Break Method Chaining? • 3 months ago

Yes, Exactly! Very good example as well!

bobbybouwmann left a reply on Checking If File Exists • 3 months ago

The Storage facade uses the storage that is active in your config files (config/filesystems.php). Note that this defaults to local. The root path is set for each storage option. In the case of local it's pointing to storage/app out of my head.

So it's not possible to retrieve a file with Storage that is not in your project without weird hacks!

bobbybouwmann left a reply on Order By • 3 months ago

This is what you need to do

// routes
Route::get('shop/{category_url}', '[email protected]');
// in your view use this url
example.com/shop/{category_url}?sort="asc"
example.com/shop/{category_url}?sort="desc"

The way you display the sorting urls depends on how you have setup your project, that is up to you!

bobbybouwmann left a reply on How To Break Method Chaining? • 3 months ago

Yes, and they are called exceptions! Instead of letting your code throw random errors you should control your own errors.

Something like this should do

// app/UpdateItem.php

public function checkIfSalesvalueEqual()
{
    // Do your thing here
    // If this fails throw a new exception
    throw new App\Exceptions\SalesNotEqualException();
}

// app/Exceptions/SalesNotEqualException.php
<?php

namespace App\Exceptions\NavigationService;

use Exception;

class SalesNotEqualException extends Exception
{
    // This class can be empty
}

// app/Http/Controllers/UpdateItemController.php

public function updateItem($id)
{
    try {
        return UpdateItem::perform()
            ->setFoundation($this->item, $this->order)
            ->getSaleById($id)
            ->validateRequest()
            ->mould()
            ->checkIfSalesvalueEqual()
            ->resetAndResubmit()
            ->response();
    } catch (App\Exceptions\SalesNotEqualException $e) {
        // Do what you want to do here
        // In your case:
        
        return back();
    }
}

bobbybouwmann left a reply on Prevent Show Duplicate Value In V-for • 3 months ago

It's not an error right? It's just displaying the item twice because it exists multiple times in the data.

In VueJS you can simply filter the results using a computed property

// Sample.Vue

<template>

    <div>

        <p v-for="comment in comments" v-text="comment"></p>

    </div>

</template>

<script>
    export {
        data() {
            return {
                comments: [
                    'test comment',
                    'test comment 2',
                    'test comment',
                ],
            }
        },

        computed: {
            sortedComments() {
                return = this.comments.filter(function(comment, position) {
                    return this.comments.indexOf(comment)  == position; 
                });
            }
        }
    }
</script>

bobbybouwmann left a reply on Making Route With "?" Arguments In $_GET Array • 3 months ago

You can simply create a route and pass data to it. Based on the key values it will either match the route parameters or add them as a query string

Route::get('/posts')->name('posts.index');

$url = route('posts.index', ['param1' => 1, 'param2' => 2];
// example.com/posts?param1=1&param2=2

7th July, 2017

bobbybouwmann left a reply on Orderby Issue • 3 months ago

You can also take this a bit further and make the field changeable. Checkout this video: https://laracasts.com/lessons/sorting-tabular-data

bobbybouwmann left a reply on Orderby Issue • 3 months ago

You url should look like this

<a href="http://localhost/myshop/public/shop/{{$category['url']}}?sort=asc">
    low to high
</a> 

Now you can simply get the request value and sort by the value in your url

 $sort = $request->get('sort', null);

$products = Product::when($sort, function ($Squery) use ($sort) {
    $Squery->orderBy('price', $sort);
})->get();

bobbybouwmann left a reply on Uh-Oh Declined • 3 months ago

If you have problems you can send a support ticket on this page: https://laracasts.com/contact

Edit Your Profile
Update

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