Nakov

Nakov

at SOLID Solutions

Member Since 4 Years Ago

Skopje

Experience Points
507,980
Total
Experience

0 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
1592
Lessons
Completed
Best Reply Awards
582
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 50
507,980 XP
Dec
09
4 hours ago
Activity icon

Replied to Select Children Of Active Parent Models (deleted_at = NULL)

@mike_hasarms That's not what the documentation says though

https://laravel.com/docs/master/eloquent-relationships#querying-relationship-existence

You need to check the records then, and is the deleted_at column for that project really null.

Dec
08
1 day ago
Activity icon

Replied to Select Children Of Active Parent Models (deleted_at = NULL)

Wouldn't this do the same:

Task::whereHas(['project' => function($query) {
    return $query->whereNull('project.deleted_at');
})->get();
Activity icon

Replied to 2 Loops (one In The Other ) Messed Up My Html Table

@jlrdw I gave my answer based on this

It shows that 1 that you see in the image. But it shows for 2 times and I want only one time

So if the user doesn't want help on the relationships, then why bother :)

Maybe the project is private, and doesn't want to share on GitHub.

Activity icon

Awarded Best Reply on 2 Loops (one In The Other ) Messed Up My Html Table

@shockwave619 or do something like this:

 @foreach ($orders as $order)
<tr>   
    <th scope="row">{{$order->id}}</th>
    <td>{{$order->firstName}} {{$order->lastName}}</td>
    <td>{{$order->productName}}</td> 
    <td>{{$order->created_at}}</td>
    <td>{{ optional($paid_result->first())->paid }}</td>
</tr>                   
@endforeach 
Activity icon

Replied to 2 Loops (one In The Other ) Messed Up My Html Table

@shockwave619 or do something like this:

 @foreach ($orders as $order)
<tr>   
    <th scope="row">{{$order->id}}</th>
    <td>{{$order->firstName}} {{$order->lastName}}</td>
    <td>{{$order->productName}}</td> 
    <td>{{$order->created_at}}</td>
    <td>{{ optional($paid_result->first())->paid }}</td>
</tr>                   
@endforeach 
Activity icon

Awarded Best Reply on Passing Data To Views From Controller

if you are passing the first array then you need to this instead:

@foreach($matchHistory['matches'] as $match)
     <li>{{ $match['platform_id'] }}<br></li>
 @endforeach 

This will print the platform ID as an example.

Activity icon

Replied to Passing Data To Views From Controller

if you are passing the first array then you need to this instead:

@foreach($matchHistory['matches'] as $match)
     <li>{{ $match['platform_id'] }}<br></li>
 @endforeach 

This will print the platform ID as an example.

Activity icon

Awarded Best Reply on Auto Create Relationship Instance Upon New Model Instance

What I will do in this case is create an Observer and when the user was created the created event on the observer will be called, and create the subscription in there

https://laravel.com/docs/master/eloquent#observers

Activity icon

Replied to Carbon Dates Parsing Wrong On Import

Hey @saadaan, don't know if this will fix it, but you can create a carbon instance from a format, for example:

Carbon::createFromFormat('d/m/Y', $value->date_of_application)->format('Y-m-d')

try that or use the validator.

Checkout this answer as well

https://stackoverflow.com/a/19271434/1457270

Activity icon

Replied to Auto Create Relationship Instance Upon New Model Instance

What I will do in this case is create an Observer and when the user was created the created event on the observer will be called, and create the subscription in there

https://laravel.com/docs/master/eloquent#observers

Activity icon

Replied to How Do I Use Blade In Javascript

Here is a good post, or at least a title on what you should be looking for

https://dev.to/trilemaestro92/how-to-add-event-listener-to-dynamically-added-elements--1iea

Activity icon

Replied to How Do I Use Blade In Javascript

@nikankad As I said, if the answers for the questions are dynamically added to the page, the event listener have to be manually attached it won't be added on the first page load if the element does not exists on the page before the script is loaded.

Activity icon

Replied to How Middleware Guards Work

@trogne then the book by Matt Staufer

https://laravelupandrunning.com/

Has a good section about the Guard in Laravel. I don't think that you will find detailed explanation on a method basis btw :) you will have to dig in the framework yourself.

There is this series https://laracasts.com/series/laravel-explained that Jeffrey started recently, so follow those and ask a question in the comments for what you want explained :) he might record it.

Activity icon

Replied to How Do I Use Blade In Javascript

@nikankad it depends, it won't work with an ID for example if the new element has the same ID, as ID is unique per page and it can be attached to only one element.

Another thing is that if the other button is dynamically displayed on the page, this script is only run when the page first loads, so if the new button appears after the page load you will have to manually attach the click event. That's why I think a class is the best option.

Activity icon

Replied to How Do I Use Blade In Javascript

@nikankad but you are using this {{$pastpaper->id}} out of a loop, right? And now you get the undefined variable I guess..

You can add a class to the element you are clicking, and a data attribute.. for example:

<tr class="pastpaper-row" data-id="{{ $pastpaper->id}}"> 

Then in your javascript get the data id like this:

$(".pastpaper-row").click(function() {
    var id = $(this).data('id');

    console.log('testing', id);
});
Activity icon

Awarded Best Reply on Laravel Controller Destroy Function Issue.

@masumluf if you run php artisan route:list you will see how the resource is actually named in your route. So your destroy route will be something like this:

/video/{video}

You don't see the attributes cause you are getting an empty instance of the model.

So if you bind it correctly, and use the ID to delete the item, then change just the method signature in your controller to this:

public function destroy(Schoolvideo $video)
{
    dd($video);
}

Or change the name of the variable, to what is between the brackets when you run the command I gave you above.

Activity icon

Replied to Laravel Controller Destroy Function Issue.

@masumluf if you run php artisan route:list you will see how the resource is actually named in your route. So your destroy route will be something like this:

/video/{video}

You don't see the attributes cause you are getting an empty instance of the model.

So if you bind it correctly, and use the ID to delete the item, then change just the method signature in your controller to this:

public function destroy(Schoolvideo $video)
{
    dd($video);
}

Or change the name of the variable, to what is between the brackets when you run the command I gave you above.

Activity icon

Replied to How Middleware Guards Work

Take a look at this answer

https://stackoverflow.com/a/38956769/1457270

and the links provided

Activity icon

Awarded Best Reply on How Do I Use Blade In Javascript

@nikankad consider marking a "Best Answer" if it helped you :)

