bugsysha

bugsysha

Member Since 4 Years Ago

Experience Points
174,205
Total
Experience

795 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
1570
Lessons
Completed
Best Reply Awards
21
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
174,205 XP
Oct
17
5 days ago
Activity icon

Commented on Widget Workshop

What would you do when you have the same widget in multiple places but the HTML is different? For example you have a card for a place you can rent which displays only most important data, but then when you open the page for that place you need to display much more info. Would you just create separate widgets or something else?

Oct
14
1 week ago
Activity icon

Replied to How To Loop Through Variables?

We believe in you ;) Or as MJ would say it "Just Do IT" (IT is capital for Information Technology) :D

Activity icon

Replied to Design Pattern Question

What about polymorphic relationships? Have you considered them? Not sure I fully understand the current setup and the problem, but if one of those has to exist that polymorphic relationships might help you.

Activity icon

Replied to How To Loop Through Variables?

Why don't you use an array that contains all those values/variables and just loop on that array?

Activity icon

Replied to Best Way To Clean Up A Large Model Class

It is hard for me to come up with any patterns or cleaning techniques without knowing the methods in the model.

If you have methods like $user->disable() or $user->unsubscribe(), in my opinion nothing will read better than that.

But on the other hand if you have stuff that is not related to the user like $user->washCar() or $user->feedTheDog() then that might be extracted.

As for the solutions you've mentioned:

  1. Do not like it. I've used that with proxies and for presenters and it just added unnecessary layer of complexity.
  2. If there is a group of methods that can be grouped then this might do the trick.
  3. I always use repositories cause it is easier for me to name the methods in it and test it than to have that on the model.

Hope this helps.

Aug
19
2 months ago
Activity icon

Replied to Getting Distinct Rows From A Model With Relationships

It's hard without database and models to get that right.

Aug
18
2 months ago
Activity icon

Replied to Getting Distinct Rows From A Model With Relationships

What about

$category->products()->groupBy('brand_id')->limit(6)->get();

And if you need brands to work with then

$category->products()->with('brand')->groupBy('brand_id')->limit(6)->get();
Activity icon

Replied to Calculate Birthdate

@bobbybouwmann keep it up. New guys need you!

Activity icon

Replied to Calculate Birthdate

@bobbybouwmann damn you reply fast :D

Activity icon

Replied to Browser Testing

Dusk all the way. Just don't run them that often.

Activity icon

Replied to Getting Distinct Rows From A Model With Relationships

Then I misunderstood you. You then do not need with(), but just something like this:

$category->products()->brand()->distinct()->limit(6)->get();

Point I was trying to make is that you do not need leftJoin() since that will be handled by relationships.

Aug
17
2 months ago
Activity icon

Replied to How Do I Add A Colum To My Database Table Without Losing My Database Entrys

@lxg please select the answer that helped you as correct one so that person gets the points they've earned and so others will easier see that the problem is solved and if anyone has the same issue they will know right away what helped you. Thanks.

Aug
16
2 months ago
Activity icon

Replied to How To Use Env In Laravel Package?

Do you have Laravel defined as a dependency in composer.json file for your package? Or maybe you should change your approach how you develop that package to have it within Laravel and later just extract it.

Here is what documentation has to say on that topic:

When writing a Laravel application, it generally does not matter if you use contracts or facades since both provide essentially equal levels of testability. However, when writing packages, your package will not typically have access to all of Laravel's testing helpers. If you would like to be able to write your package tests as if they existed inside a typical Laravel application, you may use the Orchestral Testbench package.

Aug
15
2 months ago
Activity icon

Replied to Load Localstorage To State On Load (Vuex)

Maybe it's due to promises that you have in your mutations. Move that to actions and from that action call/commit mutation.

Aug
14
2 months ago
Activity icon

Replied to How "smart" Should Model Methods Be?

I always use Repositories since they tend to have better named methods with clear dependencies. Also I love to test them to assert that everything is working as it should be which I do not do if I do not use/have them in the project. It prevents juniors breaking scopes or other simple issues.

Activity icon

Replied to How "smart" Should Model Methods Be?

If it's that way, then I suggest a PostFactory since it looks like you will just pile up code in that method.

Activity icon

Replied to How To Use Env In Laravel Package?

This should do the trick. Call it at the top of the test.

config()->set('app.name', 'Something');

You should not mock the Request facade. Instead, pass the input you desire into the HTTP helper methods such as get and post when running your test. Likewise, instead of mocking the Config facade, call the Config::set method in your tests.

Activity icon

Replied to Load Localstorage To State On Load (Vuex)

What does cart.getItem('cart') do?

Activity icon

Replied to How "smart" Should Model Methods Be?

Definitely pass it as an argument/parameter to a method.

The only thing I would ask is why don't you force your administrator users to impersonate a specific user when they need to create posts for them?

Aug
12
2 months ago
Activity icon

Replied to 419 Sorry, Your Session Has Expired. Please Refresh And Try Again.

Maybe you are using wrong middleware (web auth) on that (api) route?

Activity icon

