Buy your loved one the ultimate gift. Lifetime gift certificates are $100 off.

bobbybouwmann

Developer at Enrise

Experience

909,125

1083 Best Reply Awards

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

15th December, 2017

bobbybouwmann left a reply on Prevent Database Transaction Rollback In Listener? • 7 hours ago

Is this done by Laravel? I didn't know that! Or are you doing transactions by yourself?

Anyway, in this case you are using events and listeners. A good solution would be creating a separate listener that stores the token in the database for you. Or something that is done by the event before it fires the listeners.

bobbybouwmann left a reply on Relations In Model Or Controller • 7 hours ago

Let me know if I can help you with anything else ;)

bobbybouwmann left a reply on MorphsTo/morphOne Does Not Save The _id Column • 8 hours ago

In the create method you should pass in a new Action model instead of an array of items

 $this->actions()->create(new Action([
    'owner_id' => $request['owner_id'],
    'project_id' => $request['project_id'],
    'log_id' => $request['log_id'],
    'log_item_id' => $request['log_item_id'],
    'action' => $request['action'],
    'due_date' => $request['due_date'],
    'comments' => $request['comments'],
    'created_by' => $request['created_by']
]));

bobbybouwmann left a reply on Eloquent Query Is Pulling In A Ton Of Bogus Records • 8 hours ago

It looks like you're creating data while you are fetching it? It doesn't just magically change IDs!

Can you show a bit more code?

bobbybouwmann left a reply on Laravel Controllers: Extract Code/Logic Into Trait • 8 hours ago

Well you have three options here. Inheritance, traits or a specific class.

Inheritance: Use the BaseController class to store this method. Since the parent class has this method you can call this in any child class. This might be useful if you need to reuse this multiple times. For example an ApiController with a method responseSuccess

Trait: This is the option you are talking about. This can be a good solution for you. PHP will basically copy this method in your controller and you're done.

Specific class: This might fit your needs the most. You can create a specific class or service (PostService ) which can do this for you. The benefit of this is that you can reuse it through the whole application. A trait is more domain (controllers only) specific in my opinion.

All above options are valid options and it all depends on your needs and how big the project will be.

Let me know if I can do anything else for you ;)

bobbybouwmann left a reply on Consuming REST API In PHP With Guzzle • 8 hours ago

Session or database is fine. It depends on the livecycle of the token. Is it a temporary token then store it in the session. Is it a token you need to use the rest of the year? Store it in the database. Make sure you encrypt the token before you store it ;)

bobbybouwmann left a reply on Relations In Model Or Controller • 8 hours ago

The advantages of using the relationships is that Laravel is responsible for creating your queries. They are secured by default and it cleans up your code. I prefer to use relationships because they provide a natural code language. For example: the user has many posts. You know exactly what the relation is and how it's setup.

Creating your own queries, joins and so on might give you more control, but it also gives you more code which means more technical debt!

That's my 2 cents ;)

bobbybouwmann left a reply on Can Laravel 5.5 Horizon Use Controller Method Instead Of Closure? • 8 hours ago

As far as I know you should do this check in a service provider and not in your controller. You should simply return true or false and that's it.

What are you trying to do exactly?

12th December, 2017

bobbybouwmann left a reply on Error With Dropbox Api • 3 days ago

Laravel has this functionally build in in the form of FileSystem: https://laravel.com/docs/5.5/filesystem#retrieving-files

The example shows something about s3 but you can simply replace that with dropbox and it should give you access to your dropbox directory

bobbybouwmann left a reply on Manifest.json • 3 days ago

Great!

bobbybouwmann left a reply on Laravel Blade Check Whether Authenticated User Exists In Db • 3 days ago

@Snapey You are correct here, however the first state can be determined by Blade. In this case when you press one of the buttons you want to change I guess and perform an ajax call.

@Abhilash19 Can you explain your use case a bit more?

bobbybouwmann left a reply on Vue Template Not Rendering, No Errors • 3 days ago