Have fun coding :)

Activity icon

Replied to How Do I Use Blade In Javascript

@nikankad consider marking a "Best Answer" if it helped you :)

Have fun coding :)

Activity icon

Replied to Laravel 6+ Cookie Consent Package Problems

@seeker1337 happy to help :) make sure you accept the answer in the other thread as well, if that's what you ended up using

https://laracasts.com/discuss/channels/laravel/laravel-6-change-default-cookies-behavior?page=1#reply=561927

EDIT:

To answer to you question above, yes, Laravel cookies won't be changed. This package is just to ensure that the user is aware that there are cookies used. So if the client changes a cookie, for sure it will be invalid :)

Hope this helps.

Activity icon

Replied to How Do I Use Blade In Javascript

@nikankad you have multiple errors on the site, when changing from the dropdown, the function used is not defined. Then here:

$("#1").click(function() {
        //  var id = $(this).attr('id');
         console.log('testing', id);

        });

The id is commented so it will be undefined. And the error is in igcse.blade.php file, don't know if this is it, but you are using it in the loop, if you use that variable somewhere out of the loop, then it will throw that error otherwise it is a local variable.

Activity icon

Awarded Best Reply on Laravel 6+ Cookie Consent Package Problems

@seeker1337 I installed the package using this steps:

  • composer require spatie/laravel-cookie-consent

Published the config

  • php artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="config"

And added in my welcome.blade.php file:

@include('cookieConsent::index')

And I got this result: https://imgur.com/ykmJY8N

Activity icon

Replied to How Do I Use Blade In Javascript

@nikankad but this error has nothing to do with the code that you have shown me above..

Where do you use $pastpaper ?

Activity icon

Replied to Laravel 6+ Cookie Consent Package Problems

@seeker1337 I installed the package using this steps:

  • composer require spatie/laravel-cookie-consent

Published the config

  • php artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="config"

And added in my welcome.blade.php file:

@include('cookieConsent::index')

And I got this result: https://imgur.com/ykmJY8N

Activity icon

Replied to How Do I Use Blade In Javascript

@nikankad no I mean here: $("#{{$users->id}}") if you inspect elements in your browser make sure that the click is caught:

$("#{{$users->id}}").click(function() {

    var id = $(this).attr('id');

    console.log('testing', id);
}); 

Check if your console when you click on the element prints, testing and the id.

Activity icon

Replied to How Do I Use Blade In Javascript

@nikankad if you use it in blade and the ID is attached then use this instead:

$("#{{$users->id}}").click(function() {
    var id = $(this).attr('id');
}); 

I assume that {{$user->id}} does work in your selector.

Activity icon

Replied to Laravel 6+ Cookie Consent Package Problems

@seeker1337 in the documentation it says

The package will not display the dialog when that cookie has been set.

So try clearing all the cookies/cache on your browser before testing if it works :)

Also a friendly reminder if an answer happen to help you you should mark the thread as resolved by selecting the reply as Best Answer, here for example: https://laracasts.com/discuss/channels/laravel/laravel-6-change-default-cookies-behavior?page=1#reply=561927 :)

Activity icon

Replied to Forge Support: Is This A Joke ?

@superfive33 I understand your issue, was thinking on sending an email to that email address, but I guess that will not be one that someone can respond to your issue, so just use the one I shared above: [email protected]

Activity icon

Replied to Forge: Scheduler Not Running

@superfive33 when you use scheduler:run command it takes all the commands registered in your App\Console\Kernel.php class, the schedule method. So do you have your command scheduled there? And is it running every minute or at a specific time?

Activity icon

Replied to Forge Support: Is This A Joke ?

