manelgavalda

manelgavalda

Developer at Cyber-Duck

Member Since 2 Years Ago

Roquetes

Experience Points
237,560
Total
Experience

2,440 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1491
Lessons
Completed
Best Reply Awards
135
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 48
237,560 XP
Sep
28
4 weeks ago
Activity icon

Commented on Comments Component

You can also use $this->post->refresh() to re-hydrate the Post model using fresh data from the database.

Docs: https://laravel.com/docs/8.x/eloquent#retrieving-models

Sep
15
1 month ago
Activity icon

Replied to Form Request Cannot Be Sent Using POST.

I think the /{user} route is overwriting your /create route, you need to change the order:

Route::prefix('users')->group(function () {
        Route::get('/', '[email protected]')->name('admin.users');
        Route::get('/{user}', '[email protected]_user')->name('admin.users.view');
        Route::post('/create', '[email protected]_user')->name('admin.users.create');
        Route::post('/{user}/edit', '[email protected]_user')->name('admin.users.edit');
        Route::post('/{user}/delete', '[email protected]_user')->name('admin.users.delete');
});
Sep
13
1 month ago
Activity icon

Awarded Best Reply on Add A Global Method To All Eloquent Models.

  • You can create another model class with your method inside.
  • Then extend the eloquent model class from it.
  • And finally let all your models extend your custom model class.
// Your custom model.
<?php

namespace App;

use Illuminate\Database\Eloquent\Model as EloquentModel;

class Model extends EloquentModel
{
    public function customMethod()
    {
        //
    }
}

Your models

<?php

namespace App;

class ExampleModel extends Model
{
}
Sep
11
1 month ago
Activity icon

Replied to How To Assert Paginations In Laravel?

I would create 2 categories, and then just make sure that you can only see the first one (because the pagination):

$category1 = factory(Category::class)->create();

$category2 = factory(Category::class)->create();

$response = $this->get(route('categories.index'));

$response
	->assertSee($category1->name)
        ->assertDontSee($category2->name);

Just updated the example with categories.

Sep
10
1 month ago
Activity icon

Awarded Best Reply on PDOExcetion('Could Not Find Driver')

I think you just need to install the dbaldriver now:

composer update
composer require doctrine/dbal
Sep
05
1 month ago
Activity icon

Replied to MIgration Issue

That's weird. I just copied the code, and it's working for me, which MySql version are you using?

Activity icon

Replied to MIgration Issue

You changed the 2 lines and you still have the same problem?

Activity icon

Replied to MIgration Issue

Hey, you have a typo on ->refrences in the 2 foreign lines:

 $table->foreign('contact_user_id')->references('id')->on('contact_users');
Sep
04
1 month ago
Activity icon

Replied to User In Laravel Controllers

Hey, If you want to eager load the relationships everywhere, I would suggest using the $with property in your User model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    /**
     * The relationships that should always be loaded.
     *
     * @var array
     */
    protected $with = ['author'];

    /**
     * Get the author that wrote the book.
     */
    public function author()
    {
        return $this->belongsTo('App\Author');
    }
}

Docs: https://laravel.com/docs/7.x/eloquent-relationships#eager-loading

Sep
02
1 month ago
Activity icon

Replied to PDOExcetion('Could Not Find Driver')

I think you just need to install the dbaldriver now:

composer update
composer require doctrine/dbal
Activity icon

Replied to PDOExcetion('Could Not Find Driver')

Are you sure you have the mysql_pdo driver installed? Check your extensions file and make sure that it isn't commented and that it's installed. In your php.ini:

extension=php_pdo_mysql.dll
Activity icon

Replied to Problem With PHPUnit + SQLite DropColumn()

Is the configuration inside .env.testing/.env correct?

Activity icon

Replied to PDOExcetion('Could Not Find Driver')

Hey, maybe you are missing the dbal driver:

composer require doctrine/dbal
Aug
31
1 month ago
Activity icon