Yea of course! Typo on my side! Anyway the context was the problem here :)

Glad I could help

bobbybouwmann left a reply on How Can I Manage To Get All Of The Foreign Key When Grouping Based On Code And Show In Data Table? • 3 days ago

You should not only group them by item_code, but also by id_supplier. This way you will get all suppliers that have that item code ;)

select * from catalog group by item_code, id_supplier;

bobbybouwmann left a reply on Laravel Blade Check Whether Authenticated User Exists In Db • 3 days ago

What do you want to check exactly?

bobbybouwmann left a reply on Vue Template Not Rendering, No Errors • 3 days ago

Aah I get what you mean! In this case you can't use this because the callback got it's own context. You can get around this by doing something like this

del(index) {
    let that = this;
    swal({
        title: "Are you sure?",
    }, function () {
        swal({
            title: "Deleted!",
            type: "success"
        }, function () {
            // axios.delete('/admin/permissions/' + id);
            
                    this.items.splice(index, 1);
        });
    });
},

11th December, 2017

bobbybouwmann left a reply on Manifest.json • 3 days ago

The manifest.json should be placed in your root directory. It will automatically be called by Laravel when you use {{ elixir('css/style.css') }} for example. On the background it will check where to find the correct file based on your laravel mix config.

If you have more questions let me know ;)

bobbybouwmann left a reply on Is It Normal For AJAX Requests To Be Slow On Homestead? • 3 days ago

It could be many things here. However your Homestead is a vagrant box. If you for example would enable NFS it would be a lot faster.

This might help you out: https://websanova.com/blog/laravel/speeding-up-homestead-on-windows-using-nfs

Note: the post is from 2015 so you might have some other files here but this is the basic idea

bobbybouwmann left a reply on Delete Gallery If Post Not Created • 3 days ago

I think your best solution here is using a command every night/week/month that cleans up the galleries that are not used anymore. That is an easy query to write which you can simply run to remove the old galleries.

bobbybouwmann left a reply on Cache Issue With Forge Auto-Deploy • 3 days ago

What php version is your server running?

It automatically reloads the FPM from php7.1, but if you run php7.0 or php5.6 you need to update that part of the deploy script

bobbybouwmann left a reply on Creating Child Table Relationships • 3 days ago

I think you need to follow this link: https://voyager.readme.io/docs/relationships

As far as I can see it's a basic relationship so you only need to set the models correctly

// Customer
public function address()
{
    return $this->hasOne(Address::class);
}

// Address
public function customer()
{
    return $this->belongsTo(Customer::class);
}

10th December, 2017

bobbybouwmann left a reply on API Routes Doesn't Work, Local Works Well. • 4 days ago

We need more information to help you out here.

bobbybouwmann left a reply on Vue Template Not Rendering, No Errors • 4 days ago

Aah great I could help!

Anyway if you want to delete an item from your "data" array you need use the this keyword. The this keyword points to the data array in your component.

this.items.slice(index, 1)

This should do it ;)

bobbybouwmann left a reply on Share Local Dev Site On Internet - Ngrok? • 4 days ago

Ngrok is indeed the one that you used. However vagrant also has a vagrant share command for this kind of stuff.

https://ngrok.com/ https://www.vagrantup.com/docs/share/

bobbybouwmann left a reply on Add Existing Digital Ocean To Forge • 4 days ago

Well, I don't think it's possible right now. Forge needs to install some items on the server to make deployments work correctly. It also needs to setup the correct directory structure, nginx config, etc. Your current setup is probably different from that from Forge and that makes it impossible right now.

My suggestion would be to create a new server and simply migrate everything to the new server ;) That's a max downtime of 5 min!

bobbybouwmann left a reply on Vue Template Not Rendering, No Errors • 4 days ago

Well your template isn't showing anything here

// This
<tr v-for="permission in items">
    <td>{{ items.name }}</td>
