kalemdzievski

kalemdzievski

Software Engineer at Upshift

Member Since 5 Months Ago

Skopje

Experience Points
23,030
Total
Experience

1,970 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
62
Lessons
Completed
Best Reply Awards
27
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 5
23,030 XP
Sep
21
1 day ago
Activity icon

Replied to How To Get Model With Relation Ad That Relation Limit With Number

U can do something like this:

$categories = Category::whereNull('parent_id')
    ->with(['products' => function ($query) {
        $query->limit(3);
    }])
    ->orderBy('sort_id')
    ->get();
Jun
23
2 months ago
Activity icon

Awarded Best Reply on Notification Facade: How Can I Pass A User Attribute To The Notification?

No need to send the user id. You can use the $notifiable variable which will represent the user that the notification is being sent to. Check https://laravel.com/docs/7.x/notifications#using-the-notifiable-trait.

Activity icon

Replied to Return More Than Attribute While Grouping By From 3 Tables

If you do not sum up the ticket_reservations.price then you have to include the ticket_reservations.price in the group by.

Why do you want to group if you are not using any aggregate functions?

Activity icon

Replied to Notification Facade: How Can I Pass A User Attribute To The Notification?

Did used the Notifiable trait in your User model?

Activity icon

Replied to Return More Than Attribute While Grouping By From 3 Tables

If you like to get branches.id , ticket_reservations.price , employee.name you will need to group by by branches.id and employee.id to, assuming you wanna sum up ticket_reservations.price.

Also to group by daily you have to convert the timestamp created_at to date: DATE(ticket_reservations.created_at);

If I understood you correctly your query will look something like this:

 DB::table('ticket_reservations')
            ->select(DB::raw('DATE(ticket_reservations.created_at) as day'), 'branches.id', 'employee.name', DB::raw('SUM(price) as SumForToday'))
            ->join('employees', 'ticket_reservations.employee_id' , '=' , 'employees.id' )
            ->join('branches', 'employees.branch_id', '=', 'branches.id')
            ->groupBy('day')
            ->groupBy('branches.id')
            ->groupBy('employee.id')
            ->get();
Activity icon

Replied to Notification Facade: How Can I Pass A User Attribute To The Notification?

No need to send the user id. You can use the $notifiable variable which will represent the user that the notification is being sent to. Check https://laravel.com/docs/7.x/notifications#using-the-notifiable-trait.

Activity icon

