Gerard

Junior Full-Stack Developer at Oh! my brand

Experience

17,600

8 Best Reply Awards

  • Member Since 2 Years Ago
  • 118 Lessons Completed
  • 6 Favorites

9th May, 2017

Gerard left a reply on Error On Vagrant Ssh In Homestead, User Directory With Whitespaces • 1 year ago

@ediblemanager Seems more like a vagrant/homestead issue with whitespaces.

@clay Yeah, the issue remains.

Gerard left a reply on Error On Vagrant Ssh In Homestead, User Directory With Whitespaces • 1 year ago

@ediblemanager

$ homestead ssh -vvv
vagrant: no version found in package vv

Gerard started a new conversation Error On Vagrant Ssh In Homestead, User Directory With Whitespaces • 1 year ago

I did a fresh Vagrant/Virtualbox/Homestead installation in a coworkers PC.

His computer user account is his full name, so the user directory looks like: C:/Users/John Doe/.

homestead up it's ok, but when I run homestead ssh the path seems to get cutted at some point and it breaks.

$ homestead ssh
Warning: Identity file C:/Users/John not accessible: No such file or directory.
bash: Doe/Homestead/.vagrant/machines/homestead-7/virtualbox/private_key: No such file or directory

Has anyone encountered this problem?

23rd March, 2017

Gerard left a reply on Cross-env Not Found On Npm Run Dev • 1 year ago

Thanks @Stretsh! I finally got it to work changing my package.json scripts to yours.

2nd February, 2017

Gerard left a reply on Laravel 5.3 - Using Mailable Inside A Notification • 1 year ago

Thanks! I was assuming that a mailable should work via notification and I was scratching my head to find out why it wasn't sending the mail.

31st January, 2017

Gerard left a reply on Reset Password Not Working Laravel 5.3 • 1 year ago

Something similar happening to me, after sending the form it returns back with no errors. I haven't overwritten any method.

30th January, 2017

Gerard left a reply on My Props Not Working In Vue 2.1.10 & Laravel 5.3 • 1 year ago

Well... I suppose that this is just an example:

<widget-settings :title="title" :count="count" :articles="articles" inline-template>

but in reality is something like:

<widget-settings :title="{{ $title }}" :count="{{ $articles->count() }}" :articles="{{ $articles}}" inline-template>

Anyway, what's the meaning of use vue props in a blade template? Have you tried using .vue files instead of coding your component template directly in the blade template?

15th November, 2016

Gerard left a reply on Gulp/NPM/Elixir Error On Windows • 1 year ago

@balistikbill Can you show your gulpfile.js?

Gerard left a reply on Laracasts Refresh • 1 year ago

@JeffreyWay On discussions general view, the posts are not showing the real latest user who commented.

Site Feedback • 18 seconds ago by JeffreyWay • Updated

Gerard left a reply on Laracasts Refresh • 1 year ago

I'm not sure if that's intended, but the notifications "sidebar" has 100% window height but isn't really a sidebar, because it gets stuck at the top if you scroll down the page.

@JeffreyWay You quoted me some minutes ago and the notification says 6 hours ago. Some issue related with timezones, I suppose.

Gerard left a reply on Laracasts Refresh • 1 year ago

@JeffreyWay Also, the notifications button on top of the profile pic in the dropdown is a little buggy, hover detection doesn't work all the time, and if you click the icon that open/close the notifications sidebar a couple of times, the next time you click it the sidebar opens and closes again without another click. Firefox, Windows 10, not tested on other browsers.

Gerard left a reply on Laracasts Refresh • 1 year ago

I also miss pagination buttons at the beginning of the posts

Gerard left a reply on Laracasts Refresh • 1 year ago

@JeffreyWay When I edit my profile, the Country Flag is selected by default to United States, not to my already before saved country.

Gerard left a reply on Laracasts Refresh • 1 year ago

Amazing! I love specially the new profile page.

25th October, 2016

Gerard started a new conversation Webpack Not Really Compiling All The Time During Gulp Watch • 1 year ago

I'm working with Vue, Laravel and Elixir, compiling with Webpack.

Most of the time gulp watch works correctly, but sometimes it shows the logs like if it is compiling but in reality is not doing anything, so I got stuck trying to resolve javascript errors which are already solved.

I have a javascript error on the browser console, I lose 2 hours trying to resolve it while gulp watch it's supposed to be compiling every change on my .vue file (without any syntax errors on the gulp console). Then I cancel gulp watch and run a simple gulp and the error is gone! Because webpack seems to not compile while it's watching!

It's not that gulp watch doesn't work on my project, it works most of the time, but sometimes it says that is watching for changes but it really isn't.

24th October, 2016