@superfive33 oh, sorry to hear that. And you don't have the emails that they send when you provision the server I guess.. Here is one of the emails that I have received support from [email protected] Hope you solve your issue soon.

The link to the docs exists here : https://imgur.com/0HqkmtP

Activity icon

Replied to Help With A Bug On Jquery Code Hide Parts On Navbar When The User Scroll Down

@awadgorg try this one please:

var lastScrollTop = 51;
$(window).scroll(function() {
    var scrollTop = $(this).scrollTop();
    if (scrollTop < 51 && lastScrollTop >= 51) {
       $('#main_header_con').show();
       $(".main_page_nav").addClass('nav_cat_sticky');
    } else if(lastScrollTop >= 51) {
        $('#main_header_con').hide();
    }
    lastScrollTop = scrollTop;
});
Activity icon

Awarded Best Reply on How Do I Make A Select Function

@nikankad just a create a model for your table, for example users table it will have a model called User,

then use

$userIds = User::where('name', 'John')->pluck('id');
Activity icon

Replied to How Do I Make A Select Function

@nikankad just a create a model for your table, for example users table it will have a model called User,

then use

$userIds = User::where('name', 'John')->pluck('id');
Activity icon

Replied to Forge: Scheduler Not Running

You should just set the scheduler to run every minute for example on your project directory, then you need to check the logs in your project if the job/command has any errors or what happens with the job.. So the logs are not available in this directory cat: /home/forge/.forge/scheduled-XXXXXX.log

But it should be here: /home/forge/my-site.example/storage/logs/ and then the file is laravel..., .log extension

Activity icon

Replied to Forge Support: Is This A Joke ?

I don't think it says 24/7 support available anywhere. However there is a button in the forge admin panel bottom right corner, which you can click and check if your question has been already answered: https://imgur.com/5LAAxdr

There is a documentation as well here:

https://forge.laravel.com/docs/1.0/introduction.html

Activity icon

Replied to Admin Middleware To Protect Routes

You can add the cast to the is_admin column to be cast to boolean:

'is_admin' => 'boolean'

to the $casts array, but also make sure that your Admin middleware is actually being called by simply doing:

dd(Auth::user());

before the check. And make sure that this user is actually an admin.

Dec
07
2 days ago
Activity icon

Replied to Request $request Vs. Request()

If you look at the implementation of the request() helper it essentially does the same :) it resolves the request from the Container. Which is the same as using Request $request in your controller method :) so there is no difference, use whichever is accessible to you at the moment :)

Activity icon

Replied to MySql Remote Login

@fida then be a good guy and teach them how to protect the .env file being exposed instead of asking a way to hack them :D

Activity icon

Replied to $this Is Null Inside Model

@skinnyvin haha, thanks man. I am happy if I gave you a bit of a direction on where to look at more than what you have tried so far, unfortunately can't test it myself to know what exactly is going on, but it just maybe that's not the solution in this case anyway so do it the way it works :) append the count to the response, or yeah assign it to the Vue component as a separate property, it won't hurt as long as it gives the correct result :)

Happy coding! :)

Activity icon

Replied to MySql Remote Login

@fida

laravel will show you all the env variable with error exception etc.

That's why the APP_DEBUG is not true on a server environment, NEVER. :)

And Laravel will not show you the env variable, you are doing something very wrong I guess. The Passwords are always guarded.

You have logs for that, and many, many services for logging.

Activity icon

Replied to $this Is Null Inside Model

@skinnyvin it seems like the conditions are not considered at all when you use the withCount property. Sorry but I can't seem to help much here not having your data.

You could still pass the count() as a separate param though :) before you return it back to the view for your Vue component. Consider this as a last chance in case you can't figure it out why the withCount does not work as it should.

Activity icon

Replied to MySql Remote Login

@fida if the port is not accessible remotely, you have firewall.. then no one can do any harm to you..

and if you protect your .env file, then how can I have your mysql credentials?

If I can SSH to your server and I have your credentials, then yes, I can do you harm.. export your DB, or completely destroy it.

Activity icon

Replied to $this Is Null Inside Model

@skinnyvin well then if calling $store->plannedVisits returns the correct result, I don't see why the count() would not return the correct results..

Activity icon

Replied to MySql Remote Login

Well, you should serve your application on the server only from the public folder, and the other directories should not be publicly visible at all.

But here are some answers on protecting a specific file like the .env

https://stackoverflow.com/questions/38331397/how-protect-env-file-laravel

https://laracasts.com/discuss/channels/general-discussion/how-do-you-protect-env-file-from-public

Activity icon

Replied to $this Is Null Inside Model

ups, sorry. Didn't noticed that.

Can you dump the dates, if the range is correct?

use : dd($this->periodEnd()) and check if the date is the correct one. But this does not benefit the eager loading anyway, as you are querying the database again.

Activity icon

Awarded Best Reply on This Action Is Unauthorized.

@irankhosravi I believe that within your CouponRequest you have the authorize method returning false.

Set it to true instead:

public function authorize()
{
   return true;
}

Or use the correct policy for the check there :)