manelgavalda

manelgavalda

FullStack Developer at Self Employed

Member Since 2 Years Ago

Roquetes

Experience Points
172,270
Total
Experience

2,730 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
1042
Lessons
Completed
Best Reply Awards
113
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 35
172,270 XP
Nov
13
6 days ago
Activity icon

Replied to Unable To Print Object Value In BladeFile

What is StudentResource returning? Maybe it's returning an array so you need to do it like:

$studentInfos['firstname'];
Activity icon

Replied to Class Usercontrol Does Not Exist

Show us some code.

Nov
09
1 week ago
Activity icon

Replied to Undefined Variable From The View

Maybe its a compilation problem:

composer dumpautoload

And

php artisan clear-compiled
Activity icon

Replied to Open A Dynamic Model In Angular6

How are you passing tripdetail to the view?

Nov
07
1 week ago
Activity icon

Awarded Best Reply on Form POST User_id

Hey, if you want to store the id of the user you select you need to provide a value attribute to the dropdown:

           <label for="formUsers"><b>User</b></label>
            <select class="form-control" id="formUsers" placeholder="Select Username">
             @foreach ($users as $user)
                    <option name="user_id" value="{{ $user->id }}">
                         {{ $user->name }}
                     </option>
             @endforeach
             </select>

Then you can access it in your controller and save it:

$attributes['user_id']= request('user_id');
Activity icon

Replied to Form POST User_id

I think the attribute name must be in the select tag, not in option:

           <label for="formUsers"><b>User</b></label>
            <select class="form-control" id="formUsers" placeholder="Select Username" name="user_id">
             @foreach ($users as $user)
                    <option value="{{ $user->id }}">
                         {{ $user->name }}
                     </option>
             @endforeach
             </select>
Activity icon

Replied to Form POST User_id

Hey, if you want to store the id of the user you select you need to provide a value attribute to the dropdown:

           <label for="formUsers"><b>User</b></label>
            <select class="form-control" id="formUsers" placeholder="Select Username">
             @foreach ($users as $user)
                    <option name="user_id" value="{{ $user->id }}">
                         {{ $user->name }}
                     </option>
             @endforeach
             </select>

Then you can access it in your controller and save it:

$attributes['user_id']= request('user_id');
Nov
06
1 week ago
Activity icon

Replied to Trait Not Found While Developing A Laravel Package

Can you show us your composer.json? Looks like you are not loading the trait correctly.

Activity icon

Replied to Trait Not Found While Developing A Laravel Package

Hey, looks like you are not importing the trait on the RepositoryCreatorTest class.

use Inz\Repository\Base\FakeStorageInitiator;
Nov
04
2 weeks ago
Activity icon

Commented on Understanding Foreign Keys And Database Factories

Yes,

In the first case you are always creating a User, even if you indicate a user_id when creating the User with the factory.

In the second case you are just creating the User if you don't indicate the user_id attribute. So you should use the closure way.

What you can do is this:

return [
        'user_id' => factory(User::class)
];

This way will work like the closure case, so if you want to simplify your code and at the same time be efficient you should use this way.

Activity icon

Awarded Best Reply on How To Access Classes Within Folder Inside Root Folder App

Hello, your namespace in your HondaMachine class has a typo:

namespace Ap\Car;

to

namespace App\Car;
Activity icon

Replied to How To Access Classes Within Folder Inside Root Folder App

Hello, your namespace in your HondaMachine class has a typo:

namespace Ap\Car;

to

namespace App\Car;
Activity icon

Commented on Hello Eloquent