Replied to `php Artisan Migrate` Looks For PostgreSQL Connection Instead Of MySQL

Have you tried clearing configuration cache?

Activity icon

Replied to Getting Distinct Rows From A Model With Relationships

Replace leftJoin() with with() if you have relationships defined.

Aug
09
2 months ago
Activity icon

Replied to How To Parse This.

What about parse_str()? Maybe even request()->all()? Or request()->only()?

Activity icon

Replied to Each Or Map When Plucking Three Columns (id, Code, Name) From A Collection

You should not have ->get() in your scope.

Activity icon

Replied to Each Or Map When Plucking Three Columns (id, Code, Name) From A Collection

No need to pluck if you are then mapping over it. If you want to have less data to work with then use:

\App\Account::active()->select('id', 'code', 'name')->get();

If you are transforming then use map, if you are just looping over then use each.

Aug
08
2 months ago
Activity icon

Replied to Hello Friends | Users Table Field Keeps Return True

Seems like that is specific to your setup. To fix it use

class User extends Authenticatable implements MustVerifyEmail
{
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'type' => 'integer',
    ];
}

I know that Laravel lately changed from integer to bigInteger in migrations when you want to have a relationship. Was that feature released in 5.7, I have no idea. Maybe it is related to that, or maybe it is related to some package you are using.

Try to install new Laravel project with preferably same version and see how that one behaves once you add $table->integer('type'); to the migration.

Activity icon

Replied to Hello Friends | Users Table Field Keeps Return True

Should that be a relationship or what?

Activity icon

Replied to Hello Friends | Users Table Field Keeps Return True

Which version of Laravel are you using?

Activity icon

Replied to Deep Nested Relation Count

@snapey if he is searching for the first one like you suggested

->firstWhere('active',true);

Then the method name needs to get rid of plural.

Aug
07
2 months ago
Activity icon

Replied to CORS Access To XMLHttpRequest At X From Origin Has Been Blocked By CORS Policy

If I understand everything you are saying then you are setting those headers on your site instead of the site with the API you are trying to fetch data from? Am I correct?

Activity icon

Replied to Error While Trying To Get Id Of Logged In User Into A Database

I've watched some videos countless times until I've figured it out or it became my muscle memory. So do not give up if you do not get it first time you watch it. Click on repeat button :D

Activity icon

Replied to Where Do Developers Hangout Usually.

Not sure if it's related to humble audience. It seems to me more like everyone is coming here to solve their problems or to help others. Not one person is here to kill time. Maybe that is the trick.

But who knows, maybe we all consider Laracasts like home, where we learned so much and we do not want to leave an impression that we are idiots or internet trolls so we behave like true gentlemen.

Activity icon

Replied to How To Fix “ No Such File Or Directory”error When I Access To The Home Page

If you take a closer look than you'll notice there is an issue with difference in path notation for operating systems.

On Windows DIRECTORY_SEPARATOR is backslash \, and on Unix based systems it is slash /. Not the one from GnR :D

So in your case it is using Windows notation until this point C:\Users\Rafaa\Downloads\Compressed.idea, and after that it is switching to what is defined in the server.php file on line 21 which is /public/index.php.

I have never tried web development on Windows so I'm not sure I can help you without Google myself. So please try to search something related to that and I'm sure you will find a solution for your problem.

Activity icon

Replied to Where Do Developers Hangout Usually.

I've been to many forums, groups, chats. It always ends up with someone being insulted or picking on every word you say. I think that Laracasts forum is the best place to be. Maybe not so fast and functional, but on a long run least stressful and most rewarding.

Activity icon

Replied to Getting Distinct Rows From A Model With Relationships

Hope this all makes sense.

Not to me. Definitely I need more info/code/db to understand the problem fully.

Activity icon

Replied to Error While Trying To Get Id Of Logged In User Into A Database

Great. Consider checking out Laravel From Scratch series here on Laracasts. I have a strong feeling that you might benefit from it.

Activity icon

Replied to In Practice, What Is Abstraction?

Abstraction is something more general than the thing you are talking about. Let's say that you have a chair. Abstraction for that might be furniture. Nothing more complicated than that. You can think of it as generalization.

Activity icon

Replied to Deep Nested Relation Count

Try something like this.

    public function scopeHasActiveAccounts(Builder $query): Builder
    {
        return $query->whereHas('Provider.Account', function ($query) {
            $query->where('active', true);
        })->count();
    }
Activity icon

Replied to How To Delete Item From Session

https://laravel.com/docs/5.8/session#deleting-data

// Forget a single key...
$request->session()->forget('key');

// Forget multiple keys...
$request->session()->forget(['key1', 'key2']);
Activity icon

Replied to Error While Trying To Get Id Of Logged In User Into A Database

If you have a relationship then use this:

Auth::user()->ticket()->create(request(['title','category','description']));

If not then:

Ticket::create(array_merge(
['user_id' => Auth::user()->id],
request(['title','category','description']),
));

Or this:

$payload = request(['title','category','description']);
$payload['user_id'] = Auth::user()->id;
Ticket::create($payload);