davidleads

Member Since 4 Years Ago

Experience Points
2,440
Total
Experience

2,560 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
19
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.

  • Community Pillar

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

Level 1
2,440 XP
Jan
06
1 week ago
Activity icon

Replied to Repetitive Eloquent Query Across 1 Controller.

So what's the best approach? The view composer or simply putting this query inside my controller's construct?

Activity icon

Started a new Conversation Repetitive Eloquent Query Across 1 Controller.

Let's assume that I have a controller which is dedicated to control the views, so i have different types of views and i send to them different variables, but - i have one query which repeats itself across all the functions, in this case its

$companies = Company::where('enabled',1)->get()->sortByDesc('score');

What would be the right approach to keep it DRY? Is it safe to put this variable in the external scope of the controller and not in every function?

Dec
22
3 weeks ago
Activity icon

Replied to A Question About A Correct Design.

Thanks for that reply. Just a small side note - Since Laravel 8 there is no namespace prefix being applied to the route groups that the routes are loaded into. Which means, this line -

Route::get('reviews/{operator:name}', [email protected]');

Should look like -

Route::get('reviews/{operator:name}', App\Http\Controllers\[email protected]');

OR

Route::get('reviews/{operator:name}', [OperatorController::class,'view']);
Activity icon

Replied to A Question About A Correct Design.

Ok. thanks a lot Larafast!

Dec
21
3 weeks ago
Activity icon

Replied to A Question About A Correct Design.

But is it OK to do so many actions within the web.php file? Feels like a poor design to me.. No?

Activity icon

Started a new Conversation A Question About A Correct Design.

I have a model in my app which is called 'Operator', and each operator has tables which are related to him in one-to-many relationship (each operator has testimonials, comments, videos and more..)

I have a route in web.php which is supposed to retrieve a review page for each operator, and in this view I am using around 4-5 tables which are related to the 'Operator' table as well.

To be able to do it - I first define these variables in the router and then pass them into the view.. But I'm feeling like something is wrong in the way I design these requests, since I feel like im putting too much code into the web.php file itself.

For example, the /{operator}/review route in web.php looks like this -

Route::get('/reviews/{operator}', function ($operator) {
    $operators = Operator::all();
    $operator = $operators->where('name',$operator)->first();
    $params = Param::all();
    $pros_and_cons = ProsAndCon::all()->where('operator_id',$operator->id);
    $testimonials = $operator->testimonials()->get();
    $marketplaces = $operator->marketplaces()->get();
    return view('front.review.main', [
        'operators' => $operators,
        'operator' => $operator,
        'params' => $params,
        'pros_and_cons' => $pros_and_cons,
        'marketplaces' => $marketplaces,
        'testimonials' => $testimonials,
    ]);
});

So basically - the $params, $pros_and_cons, $testimonials and $marketplaces are additional variables which are related to the Operator model and everything works like a charm in the views, so no complaints about that. The only problem is that it looks like im giving too much responsibility to the web.php file, but on the other hand - It's only defining new models based on the {operator} in the URL, so it feels kinda dumb to take this functionality out to the controller - since it's only 1 line of code for each call.

Please let me know how would you approach it?

Dec
20
4 weeks ago
Activity icon

Replied to Restoring Migration Files Based On DB's Structure

Found a solution, if it may concern someone sometimes - Since I worked with PhpStorm, there's a thing called 'Local History' where you can retrieve a specific directory's whole history of changes. Kinda cool!

Activity icon

Started a new Conversation Restoring Migration Files Based On DB's Structure

Hey. I mistakingly deleted the migrations folder (it was a hard-delete, skipped thrash..). Is there a way to restore these files based on the current DB's tables? The project is hosted locally and doesn't have any backup in github or something, unfortunately.

Nov
25
1 month ago
Activity icon

Replied to Multi Language In Laravel

Well, now I can see that it's scanning __("String to be translated") within the views and knows how to manage their translations. But what if I'm retrieving dynamic data from the db inside a blade tag? For example, let's take 'user_profession.blade.php' -

...
$user_profession = $user->profession;
$current_language = App::getLocale();
<p>
__('Profession'): {{Lang::get($current_language,[], $user_profession )}}
</p>
...

So yeah, It will scan the first 'Profession' string and will let me manage it inside its' nice GUI template, but let's assume I have 5 pre-defined professions in the DB and I wish to hold a translation for each of them.. So let's say if the current user's profession is Carpenter, and getLocale() is 'it' (italian) - then logically it should retrieve the italian translation for the Carpenter english word, but langly won't scan it since it doesn't start with the '__' prefix, and i still need to manage the user's professions translations in .json file, or am I missing something?

Activity icon

Replied to Multi Language In Laravel

Oh Wow! Thanks!

Nov
24
1 month ago
Activity icon

Replied to Multi Language In Laravel

I was talking about something which is more similar to WPML (of wordpress) - That i'll be able to manage these translations in some dashboard instead of taking care of .json files all the time. That's kinda not an intuitive way to manage so many languages and so much data.

Activity icon

Started a new Conversation Multi Language In Laravel

Lets assume I have a big blog with around 8-9 different languages.. Is there any practical solution to manage all the translations? Do I really have to store every string of the other language in a file within the resources\lang directory? I have different content writes which are supposed to update different parts of the blog during the time.. It's not realistic for me to give an access to these translation PHP files. Is there some out-of-the-box solution for this one?

Nov
16
2 months ago
Activity icon

Replied to Upgrading VERY Old Laravel To The Latest Version.

https://laravel.com/docs/5.7/upgrade (Estimated Upgrade Time: 10 - 15 Minutes)

"...Next, examine any 3rd party packages consumed by your application and verify you are using the proper version for Laravel 5.7 support..."

how can you say this process takes 15-20 minutes if you don't know the number of my 3rd party packages? i mean.. if i must go over 30-40 packages now to check compatibility, one-by-one.. wouldn't it take me much more than these 15-20 minutes?..

Activity icon

Started a new Conversation Upgrading VERY Old Laravel To The Latest Version.

So, there's some project we abandoned in our company about 2.5 years ago, and now we are willing to get it back. Here's the output of the --version command..

local$ php artisan --version
Laravel Framework 5.6.38

As you can see, it wasn't updated for a long time, and we are wondering what will be the best and fastest approach to upgrade it and make it use the last laravel (8.x.x) version available. From what I already saw - it might be even faster to actually create a new project and gradually copy chunks of code into it.