OriOn

OriOn

Member Since 2 Years Ago

Experience Points
35,460
Total
Experience

4,540 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
288
Lessons
Completed
Best Reply Awards
10
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 8
35,460 XP
Aug
22
5 months ago
Activity icon

Replied to Undefined Variable: Users

well there is a small typo in @mstrauss ' answer,

in the blade a s is missing in the foreach directive:

@foreach($users as $user)
Activity icon

Replied to What Is Different Or Best Practices

Yes, in the case where you foreign key is what laravel expects it to be then you do not need to provide it in the relationship definition. I would also like to point out that there are other optional parameters to the hasMany and belongsTo methods then only the foreign key (you can find this out in the documentation or the source code the trait name is HasRelationships)

for the blade part, Your post will never have more than one owner because it is a belongsTo relation between the models $post->owner is the User Model of the id stored in the user_id field of the post object.

the use of parenthesis is for collections, for instance in your environment a user can have many posts so $user->posts() will be the collection of posts the user is the owner of. $user->posts()->first() will be the post object with the oldest created_at timestamp (unless otherwise ordered or sorted) $user->posts()->first()->title would reach for the title property of that post object.

hope it clarifies things for you.

Activity icon

Replied to More Than One Listener On Events

if you edit the sequence of listeners do you observe the same result (only the first of the list is logging) or only SendOrderStatusChangeMail is logging?

on a side note I would like to say that I would personally not have the same approach here: I would not list listeners to a single event, if the logic dictates that 3 jobs have to be fired then I would queue those jobs into a single listener and let the server deal with the jobs at its convenience, especially if you are dealing with mail sending like it appears by the names you defined.

Activity icon

Replied to Repeated Query Or Wrong Model Implementation?

with what I suggested above you could reach the last slotQuery related to the Slot by doing

$slot->slotQueries->first()
// returns the slot query or null

You could also use a forelse in the blade that would prompt the latest slot query or whatever you like if empty

@foreach($slots as $slot)
    <tr scope="row" class="">
        <td>{{ $slot->latestQuery()->date }}</td>
        <td>{{ $slot->latestQuery()->gnl }}</td>
        <td>{{ $slot->latestQuery()->gme }}</td>
        <td>{{ $slot->latestQuery()->created_at }}</td>
        @forelse($slot->slotQueries as $slotQuery)
            <td>{{ $slotQuery->id }}</td>
        @empty
            <td>no slot query</td>
        @endforelse
</tr>
@endforeach
Aug
21
5 months ago
Activity icon

Replied to Blocking Other Users From Viewing Messages

@cronix just assumed the controller method you used to return the conversations was a show method.

the logic he suggested can be added on the existing method you are using,

what // other stuff for if the do have permission meant was the rest of your method goes here.

Activity icon

Replied to Repeated Query Or Wrong Model Implementation?

Have you tried something like:

$slots = Slot::with(['slotQueries' => function ($query) { return $query->latest()->first(); }])->get();
Aug
18
5 months ago
Activity icon

Replied to Call To Undefined Function Save()

You miss the parenthesis after you Menu class

public function store(Request $request) { 
  $menu=new Menu();
  $menu->restaurant_id=$request->get('restaurant_id');   
  $menu->value=$request->input('food_item');
  $menu->value=$request->input('price'); // Also you overwrite the line you just wrote
  $menu>save();

  return redirect('/restaurants')->withStatus(__('Restaurant successfully updated.'));
}
Aug
14
5 months ago
Activity icon

Replied to Difference Between Jobs And Events

To my understanding an event is listening to a change while a job is creating one.

But then of course if you pick up on a change with an event it's also to do something with that .

I would use jobs in your context, it provides you with a control over the sequence of jobs that your workflow might require. Using events when updating multiple things at once could have some undesirable effects.

Aug
08
5 months ago
Activity icon

Replied to Integrate Different Sources Of Notifications

Hello, Maybe I didn't catch all the details here but to me this really look different notification channels and could be handled within a Notification class.

what you really have here is multiple broadcast channel for a single entry. ok, the different channels do not emit necessarily the same fields but that's just logic within the different channels, no real need for a table storing these fixed configuration items.

I would look into creating new broadcasting channels to handle your variety of streams.

Also Notifications are sent to users so the Oauth variables could be appended to the users table directly and you would still be able to $user->notify()

Activity icon

Replied to Delete Notification

Well like for any other model, you have the $notification->delete() method.

you can access a collection of notifications for a given user by doing $user->notifications()

From this point, you could narrow to the notification you want to delete and proceed with that.

$user->notifications()
    ->where('id', $notificationId) // and/or ->where('type', $notificationType)
    ->get()
    ->first()
    ->delete();
Aug
06
5 months ago
Activity icon

Replied to How To Find Parent_id In Users Table

Hi there, it seems you are querying the related table and want to use the whereHas method docs

$users = Buy::with('user')->whereHas('user', function ($query) { return $query->where('parent_id', auth()->user()->id); })->latest()->paginate(25);;