Awarded Best Reply on Difference Between Session::get And {!!

I understand now. The redirect with and the view with, don't do the same.

  • The redirect with puts the variable in the session.
  • The view with passes the variable to the view.

You have some options here. Instead of passing the variable to the view, you can put it in the session, so the redirect and the view will work :

// Passing to session and returning the view.
session(['param1' => $param1]);

return view('Page1');
// Passing to session and redirecting.
return Redirect::back()->with('Param1', $Param1);

Then in your javascript access it like:

var Param1={!! Session::get("Param1") ?? '' !!};
Activity icon

Replied to Question About Subsciption

You keep the access for the rest of the month.

Activity icon

Replied to Difference Between Session::get And {!!

I understand now. The redirect with and the view with, don't do the same.

  • The redirect with puts the variable in the session.
  • The view with passes the variable to the view.

You have some options here. Instead of passing the variable to the view, you can put it in the session, so the redirect and the view will work :

// Passing to session and returning the view.
session(['param1' => $param1]);

return view('Page1');
// Passing to session and redirecting.
return Redirect::back()->with('Param1', $Param1);

Then in your javascript access it like:

var Param1={!! Session::get("Param1") ?? '' !!};
Activity icon

Replied to Difference Between Session::get And {!!

Hey, with passes the variable to the view, not to the session, that's why the first option works.

You can also use this to access the variable in your javascript:

var Param1 = @json($Param1);
Aug
15
2 months ago
Activity icon

Replied to How To Prevent Trimming Of Spaces While Creating A Record In Db

That's weird, I don't really know what else to do then, sorry.

Activity icon

Replied to How To Prevent Trimming Of Spaces While Creating A Record In Db

You should put the name of the attribute in this array. In case you don't want to trim the name of the user:

protected $except = [
    'name'
];
Activity icon

Replied to How To Prevent Trimming Of Spaces While Creating A Record In Db

Hey, in the TrimStringsmiddleware there's a property $exceptwhere you can add all the fields you want to save without being trimmed. If you want to do this for all the fields you can remove the TrimStrings middleware from Http/Kernel.

Aug
13
2 months ago
Activity icon

Awarded Best Reply on Download Laracast Videos

Hey skino, Yeah sure, you have a Download button on the episode link page, just right to the Watchlist button.

Activity icon

Replied to Download Laracast Videos

Hey skino, Yeah sure, you have a Download button on the episode link page, just right to the Watchlist button.

Jul
20
3 months ago
Activity icon

Awarded Best Reply on Dynamically Generated Nav Dropdown

One option is to use View Composers, so you only need to define the variable you want to share once.

public function compose(View $view)
{
    $view->with('categories', $this->categories);
}

Docs: https://laravel.com/docs/7.x/views#view-composers

Activity icon

Replied to Dynamically Generated Nav Dropdown

One option is to use View Composers, so you only need to define the variable you want to share once.

public function compose(View $view)
{
    $view->with('categories', $this->categories);
}

Docs: https://laravel.com/docs/7.x/views#view-composers

Jul
17
3 months ago
Activity icon

Awarded Best Reply on In Which File To Write Application Routes

Normally you would use the web.php file. If you just want api routes (to use with axios for example) you can use the api.php file. It's just a matter of organizing routes you can visit the RouteServiceProvider to see the differences between the files.

Activity icon

Replied to In Which File To Write Application Routes

Normally you would use the web.php file. If you just want api routes (to use with axios for example) you can use the api.php file. It's just a matter of organizing routes you can visit the RouteServiceProvider to see the differences between the files.

Jul
16
3 months ago
Activity icon

Awarded Best Reply on Laravel Notifications - Exists In Database, But Not In Auth()->user()->notifications

You call the relation 2 times so maybe the second time you call it, it gets the cached collection, maybe if you get the fresh model it will work:

    $this->assertCount(1, auth()->user()->fresh()->notifications); // not working
Activity icon

Replied to Laravel Notifications - Exists In Database, But Not In Auth()->user()->notifications

You call the relation 2 times so maybe the second time you call it, it gets the cached collection, maybe if you get the fresh model it will work:

    $this->assertCount(1, auth()->user()->fresh()->notifications); // not working
Activity icon

Replied to Extending A Class Several Times

What you can do is to make one User extend the User (parent) class and then make your User (parent) class extend Authenticable. Something like:

User:

use \TCG\Voyager\Models\User as BaseUser;

class User extends BaseUser

User (parent):

class User extends Authenticatable implements MustVerifyEmail
Jul
15
3 months ago
Activity icon

Awarded Best Reply on Admin Creates User Send Verification Code

Hey, you are using the query builder to fetch the user, so you are not getting a User instance, if you want a User instance you can do something like:

...
$newuser = User::find($user_id);
$newuser->sendEmailVerificationNotification();
...
Activity icon

Replied to Admin Creates User Send Verification Code

Hey, you are using the query builder to fetch the user, so you are not getting a User instance, if you want a User instance you can do something like:

...
$newuser = User::find($user_id);
$newuser->sendEmailVerificationNotification();
...
Jul
14
3 months ago
Activity icon

Replied to Extra Fields For 1 User Role

I think both options are good implementations. I would personally put the extra fields as nullable in the first table just to keep things easy, because if you go with the second implementation you will need to see when to eager load the second table and things like that.

Jun
20
4 months ago
Activity icon

Replied to Unique Email Validation On Update (Laravel 5.6)

In case anyone is interested you can access your model in your FormRequest class using this->model:

public function rules()
{
    return [
        ...
        'email' => ['required','email',Rule::unique('businesses','email')->ignore($this->business->id)],
        ...
    ],
}
May
20
5 months ago
Activity icon

Awarded Best Reply on (2/2) ErrorException Invalid Argument Supplied For Foreach() (View: C:\laragon\www\path\resources\views\pages\knowledgebasecategory.blade.php)

Looks like your $knowledgebasecategory->knowledgebases relation is not working (probably returning null or 1 record). Do you have the knowledgebases relation correctly defined in your KnowledgebaseCategory model to return a collection?

// app/KnowledgebaseCategory.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class KnowledgebaseCategory extends Model
{
...
    public function knowledgebases()
    {
        return $this->hasMany(KnowledgeBase::class);
    }
...
}
May
09
5 months ago
Activity icon

Awarded Best Reply on How To Resolve: "Trying To Get Property 'email' Of Non-object"

first() returns you the first result of the query you made, if there are no results it returns null. So you are trying to get the email from null. Check that the record you are searching exists in the database.