</tr>

// Should be this
<tr v-for="permission in items">
    <td>{{ permission.name }}</td>
</tr>

See the difference here in the variable name in your <td> element ;)

8th December, 2017

bobbybouwmann left a reply on Getting The Total Of Payments By Row • 6 days ago

Do you want to total of the payments or not? I'm not really sure...

Can you post your code here what you have so far? Maybe we can point you in the right direction?

bobbybouwmann left a reply on Laracasts Certification For College • 1 week ago

It's a good idea, but I don't think Jeffrey is going to put time into this!

What you can do is register for the Laravel Certification: https://laravel.com/certification/

bobbybouwmann left a reply on Saving Multiple Images • 1 week ago

If we look at your code we see that your $content->image call is called for every image. This means that it will override that. What you want here is a relationship between content and images. You can of course save it as an array in your database, but then you will have a hard time removing one image for example.

Here is an example with the relationship set up

$content->fill($this->getSafeInput($request));
$content->save();

if($request->hasFile('image')) {
    foreach($request->file('image') as $image) {
        $destinationPath = 'content_images/';
        $filename = $image->getClientOriginalName();
        $image->move($destinationPath, $filename);

        $image = new ContentImage([
            'path' => $filename,
        ]);

        $content->images()->save($image);
    }
}

Now that we have this working we also need to create the relationship. For the you need an extra table in your database and also an extra model.

// create_content_image_table

Schema::create('content_image', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('content_id')->unsigned();
    $table->string('path');
    $table->timestamps();
});

// Content.php

public function images()
{
    return $this->hasMany(ContentImage::class);
}

// ContentImage.php
public function content()
{
    return $this->belongsTo(Content::class);
}

For more information on relationships read this: https://laravel.com/docs/5.5/eloquent-relationships#one-to-many

Let me know if you have more questions ;)

bobbybouwmann left a reply on Is There A Package That Adds Repost (like Retweet, Reblog Or Facebook Share) Functionality? • 1 week ago

I think overtrue/laravel-follow is the best solution so far. Your requirements are really specific and I think you can better build this from scratch. If there is a package for this, it's either not maintained or it mega which gives you a lot of extra stuff you don't need!

If you have any other questions let me know ;)

bobbybouwmann left a reply on Error With Dropbox Api • 1 week ago

For Laravel you should follow this blog which makes it a lot easier for you!

https://murze.be/dropbox-will-turn-off-v1-of-their-api-soon-its-time-to-update-your-php-application

It uses a service provider which is cleaner for your code as well ;)

bobbybouwmann left a reply on Problems Installing Laravel-backup Extention • 1 week ago

You have this packages which requires the spatie/db-dumper package

"spatie/laravel-backup": "^3.0.0"

Instead of running composer require spatie/laravel-backup you need to run composer update spatie/laravel-backup since you already have the package installed ;)

bobbybouwmann left a reply on Logged Out After Register And Login In Laravel 5.5 • 1 week ago

What do the logs tell you know? As far as I know this should all just work fine!

7th December, 2017

bobbybouwmann left a reply on Logged Out After Register And Login In Laravel 5.5 • 1 week ago

You can't access the auth() method in your middleware. The session isn't started yet by the framework. If you would move that code to your index method it should work ;)

See here for more information: https://laravel-news.com/controller-construct-session-changes-in-laravel-5-3

This is also a nice discussion to read about this subject: https://github.com/laravel/framework/issues/15072

bobbybouwmann left a reply on Laravel, TDD And ExtDirect • 1 week ago

Cool stuff to work with! Well testing this doesn't have to be hard. You can always validate your request with your response. Once you give a request you always expect a certain response. Maybe a certain json structure or data that you expect. So in this case there is only one endpoint to test, but the structure of the requests and responses are different and can be tested here!

I have been playing with GraphQL and it has a similar approach. With GraphQL you simply tell the server what objects and what fields you want and the server needs to give that back to you. Of course you can go as deep as you want. Here is an example