Gerard started a new conversation Can I Override In Any Way The Default Laravel Vue Instance? • 1 year ago

I have problems with event handlers because in a specific page I have the default main Vue instance plus a new instance.

I have a main <div id="app"></div> wrapper (because in Vue 2.0 you can't attach el to the body tag) and the default Laravel Vue instance is:

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

Event handlers works inside this instance, but the methods that I want to use exist in the new instance that I created on the page. I want the new instance to have the same el as the default instance: el: '#app'. But then event handlers doesn't work anymore, they just doesn't trigger.

When I do console.log(app) I don't receive a Vue instance, I receive my html wrapper div, I don't know why.

So in order to can fire event handlers, I need a unique Vue instance, and the default Vue instance should be there. Can I "override" or "extends" the default Vue instance instead of create a new one? I want to attach data and methods to the instance only in a specific view, in my blade template.

Oh, I don't want to use components for this specific case.

19th October, 2016

23rd September, 2016

Gerard started a new conversation Blade: Unescaped Brackets Inside Escaped Brackets • 2 years ago

I need to echo a PHP variable in blade inside an escaped brackets for Vue.js:

selected="@{{ center.id == {{$lesson->center_id}} }}"

But that's not possible, right? Should I use php tags in replacement of blade brackets on these cases?

selected="@{{ center.id == <?php echo $lesson->center_id; ?> }}"

Here is the full code:

<select name="center" id="center" v-model="center" v-bind:class="{'has-error': request.center}">
    <option v-for="center in centers" value="@{{ center.id }}" selected="@{{ center.id == {{$lesson->center_id}} }}">
        @{{ center.name }}
    </option>
</select>

21st September, 2016

Gerard left a reply on Laravel API Update Endpoint And Vue Resource • 2 years ago

@nate.a.johnson Thanks Nate, the problem was that the network entry was empty, without status code and without response.

It was a problem with the submit event missing preventDefault(), the page was reloaded before the request has finished. The listener should be @submit="updateCenter($event, {{ $center->id }})".

Also, the controller update method needs to be fixed:

public function update(UpdateCenterRequest $request, Center $center)
    {
        $center->update( $request->all() );
        $center->save();

        return $center;
    }
```

Gerard started a new conversation Laravel API Update Endpoint And Vue Resource • 2 years ago

I'm not sure if I'm doing something wrong, but on my update request the item is updated but I don't receive any status code from the request, so Vue.js triggers the request error callback .

Here is the code:

Controller method

public function update(UpdateCenterRequest $request, Center $center)
    {
        $center->update( $request->all() );
        
        return $center->save();
    }
app = new Vue({
            el: 'body',

            data: {
                name: '',
                address: '',
                request: ''
            },

            methods: {
                updateCenter: function(center){
                    this.$http.put('/api/centers/'+center,{
                        name: this.name,
                        address: this.address
                    }).then((response) => {
                        console.log('Success');
                        window.location = '/centers/'+center;
                    }, (response) => {
                        console.log('Error');   // I'm getting this, even when the item has been updated in the database
                        this.$set('request', response.data);
                    });
                }
            }
        });

triggered from

<form class="half-width" @submit="updateCenter({{ $center->id }})">

16th September, 2016

Gerard left a reply on Homestead Code Directory Not Syncing • 2 years ago

Same here, I recently installed phpmyadmin on my VM and linked the folders on my homestead.yaml, but the folder is empty on my computer, but not in the VM linked folder.

21st August, 2016

Gerard left a reply on Setlocale() For Carbon FormatLocalized() Not Working • 2 years ago

@vapenation This only works for the diffForHumans() method :(

Gerard started a new conversation Setlocale() For Carbon FormatLocalized() Not Working • 2 years ago

As the Carbon docs says, this code should output the date in spanish:

$d = new Carbon\Carbon;
setlocale(LC_TIME, 'es_ES');
dd($d->now()->formatLocalized('%A %d %B %Y'));

But it's not being translated, the output remains in english. I'm using Laravel Homestead, so maybe the locale isn't installed.

on Linux If you have trouble with translations, check locales installed in your system (local and production). locale -a to list locales enabled. sudo locale-gen fr_FR.UTF-8 to install a new locale. sudo dpkg-reconfigure locales to publish all locale enabled. And reboot your system.

And effectively the locale es_ES isn't installed so I followed the instructions above in order to install it. To reboot the system I used homestead destroy and homestead up again, but when I enter to ssh again and run locale -a the new installed locale disappears again.

I tried everything I found, but nothing works. Some ideas?

14th August, 2016

Gerard left a reply on Check If ManyToMany Collection Contains The Authenticated User • 2 years ago

@pbelyaev Thanks, with that works :)

Gerard started a new conversation Check If ManyToMany Collection Contains The Authenticated User • 2 years ago

If I have a many to many relationship like this:

User.php

public function posts(){
        return $this->belongsToMany(Post::class);
}

Post.php

public function users(){
        return $this->belongsToMany(User::class);
}

Which could be the best way to check if Auth::user() is inside a given $post->users collection?

I tried something like this, but it doesn't seems to work:

$post = Post::find(1);

if ( $post->users->has( Auth::user() ) ) {
    return true;
}

10th August, 2016

Gerard left a reply on Foreach Of Empty Collection Still Enters • 2 years ago

@guc43 Doctor (the user) has many patients and Patient has many doctors, so the hasManyThrough realtionship is not applicable in this case.

Doctor.php (This is equivalent to the User model)

class Doctor extends Authenticatable
{
    public function patients(){
        return $this->belongsToMany(Patient::class);
    }
}

Patient.php

class Patient extends Model
{
    public function doctors(){
        return $this->belongsToMany(Doctor::class);
    }
}

Anamnesis.php

class Anamnesis extends Model
{
    public function patient(){
        return $this->belongsTo(Patient::class);
    }
}

Gerard left a reply on Foreach Of Empty Collection Still Enters • 2 years ago

@guc43 That's true, good point. With merge instead of push the problem disappears.

But if I have multiple anamneses records, the merge method may overwrite elements that I don't wish to be overwritten, or this only happen with completelly duplicate models?

Gerard started a new conversation Foreach Of Empty Collection Still Enters • 2 years ago

I'm getting this error on my view: Undefined property: Illuminate\Database\Eloquent\Collection::$patient

I have the following relationships: User belongsToMany Patient Patient belongsToMany User Patient hasMany Anamnesis Anamnesis belongsTo Patient

And I'm trying to get the 5 more recent anamneses related with the User.

routes.php

Route::get('/', function () {
    $latest_anamneses = new Illuminate\Database\Eloquent\Collection;
    foreach(Auth::user()->patients as $patient){
        $latest_anamneses->push($patient->anamneses);
    }
    $latest_anamneses = $latest_anamneses->sortBy('updated_at')->take(5);
    return view('home', compact('latest_anamneses') );
});

home.blade.php

@if( count($latest_anamneses) )
    <table class="table">
        <tbody>
            @foreach ($latest_anamneses as $anamnesis)
                <tr>
                    <td>{{ $anamnesis->patient->last_name }}, {{ $anamnesis->patient->first_name }}</td>
                    <td>{{ $anamnesis->updated_at }}</td>
                </tr>
            @endforeach
        </tbody>
    </table>
    <button>{{ trans('home.see-anamneses') }}</button>
@endif

Currently I have 0 anamneses on my database anamneses table, so the app should not enter in the foreach loop, but it enters and then breaks in $anamnesis->patient because the collection is empty and has no patient property.

What have I done wrong? Why it enters in the foreach loop if $latest_anamneses is empty?

dd($latest_anamneses)

Collection {#199 ▼
  #items: array:1 [▼
    0 => Collection {#209 ▼
      #items: []
    }
  ]
}

Seems like a collection of collections, but why?

28th July, 2016

Gerard left a reply on Form Routes In Laravel 5.2 • 2 years ago

Could you explain better?

Also you can install the Laravel Collective package in order to use the form facades.

Form::open(['action' => '[email protected]'])

Gerard left a reply on Artisan Crashes • 2 years ago

What happens if you open any of your project routes on the browser? It shows the same error?

Gerard left a reply on Collection Method Contains() Not Behaving As Expected • 2 years ago

Can you paste the result of echo $congregationlist?

13th June, 2016

Gerard left a reply on Why Does Jeffrey Way Not Advocate Loading Files From A CDN In Production? • 2 years ago

I think custom and specific site resources should be loaded from the server, but CDN's also has cache advantages for popular resources, right?

For example, I'm pretty sure that a lot of sites are using the same CDN for jquery or bootstrap resources. So if you use the same CDN for the same resources as other sites, then most of the users will already have this resources on its browser cache when they visit your site, I'm right?

6th June, 2016

Gerard started a new conversation Laracasts Site Popups Giving Me Problems • 2 years ago

When I open a lesson that I had already opened before, a popup appears asking if I want to resume the video from the last point or if I want to start again. That's okay, the problem that I have is that most of the times this popup appears and reappears in loop at a fast speed that makes fairly imposible to click it.

@JeffreyWay I have this problem since I registered in laracasts. I'm not sure if this maybe is a browser problem, I'm using an up to date Firefox version, but this is the only site where I have had problems like these.

Today I had this problem with the login popup too. And while I'm trying to post this, the Google reCAPTCHA popup has the same problem. That's weird.

Someone else has experimented these issues?

26th May, 2016

Gerard left a reply on Route Is Not Found • 2 years ago

There is no getLogout method in the default AuthController. Try with:

Route::get('auth/logout',  'Auth\[email protected]' );

Gerard left a reply on Create Authentification • 2 years ago

@mimou I can't see an 'admin/login' route in your code. You have it elsewhere?

Gerard left a reply on Create Authentification • 2 years ago

What's wrong with the default authentication for your purpose?

php artisan make:auth

14th May, 2016

Gerard left a reply on Can I Set An Attribute Inside An Accessor? • 2 years ago

@Snapey @Prez Okay, so it's much better for performance and clarity to only do this operation in user register() and update(). Is it that?

Gerard left a reply on Removing Certain Attributes From A Users Collection. • 2 years ago

@jsrosas Well.. I can't say much about optimization, but in this case your question is:

  • Who can filter a lots of data faster? A database query or a custom filter?

I think (but I'm not sure of it) that the database query should be faster.

Gerard left a reply on Removing Certain Attributes From A Users Collection. • 2 years ago

@jsrosas You have a controller function for each route, right? Then $users = User::all( ['id', 'name'] ); should work for you before passing $users to the view.

public function index(){
    $users = User::all( ['id', 'name'] );
    return view('users.index', compact('users'));
}
public function anotherRouteAction(){
    $users = User::all( ['id', 'name', 'address', 'phone'] );
    return view('users.index', compact('users'));
}

That's not what you want or do you need help to understand how it works?

Gerard left a reply on Removing Certain Attributes From A Users Collection. • 2 years ago

@jsrosas So you don't want it to be hidden, but you don't want it in the current collection? Then User::all() it's not the query you want in this case. Try with:

User::all( ['id', 'name'] )

The array works like a database SELECT, the query will return only the user attributes that you put into the array.

Gerard left a reply on Removing Certain Attributes From A Users Collection. • 2 years ago

@jsrosas I think your are looking for the $hidden array in your user model:

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

Gerard left a reply on Can I Set An Attribute Inside An Accessor? • 2 years ago

@Prez Why? It's so bad? :o

Should I do that only one time in user registration?

Gerard left a reply on Can I Set An Attribute Inside An Accessor? • 2 years ago

@Prez The doubt I had was about updating it inside the accessor, not from a controller, but the documentation hasn't an example for it ( I suppose that it's not an usual usage). Now using $this->save() works.

public function getProfilePictureAttribute(){
        if( empty($this->attributes['profile_picture']) ){
            $this->attributes['profile_picture'] = Gravatar::get($this->attributes['email']);
            $this->save();
        }
        return $this->attributes['profile_picture'];
    }

Thanks guys :)

Gerard left a reply on Can I Set An Attribute Inside An Accessor? • 2 years ago

@Prez Yes, an accessor, sorry for the mistake, I updated the title and the question :) I want to set an attribute inside its accessor.

@Snapey What would be the syntax? $this->save()?

Gerard started a new conversation Can I Set An Attribute Inside A Get Mutator? • 2 years ago

In my application users table has a profile_picture column. If the field is empty, I take a profile picture from gravatar, but I want set the user profile_picture to the retrieved URL in that case, avoiding an extra call to gravatar services.

Can I set an attribute inside a get mutator? How can I do that?

public function getProfilePictureAttribute(){
    if( empty($this->attributes['profile_picture']) ){
        $this->attributes['profile_picture'] = Gravatar::get($this->attributes['email']);
        return $this->attributes['profile_picture'];
    }else{
        return $this->attributes['profile_picture'];
    }
}

12th May, 2016

Gerard left a reply on Laravel Standards & Conventions Series? • 2 years ago

Yeah, this could be a great series. I usually find myself searching for Laravel conventions, especially when working in collaborative projects.

1st May, 2016

Gerard left a reply on How To Name Laravel 5.2 Auth Routes • 2 years ago

@heihachi88 It is not in the AuthController.php itself, it is in the Traits that it uses.

28th April, 2016

Gerard left a reply on Laravel 5.2 Routes Work Only On Root Directory • 2 years ago

@Sky93 Maybe a problem in your APP_URL on your config/app.php or in your .env file?

Gerard left a reply on Architecture For Menu • 2 years ago

  1. Create a Menu class
  2. Create a MenuItem class
  3. Menu class will have an array variable of MenuItem's
  4. Create a singleton instance of your Menu class in your ServiceProvider register() method.
  5. Add MenuItem's to the singleton instance on your packages ServiceProvider.
  6. Display the Menu class in your menu view.

Gerard left a reply on About Checkbox Value Attribute • 2 years ago

@d3xt3r So in my controller I will have to check if it is null, right?

Edit Your Profile
Update

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