From docs ( https://laravel.com/docs/6.x/eloquent#eloquent-model-conventions ):

Note that we did not tell Eloquent which table to use for our Flight model. By convention, the "snake case", plural name of the class will be used as the table name unless another name is explicitly specified. So, in this case, Eloquent will assume the Flight model stores records in the flights table. You may specify a custom table by defining a table property on your model.

Jun
22
4 months ago
Activity icon

Replied to Append An Attribute To Collection Without Causing N+1 Issue

@THEBIGK - I think you need to load the relation with the events:

public function index()
{
    $events = Event::with('attendees')->where('start_date', '>', now())->paginate(30);

    return $events; // Testing
}

And maybe in your User model you will need to work with collections instead of the query builder:

    public function getAttendingAttribute()
    {
        return $this->attendees->where('user_id', '=', auth()->id()); // remove the () in attendees
    }
Jun
21
4 months ago
Activity icon

Replied to Laravel Relations

If the user can only have 1 role I don't think you need the user_roles table.

You can simply add a role_id column in your users table.

Activity icon

Replied to Empty Session(s) After (external) Redirect?

When the user gets redirected from the external server to your laravel server, you will have a new session, so before your laravel server redirects to the external server, you need "to pass" the session you had to the external server, and when the external server redirects you back to the laravel server you will have the session.

Finally, if you are redirecting to your laravel application from an external server, you should disable the csrf token validation: https://laravel.com/docs/5.8/csrf#csrf-excluding-uris

Hope this helps.

Jun
20
4 months ago
Activity icon

Replied to Body Data Is Including The HTML When It's Input To My PhpMyAdmin...

@FORTEIRP - Mm, if you are already displaying the data using {!! $post->body_html !!} it's weird that you still see the <p> tags, if the data is correctly saved in your database I don't understand what else can be wrong.

Activity icon

Replied to Package Dependencies During Development

Hey, I tend to use franzliedke/studio, is pretty easy to use, you can see how it works here: https://github.com/franzliedke/studio

Activity icon

Replied to Body Data Is Including The HTML When It's Input To My PhpMyAdmin...

What you are showing in the screenshot and your code doesn't look the same thing.

In your create view you are using a class to create the textarea, so you don't need to use {!! !!}.

You probably want to show the unescaped text in your show view.

Jun
19
5 months ago
Activity icon

Replied to Laravel Request User

Hey, yep this is normal behavior.

When you use $request->user() you are getting an instance of User, so when you do $request->user()->first() you will get the first User.

This is not dangerous because if you are returning the $request->user() the user has no way of using ->first() after it.

Jun
17
5 months ago
Activity icon

Replied to Validation: String IS NOT

Hey, I think you can use the not_in validation rule: https://laravel.com/docs/5.8/validation#rule-not-in

Maybe the different rule can also help you: https://laravel.com/docs/5.8/validation#rule-different

Jun
14
5 months ago
Activity icon

Replied to Model Function Within FormRequest

@MIHIRPATEL83 - Um, are you sure that you are hitting the Validator, in your controller, before creating the product?

Btw if you already have a custom request class to to do the validation, I think it will be just better to have the rules in your request class.

Activity icon

Replied to Model Function Within FormRequest

You can access the model from the request like this inside your ProductFromRequest:

$product = $this->route('product');
Activity icon

Replied to How To Convert My Json View In Laravel?

@RAVIAWASTI - Um, the easier thing will be for your android developer to access the first item of the array, or create a loop to show errors. If he doesn't know how to do it, then try something like:

    if ($validator->fails())
    {
        $errors = $validator->errors();

        if(array_key_exists('username', $errors)) {
            $errors['username'] = $errors['username'][0];  // Here you are getting the first item of the array and assigning it directly to "username" so it will be a string
        }

        if(array_key_exists('email', $errors) {
            $errors['email'] = $errors['email'][0]; //same as before.
        }

        return response()->json(['success'=>'0','post'=> $errors]);
    }

As I said that's a very ugly flx, but I suppose that something like this should work, in this specific case.

Activity icon

Replied to How To Convert My Json View In Laravel?

Hey, can you show us why do you want to do this? The reason why the username and email fields are returning and array, is because they can have more than 1 error, so I don't think it's a good practice to pass the array into a string.

What you can do in your blade is to access the first item on the array, so you will get the result you expect. If you have this:

{ "success": "0", "post": { "username": [ "The username has already been taken." ], "email": [ "The email has already been taken." ] } }

You can access the key accessing the first item on the array, so instead of accessing username to get the error, you will have to access username[0], and the same with the email.

Activity icon

Replied to It Is That Possible To Gerate A New Class With A Custom Artisan Command ?

Yeah , instead of defining the $class_template inside the command, you can create a stub with the customClass code and generate the class using that.

I think that's a good example of what you want to do: https://medium.com/@imfx/create-make-custom-commands-in-laravel-9fa002da582e

Activity icon

Replied to Which Type Of Format Is This In Laravel Api?

@RAVIAWASTI - They are surrended with curly braces {}, so they are both JSON objects https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON.

A JSON object can have nested JSON objects inside, that's why you have more {} inside.

And in the first case this JSON object has 2 arrays of 1 item inside:

[ "The username has already been taken." ] // First array
[ "The email has already been taken." ] // Second array
Activity icon

Replied to Which Type Of Format Is This In Laravel Api?

This format is called JSON, it's the most common format when working with apis.

If you want to see the data structured, you can use https://jsoneditoronline.org/ for example.

Jun
13
5 months ago
Activity icon

Replied to How To Remove Port In Laravel Aap In Localhost In Ubuntu 16.04

Hey, I'm not sure if I understand the question but maybe, instead of your app url being localhost:8080 you want something like your-app.test?

If that's the case you can use valet: https://cpriego.github.io/valet-linux/

Activity icon

Replied to Phpunit Returns Green On Null

Hey, this is not failing because $thread->slug is probably returning null, so your string looks like "/thread/1/" and your path() function doesn't even need to return the slug.

I think a better test for this would be something like:

public function a_thread_has_a_path()
{
    
    $thread = factory(Thread::class)->create([
        'slug' => 'your-slug'   // or fill the title column and get the slug from that, so you will know that the slug is generated correctly
    ]);

    $this->assertEquals('/thread/1/your-slug', $thread->path());
}

This way you will assure that the path you want is the expected.

Jun
12
5 months ago
Activity icon

Replied to Undefined Variable

You are having this error on your controller or in your blade? The code seems right so this may be a problem with cache or compilation. Try to run this commands:

php artisan cache:clear

composer du
Activity icon

Replied to Declare Middleware Use In Route File Or Controller

Hey, there's not any convention on this, it's just a matter of your personal preference.

Personally i like to put the middleware on the route definition, so when i take a look at my routes file I can easly see which routes are protected by a middleware and I also like to wrap all the routes in a middleware group.

Taken from the docs https://laravel.com/docs/5.8/controllers#controller-middleware :

  • Middleware may be assigned to the controller's routes in your route files.

  • However, it is more convenient to specify middleware within your controller's constructor. Using the middleware method from your controller's constructor, you may easily assign middleware to the controller's action. You may even restrict the middleware to only certain methods on the controller class.

  • Controllers also allow you to register middleware using a Closure. This provides a convenient way to define a middleware for a single controller without defining an entire middleware class.

Activity icon

Replied to Error While Installtion Laravel

Hey, this is actually another problem:

  • PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)"

The php-mysql driver is installed correctly, the problem now is that the credentials to connect to your mysql database are not correct.

Check out that your .env file is configured properly with your mysql credentials:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE="your-database"
DB_USERNAME="your-user"
DB_PASSWORD="your-password"
Activity icon

Replied to Error While Installtion Laravel

@INDERSEIN

  • Illuminate\Database\QueryException : could not find driver.

You are missing the mysql database driver now:

sudo apt-get install php7.2-mysql
Activity icon

Replied to RelationShip

@AFOYSAL - Hey, glad it worked, but it was @wobbie who provided the correct solution to your answer, so you can mark his answer as best, thanks.

Activity icon

Replied to Error While Installtion Laravel

  • Problem 1 - phpunit/phpunit 7.5.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.

You are missing the php xml-extension:

sudo apt-get install php7.2-xml

Here you can see the required extensions: https://laravel.com/docs/5.8/installation#server-requirements

Activity icon

Replied to RelationShip

@AFOYSAL - Here you are referencing the name of this relationship:

public function course()
{
    return $this->belongsTo(Course::class);
}

So you need to use the name of the relationship course, because a Semester belongs to one Course.

Activity icon

Replied to RelationShip

@AFOYSAL - The relationship name to retrieve the course of the semester is course, not courses:

public function index(Request $request, $domain) 
{ 
    $semesters = Semester::with('course')->get(); // change courses to course

    return response()->json(["semesters" => $semesters, "status"=>200]); 
}

Jun
11
5 months ago
Activity icon

Replied to Unexpected AuthenticationException

If you want to check the redirect you need to have the exceptions enabled, so laravel can catch it and redirect you with a 302 response.

/** @test */
public function guests_cannot_manage_projects()
{
    $project = factory('App\Project')->create();

    $this->get('/projects')
        ->assertRedirect('login');
        
    ...
        
}
May
20
5 months ago
Activity icon

Replied to Issues With Sending An Email With A Pdf Attachment

Hey, then the problem must be on the way you are calling the successPayment function. Looks like you are calling it multiple times, but just calling it correctly the first time. Can you show us the code you are using to call it?