imhitt

imhitt

Member Since 9 Months Ago

Experience Points
2,910
Total
Experience

2,090 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
26
Lessons
Completed
Best Reply Awards
0
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 1
2,910 XP
May
25
4 days ago
Activity icon

Replied to How To Get Model ?

@michaloravec sorry, can not select 2 "best answer", thanks SO MUCH for solutions! i am expected get understandigs and @tykus described it.

Activity icon

Started a new Conversation How To Get Model ?

How to get model if i pass id as argument of function ?

i want to get model in same way as with routes, like:

Route example: /users/{user}

public function userShow(User $user)
{
    dd($user); //return me user`s data
}

but when i try to do without route - it says:

Argument 1 passed to App\Http\Controllers\OrderController::getItems() must be an instance of App\Models\Good, string given,

I do:

public function create()
{
   $id = '19ed1e8f-e790-46d2-9e8f-3d7efd27702c'; //im useing uuid as primary key
   
   $itemsArray = $this->getItems( $id );
}

public function getItems(Good $good)
{  
   return $good->items;
}
May
23
6 days ago
May
21
1 week ago
Activity icon

Replied to Laravel Eloquent “with” / “load” Return Null

@michaloravec that what im talking about : ) Ohh great solution !! ?? ?? comes with php 7.4 ?

Activity icon

Replied to Laravel Eloquent “with” / “load” Return Null

@michaloravec Good::latest()->with('user')->paginate(20);

Activity icon

Replied to Laravel Eloquent “with” / “load” Return Null

@michaloravec Yes, please check screenshot of "view file" (https://i.stack.imgur.com/M9V7V.png), and after "output" (https://i.stack.imgur.com/jIKtH.png) to be on same page : )

Activity icon

Replied to Laravel Eloquent “with” / “load” Return Null

@michaloravec @sergiu17 @james_moore relations is ok. i updated question, please pay attention to screenshots. Most of goods return me user relation, but around 1% of all goods can not return me user with with method, but if im using $good->user()->first() it returns me user.

Activity icon

Started a new Conversation Laravel Eloquent “with” / “load” Return Null

I am trying to get ralation (product owner) using with method but it returns me null.

My User model:

public function goods()
{
    return $this->hasMany(Good::class);
}

My Good model:

public function user()
{
    return $this->belongsTo(User::class);
}

Problem in real example:

View file: https://i.stack.imgur.com/M9V7V.png

Output: https://i.stack.imgur.com/jIKtH.png

Why i can not get relation with with of load method ?

*same questionon stackoverflow https://stackoverflow.com/questions/61916987/laravel-eloquent-with-load-return-null

Mar
19
2 months ago
Activity icon

Replied to Eloquent “with” Returns Null

interesting is: why $course->user()->first() return data when $course->user return null -_-

Mar
18
2 months ago
Activity icon

Replied to Eloquent “with” Returns Null

no, also null

Activity icon

Replied to Eloquent “with” Returns Null

this way was offered at stackover, but also returns null

Activity icon

Started a new Conversation Eloquent “with” Returns Null

i'm getting all courses with user (author of this course), but it returns me null. After debuging i tried diferent way to get relation, but it gives me diferent result.

i'm confused because of $course->user (null) | $course->user()->first() (expected result), but for some of users $course->user gives me expected result...

$coursesModel = Course::latest()->with(['user.profile', 'reviews:course_id'])->get();

    foreach ($coursesModel as $key => $course)
    {
        if (!$course->user)
            dd($course, $course->user, User::find($course->user_id), $course->user()->first());
    }

Result of dd:

-> Course model (with attributes)
-> null
-> User model (with attributes)
-> User model (with attributes)

User Model:

public function courses()
{
    return $this->hasMany(Course::class);
}

Couse Model:

public function user()
{
    return $this->belongsTo(User::class);
}

DataBase:

-users
  ->id
-courses
  ->id
  ->user_id

Try to ask at stackoverflow, but nobody can not undertand why its heppening https://stackoverflow.com/questions/60710467/eloquent-with-returns-null