// Request
{
    hero {
        name
        height
        mass
    }
}

// Response
{
    "hero": {
        "name": "Luke Skywalker",
        "height": 1.72,
        "mass": 77
    }
}

Anyway, back to the point. To test this you can simply replace the request and test the structure of the response. Or test that data in the response if you have a set of static values.

GraphQL: http://graphql.org/

bobbybouwmann left a reply on Google Smart Lock Takes Location And Password Input To Be Saved • 1 week ago

I think it has something to do with how you name your fields or the type you give them. Can you show us your form?

bobbybouwmann left a reply on Table - Sorting In Function Of Points • 1 week ago

You can use the groupBy method here from the collection

$liens = Liens::whereNotIn('id', function($query) {
    $query->select('liens_id')
        ->from('liens_user')
        ->where('user_id', '=', auth()->id());
}->get();

$liensGrouped = $liens->groupBy('points');
$liensArray = $liensGrouped->toArray();

Documentation https://laravel.com/docs/5.5/collections#method-groupby

bobbybouwmann left a reply on Illuminate \ Database \ QueryException (42S02) • 1 week ago

It says that the table doesn't exists... Did you create the table in your database. Normally you can do that by running

php artisan migrate

bobbybouwmann left a reply on Pass Multiple Javascript Objects To Laravel Controller Post Request Via AJAX • 1 week ago

Did you try to pass them as an array? So you have an array with objects that you post to the server?

6th December, 2017

bobbybouwmann left a reply on Bad Blade Performance On Huge Includes • 1 week ago

A 1000 templates seems to be a lot to me.. What are you rendering there? Just curious

bobbybouwmann left a reply on HttpFoundation\ParameterBag Not Found Http-foundation/Request • 1 week ago

Have you tried running composer update or removing your composer.lock file. It could be something in there!

bobbybouwmann left a reply on Error With Dropbox Api • 1 week ago

You need to update your package to a newer version. The league-flysystem-dropbox package is not maintained and updated.

If you did read the page the package you would have known this:

Flysystem Adapter for Dropbox [ABANDONED] replacement: https://packagist.org/packages/spatie/flysystem-dropbox

And there is your answer as well, the spatie/flysystem-dropbox is a perfect replacement for that package with good documentation ;)

bobbybouwmann left a reply on Torran Currency Converter Laravel Giving Error 'Call To A Member Function Get() On Null' • 1 week ago

It looks like it's trying to call get on the session, but the session is not available, see: https://github.com/Torann/laravel-currency/blob/514cca62a66699994b2b8fb285a61d7addb429f6/src/Middleware/CurrencyMiddleware.php#L52

Are you running this as an API endpoint? In that case you don't have sessions enabled in your Kernel.php which of course throws this error since there is no session at all.

bobbybouwmann left a reply on HttpFoundation\ParameterBag Not Found Http-foundation/Request • 1 week ago

Can you try to delete your vendor directory and run composer install again. That class is part of symfony and should always be there!

bobbybouwmann left a reply on Cross Origin Failing On DELETE Request • 1 week ago

What do you post to the server? Is that a POST request or a DELETE request?

bobbybouwmann left a reply on Laravel 5.5 Eloquent Cartesian • 1 week ago

You can chain your relations to achieve this.

For example

$results = PartBasePart::whereIn('id', array(1,2,3,4,5))
    ->with('materials.profiles')
    ->get();

This will fetch the profiles from the material model.

bobbybouwmann left a reply on Laravel Logout After Sending Information To Another Website • 1 week ago

Show your code please, your session is not automatically deleted as far as In know!

bobbybouwmann left a reply on RSS Feed For Laravel 5.2 • 1 week ago

You can install an older version of the package that does support PHP5.6. For example: https://packagist.org/packages/roumen/feed#v2.10.5

composer require roumen/feed:v2.10.5
Edit Your Profile
Update

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