Replied to Failed Connection To PhpMyAdmin. I Got This Error When I Tried To Migrate. I Checked The .env File And It Seems To Be Ok. Anyone Can Help :(

What value do you have for env variable DB_CONNECTION ?

And also, what value do you have for driver in your config/database.php ?

Activity icon

Replied to Not Working Laravel Seed

Please provide your code.

Jun
21
3 months ago
Activity icon

Replied to Laravel, Queue & Logging

Did u restarted the workers? Take a look at this part of the documentation: https://laravel.com/docs/7.x/queues#queue-workers-and-deployment

Activity icon

Awarded Best Reply on How To Write Complex Inner Join On Query Builder?

@lonw my bad. Can u try this:

->join('remunerations', function ($join) {
     $join->where('remunerations.id', '=', function ($query) {
         $query->select('id')
             ->from('temporaryTable')
             ->limit(1);
     });
})
Activity icon

Replied to How To Write Complex Inner Join On Query Builder?

@lonw my bad. Can u try this:

->join('remunerations', function ($join) {
     $join->where('remunerations.id', '=', function ($query) {
         $query->select('id')
             ->from('temporaryTable')
             ->limit(1);
     });
})
Activity icon

Replied to How To Write Complex Inner Join On Query Builder?

Why are u writing a join, when u are not joining the table attendances a with remunerations rr ?

But anyways, you can write a complex join like this:

->join('remunerations', function ($join) {
     $join->on('remunerations.id', '=', function ($query) {
         $query->select('id')
             ->from('temporaryTable')
             ->limit(1);
     });
})
Jun
16
3 months ago
Activity icon

Awarded Best Reply on (1/1) NotFoundHttpException In RouteCollection.php Line 179

Try dumping the $id and the $projectmachines to see what is happening. Also Telescope might be useful to see what kind of HTTP request is sent upon clicking the link.

Jun
15
3 months ago
Activity icon

Replied to Eloquent One To One, HasOne / BelongsTo Relationship Only Readable One-way?

Since your foreign key fishery_id in address is not nullable, you will have to insert a valid (existing record) value for it when creating an address row.

Instead of seeding both fisheries and addresses and assigning a random fishery_id for an address, you can seed a fishery for every address within the Address factory:

$factory->define(Address::class, function (Faker $faker) {
    return [
        'line_one' => $faker->streetAddress,
        'town' => $faker->city,
        'county' => $faker->state,
        'post_code' => $faker->postcode,
        'fishery_id' => factory(Fishery::class)->create()->id
    ];
});

After that in your seeder, you can simply do:

public function run()
{
    factory(Address::class, 20)->create();
}
Jun
14
3 months ago
Activity icon

Awarded Best Reply on Laravel Eloquent - Morph With Subject Query

@jeroenvanrensen I've tried an example similar to yours. Your code works just fine. But I've found out that a scenario where subject can be null in the response is when the ID of the "subject" doesn't exists in the corresponding table.

Can u verify that, for example a Thread with id 1 exists, or Reply with id 1 or 2 exists?

Jun
13
3 months ago
Activity icon

Replied to Laravel Eloquent - Morph With Subject Query

@jeroenvanrensen I've tried an example similar to yours. Your code works just fine. But I've found out that a scenario where subject can be null in the response is when the ID of the "subject" doesn't exists in the corresponding table.

Can u verify that, for example a Thread with id 1 exists, or Reply with id 1 or 2 exists?

Jun
12
3 months ago
Activity icon

Replied to Laravel Eloquent - Morph With Subject Query

Your approach seems to be okay. Do you have an issues?

Jun
11
3 months ago
Activity icon

Replied to How To Overlook Case Sensitivity In Entity Relationship

How do you mean overlook case sensitivity?

Activity icon

Replied to SMS Via Event/Listener

The error message is pretty straightforward. You've added use NexmoMessage which is not a trait.

Activity icon

Replied to Return Custom Json Response When Catching ValidationException

Actually my bad. That was not a good idea.

But neither is that catch (\Exception $e) in your controller. This will catch any exception, including for example maybe a incorrect DB query and the message will be shown in your response. Something you should not do on Production. Never.

You should narrow your exceptions here. In your handler, you should handle exceptions like validation, authorization, authentication maybe, etc.

The rest, for local environment will be rendered, but for production will not be shown.

What kind of errors are u expecting in your controller? Do you expect some specific exceptions?

Jun
10
3 months ago
Activity icon

Replied to Return Custom Json Response When Catching ValidationException

Why don't u move the default catch also in the Handler class? You need to add it after the validation exception ofc.

You won't have to add it anywhere else, however if you do need to, that will be fine to.

Activity icon

Replied to Issue With BelongsTo On Self

Can u please provide an example of how u use this method?

Activity icon

Replied to Hey Guys Am Trying To Create A Group Trait. But I Have Some Errors

Can u please provide an example of how you use this method?

Jun
09
3 months ago
Activity icon

Replied to How To Run Artisan Queue:listen Or Queue:work In Production?

If you can install Supervisord on your server then I suggest doing that.

If not, maybe this thread will help you. https://laracasts.com/discuss/channels/laravel/free-queue-solution-for-shared-hosting

Jun
08
3 months ago
Activity icon

Awarded Best Reply on Weird Eloquent Bindings When Using AddSelect Method, Bindings Are Messing With Different Conditions.

@erti not sure, but my wild guess would be that the problem is that you are executing a query inside the query builder. More specifically this part:

$myTeams = auth()->user()->ownTeams()->select('teams.team_id')->get();

There is no need to execute this query, since you can pass it as subquery. Something like this:

->orWhere(function ($q) {
    $subQueryMyTeams = auth()->user()->ownTeams()->select('teams.team_id')->getQuery();
    $q->where('proposable_type', Team::class)->whereIn('proposable_id', $subQueryMyTeams);
});

This way, nothing no DB query will be executed, while building the whole query.

Activity icon

Replied to Weird Eloquent Bindings When Using AddSelect Method, Bindings Are Messing With Different Conditions.

@erti not sure, but my wild guess would be that the problem is that you are executing a query inside the query builder. More specifically this part:

$myTeams = auth()->user()->ownTeams()->select('teams.team_id')->get();

There is no need to execute this query, since you can pass it as subquery. Something like this:

->orWhere(function ($q) {
    $subQueryMyTeams = auth()->user()->ownTeams()->select('teams.team_id')->getQuery();
    $q->where('proposable_type', Team::class)->whereIn('proposable_id', $subQueryMyTeams);
});

This way, nothing no DB query will be executed, while building the whole query.

Jun
07
3 months ago
Activity icon

Replied to SQLSTATE[HY000] [2006] MySQL Server Has Gone Away Laravel Mysql And Xampp

@screwtape_mk still not sure what the problem is, but when u had the error SQLSTATE[HY000] [2002] Connection refused. it looked to me like the port for mysql is incorrect.

Maybe try to confirm that mysql is listening on port 3306?

Activity icon

Replied to (1/1) NotFoundHttpException In RouteCollection.php Line 179

Try dumping the $id and the $projectmachines to see what is happening. Also Telescope might be useful to see what kind of HTTP request is sent upon clicking the link.

Activity icon

Replied to (1/1) NotFoundHttpException In RouteCollection.php Line 179

U did not answer my question. Anyways, seems like you are doing POST request on a GET route.

Activity icon

Replied to (1/1) NotFoundHttpException In RouteCollection.php Line 179

Is this

<a href="{{ route('machineindex', $c->p_id)}}" type="submit" class="btn btn-secondary">Go to machines of the Project</a>

wrapped in a form?

Activity icon

Replied to SQLSTATE[HY000] [2006] MySQL Server Has Gone Away Laravel Mysql And Xampp

@screwtape_mk are you using something else like docker, vagrant, homestead? Also what OS are u using?

Activity icon

Replied to How To Count The Number Of Likes For Each Product In The Table?

Assuming you have likes relation in your Products model:

$products = Product::withCount(['likes' => function (Builder $query) {
    $query->where('type', '=', 'like');
}])->get();

foreach ($products as $product) {
    echo $product->likes_count;
}
Jun
06
3 months ago
Activity icon

Awarded Best Reply on Recently Active Threads And Replies

@orest you might run unto some trouble if you do not use eager loading here. For 50 categories you will have 151 DB query, which is to much.

Either add eager loading when pulling the categories which is totally fine or other solution might be to use sub selects. Sub selects are available for Laravel 6.X and above.

So for example if you wanna pull the recently active thread title for a category you might do something like:

Category::addSelect(['recently_active_thread_title' => Thread::select('thread.title')
    ->whereColumn('thread.category_id', 'category.id')
    ->orderBy('thread.updated_at', 'desc')
    ->limit(1)
])->get();

Or for the poster's full name for the most recent reply on the thread:

Category::addSelect(['recently_active_thread_reply_poster' => User::select('user.full_name')
    ->join('reply', 'reply.user_id', '=', 'user.id')
    ->join('thread', 'thread.id', '=', 'reply.thread_id')
    ->whereColumn('thread.category_id', 'category.id')
    ->orderBy('reply.updated_at', 'desc')
    ->limit(1)
])->get();

Since you can add however sub selects you want at once, you'll end up with only one DB query.

You can find more on sub selects here:

https://laravel-news.com/eloquent-subquery-enhancement

Activity icon

Replied to Absolute Path In Laravel 7 ?

U can use any helper method in views.

Activity icon

Replied to Absolute Path In Laravel 7 ?

Use public_path helper method.

<img src="{{ public_path('assets/img/profile-thumbnail.png') }}" alt="">
Activity icon

Replied to Recently Active Threads And Replies

@orest you might run unto some trouble if you do not use eager loading here. For 50 categories you will have 151 DB query, which is to much.

Either add eager loading when pulling the categories which is totally fine or other solution might be to use sub selects. Sub selects are available for Laravel 6.X and above.

So for example if you wanna pull the recently active thread title for a category you might do something like:

Category::addSelect(['recently_active_thread_title' => Thread::select('thread.title')
    ->whereColumn('thread.category_id', 'category.id')
    ->orderBy('thread.updated_at', 'desc')
    ->limit(1)
])->get();

Or for the poster's full name for the most recent reply on the thread:

Category::addSelect(['recently_active_thread_reply_poster' => User::select('user.full_name')
    ->join('reply', 'reply.user_id', '=', 'user.id')
    ->join('thread', 'thread.id', '=', 'reply.thread_id')
    ->whereColumn('thread.category_id', 'category.id')
    ->orderBy('reply.updated_at', 'desc')
    ->limit(1)
])->get();

Since you can add however sub selects you want at once, you'll end up with only one DB query.

You can find more on sub selects here:

https://laravel-news.com/eloquent-subquery-enhancement

Activity icon

Replied to How To Handle Failed Cron Job

What do you intend to do if your job fails? Just rollback the DB transaction or something more?

Check: https://laravel.com/docs/7.x/database#database-transactions https://laravel.com/docs/7.x/queues#cleaning-up-after-failed-jobs

Jun
05
3 months ago
Activity icon

Replied to Join With 'where' Clause

@orest you need to explicitly specify select: ->select('group_categories.*'). When doing join, attributes from both tables are selected, and if there are two columns with the same name, Laravel won't know which one to retrieve. For example if you try $group->id, the id from the category might be pulled instead of the id of the group.

Activity icon

Replied to Join With 'where' Clause

How do you mean "none of the group_categories attributes is returned." ?

Activity icon

Awarded Best Reply on When I Ran The API Of My Application Through Postman It Shows "Undefined Index: Edit_id"

If you are using PUT method for this route, make sure that u are using x-www-form-urlencoded instead of form-data.

Activity icon

Replied to Eloquent Sorting My Results?

Do not depend on order when ORDER BY is missing. Default order might vary a lot.

It “could” be the order in which rows were entered into the table, but not necessarily if a filter caused an index to be used to filter data. It could be in the order of the key of some index used during the query, but not necessarily if an ORDER BY clause specified a different order or if a GROUP BY, windowing function, or aggregation caused an implicit sort to happen. It could be in the order of an implicit sort triggered as noted, but not necessarily if a join to another table forced a different ordering.

Just add order by in your query builder.

Activity icon

Replied to Running Console Commands In Background

Try to add Logs inside your commands, to see what is actually happening and if the ProcessPhoneNumberFilesCommand is being executed.

Also check for any error logs inside your filed_jobs table.

Jun
04
3 months ago
Activity icon

Awarded Best Reply on How To Model A HasMany Relationship With An Extra Condition ?

I believe that is currently not available in Laravel. However, this library that might help u.

https://github.com/topclaudy/compoships

I answered this very same questions two days ago. Check out this thread: https://laracasts.com/discuss/channels/laravel/two-way-pivot-table

Activity icon

Replied to How To Model A HasMany Relationship With An Extra Condition ?

I believe that is currently not available in Laravel. However, this library that might help u.

https://github.com/topclaudy/compoships

I answered this very same questions two days ago. Check out this thread: https://laracasts.com/discuss/channels/laravel/two-way-pivot-table

Activity icon

Replied to How To Model A HasMany Relationship With An Extra Condition ?

So let me check if I understood u right. U are trying to write a relationship for children that will generate the following query:

SELECT * FROM category WHERE website = 'website_parent'; 
Activity icon

Awarded Best Reply on Two Way Pivot Table.

I believe that is currently not available in Laravel. However, this library that might help u.

https://github.com/topclaudy/compoships

Activity icon

Replied to When I Ran The API Of My Application Through Postman It Shows "Undefined Index: Edit_id"

@vinurajayalath if the answer helped u solve the problem, I would appreciate if u mark it as correct answer. Thanks