Nakov

Nakov

at SOLID Solutions

Member Since 3 Years Ago

Skopje

Experience Points
344,560
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
1569
Lessons
Completed
Best Reply Awards
313
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
344,560 XP
Oct
18
1 day ago
Activity icon

Replied to "Class 'Socialite' Not Found"

@avishkame you are certain you ran composer require laravel/socialite?

What about looking for a file in your project called Socialite.php, are you able to find it at all?

Activity icon

Replied to Understanding The HasManyThrough Relation

@jesse_orange_newable Laravel is awesome just so you know :D

There is always something to get you debug easier. You can also install Laravel debugbar which also shows the queries in the browser. Or use Telescope. Many options, huge community :)

Activity icon

Replied to "Class 'Socialite' Not Found"

So in the config/app.php have you registered an alias?

This line in the aliases array:

'Socialite' => Laravel\Socialite\Facades\Socialite::class,

And run php artisan config:clear just in case if the config has been cached.

Activity icon

Replied to Understanding The HasManyThrough Relation

Hm, not sure. Because ->get() returns a collection, so I don't know how don't you get an error, saying articles does not belong to the Collection instance or similar.

You can test in tinker 100%, but try this instead:


$team = Team::where('name', 'Digital')->first();

$team->articles;

->first() returns an instance of the team :)

or the one liner I showed in my previous reply.

Activity icon

Replied to Understanding The HasManyThrough Relation

@jesse_orange_newable So how do you call it then??

Is it this:

Team::whereName('Digital')->first()->articles;

?

Activity icon

Replied to Javascript And JQuery After Inserted Vue Component

@arcadia_1 yes, it might have been a collision of some sort. But keep in mind that for Vue to work all the components must be under that root element to which you have initialized it.

Activity icon

Replied to Javascript And JQuery After Inserted Vue Component

They can for sure :)

jQuery is a JS library. So if you meant VueJS and jQuery, again the answer is yes they can run.

You can inspect any errors in your browser console, if there are any. But if it works as you say then keep on running, even though it is good if you can just depend on one library and not on all of them, unless you use Bootstrap or any such frameworks that depend on jQuery.

Activity icon

Replied to Understanding The HasManyThrough Relation

@jesse_orange_newable it looks like the query is correct, so now the question is do you have data that belongs to that department ? Meaning users but also those users to have articles, otherwise it will return null because it is inner join not left join.

Activity icon

Replied to Auth::viaRemember() Doesn't Work

@emanfateen does this happens on every browser? Have you checked if you have selected to clear cache whenever you close the browser?

Take a look here:

https://cahnrs.wsu.edu/communications/web-services/support/set-browser-to-clear-cache-when-closing/

Activity icon

Replied to Understanding The HasManyThrough Relation

@jesse_orange_newable did you get the query by debugging or this is what you expect?

You can check where do you go wrong like this:

dd(Team::first()->articles()->toSql()); 

And make sure that the SQL is the one that you expect.

Activity icon

Replied to ErrorException (E_WARNING) Use Of Undefined Constant ‘name’ - Assumed '‘name’' (this Will Throw An Error In A Future Version Of PHP)

@neeraj1005 the error might be weird, but it looks like the apostrophes that you use are wrong, try this code instead:

public function hasRole($role)
{
  if ($this->roles()->where('name', $role)->first()) {
    return true;
  }
  return false;
}   

I replaced with . :)

Activity icon

Replied to Adding Up Price Per Week With Transactions

@mykelcodex please show some code :) I cannot help you without code.

As I said above, don't know if you still use the map, or you just return the collection. But you can put the sum in the view:

{{ $transactions->sum('product_price') }}

Ofc out of the $transactions loop, as you only need the total once.

Activity icon

Replied to How To Print All Selected Items By Logged In User

@vikas_developer it seems wrong, so I guess the relationships are wrong that's why you get data that you don't need.. Does auth()->user() returns the correct one?

Activity icon

Replied to How To Print All Selected Items By Logged In User

@vikas_developer why do you use ->toArray() on it? You can simply iterate over the collection.

If the relationships should be as I described them above, change the methods then :)

Activity icon

Replied to Undefined Variable In Blade

@royo1987 happy to help :) one of the ways to learn is asking questions, there is always someone out there to help, so don't hesitate :)

Activity icon

Replied to How To Print All Selected Items By Logged In User

@vikas_developer that does not make sense.. This auth()->user() is the currently authenticated user.. So make sure that your relationship is setup correctly then.

Test the user using dd(auth()->user()) is it one or multiple? :)

I believe that your setup is a bit wrong. I believe that a user should have many orders, and each order can have an extra order, does this sounds correct?

Activity icon

Replied to How To Print All Selected Items By Logged In User

@vikas_developer so why not this way:

$myItems = auth()->user()->with('ExtraOrders.orders')->get();

Then in the view you will need to iterate over them?

So $myItems will be actually an instance of the User, which will contain collection of ExtraOrders and each extra order will contain it's orders.

Activity icon

Replied to Undefined Variable In Blade

@royo1987 your error is from this code:

$form->formType1==$type->id

What is your formType1 ? Is it a model? Try using it's id instead?

Activity icon

Replied to Undefined Variable In Blade

@royo1987 so all seems correct, doesn't it?

Activity icon

Replied to Eloquent Relationship Help

@vikas_developer you can start a new discussion on the forum, and share exactly what you need. Because we are going very far from the initial question here. So if that one is answered then start a new conversation, someone else might help as well.

Activity icon

Replied to Undefined Variable In Blade

@royo1987 that problem might be here: {{route('pokemon.forms.edit',[$pokemon,$form])}}

Try getting the id from the form for example?

Activity icon

Replied to Undefined Variable In Blade

You can pass one array only in the view:

return view('forms.update', [
     'pokemon' => $pokemon, 
     'form' => $form, 
     'types' => $types
]); 

Or use PHP compact()

return view('forms.update', compact('pokemon', 'form', 'types') ); 
Activity icon

Replied to Numbers

@davy_yg this is wrong syntax <? $i = 1; ?> it should be either this <?php $i = 1; ?> or use the blade directive

@php 
$i = 1;
@endphp 

Same for the ++ but check the loop as well as @topvillas shared. That starts from 0 btw.

Activity icon

Replied to Handle Guzzle Async Post Requests

@bajwa_rajat Take a look at the queue you can schedule all the requests but make a delay between the jobs in couple of seconds. The queue also frees your main thread, and everything that does goes completely on the background. You can also have failed jobs if the request did not responded correctly and dispatch just those after a while.

I cannot explain it in a reply here, you should read the docs, but that will be the most efficient way for your case I believe.

Activity icon

Replied to Handle Guzzle Async Post Requests

@bajwa_rajat What I will recommend is using Queue with which you can delay the execution of the jobs.

So take a look at the docs

https://laravel.com/docs/master/queues#delayed-dispatching

Activity icon

Replied to Handle Guzzle Async Post Requests

@bajwa_rajat you can use php own sleep() function if you really want to do it, but I won't recommend it doing it this way..

So at the bottom of the for each sleep for a second between requests

sleep(1);
Activity icon

Replied to Handle Guzzle Async Post Requests

@bajwa_rajat then chunk your $main_array into results of two.. I don't know how big your array is.. But once again if you delay it manually if it is a big array it will block the main thread so your request will timeout after 30 seconds..

Activity icon

Replied to Handle Guzzle Async Post Requests

@bajwa_rajat then what's the reason of using async?

If you want to delay the request it will again block your program, so it does not make sense to me.

Activity icon

Replied to Adding Up Price Per Week With Transactions

As @sinnbeck said but also it will fail on the total when you are looping over the transactions as thats not an object.

I was trying to show you the way to do it, didn't knew how you want to present the results. So you will either need to check if it is an array or an item and show the results there or just remove the map completely and do the sum in the view, it will hurt the same :)

Activity icon

Replied to Adding Up Price Per Week With Transactions

@mykelcodex when you map, you can return another array there built per your needs, so something like this maybe?

$transactions = Transaction::where('user_id',$id)->orderBy('created_at','desc')->get()->groupBy(function($date) {
              return Carbon::parse($date->created_at)->format('W');
              })->map(function ($row) {
                  return $row->toArray() + ['total' => $row->sum('product_price')];
             });

Let me know if it works :)

Activity icon

Replied to Handle Guzzle Async Post Requests

@bajwa_rajat you can handle the exception as a second callback to the then function:

$promise->then(
    function (ResponseInterface $res) {
        // handle successful response
    },
    function (RequestException $e) {
        // handle the exception here..
    }
);
Activity icon

Replied to Double Relationship Between Two Tables

Simple mistake: belgonsTo should be belongsTo.

Activity icon

Replied to Checking Date Payment For My Function Update()

@david2000 your code should work then.

But when I asked you to print out the student id and the date_seance:

dd($request->get('fk_student'), $date_seance);

You said that the $date_seance returns 2019-10-11 which is not what you are saying now, so if the payment date is 2019-10-10 that's not after the 2019-10-11 so make sure that when you change the date in the field, you are sending the correct one to the back-end.

Activity icon

Replied to Creating Default Object From Empty Value

@irankhosravi the image that you showed above, shows a hidden field.. but you are getting the value from the session. The hidden field is not a session, plus you are using the same attribute name for the newPhone.

For this to work:

$oldPhone = Session::get('mobile');

You will have to have:

Session::put('mobile', '0123213');

Somewhere in your code, but you don't.

So make sure at least that you use a different name attributes for the input fields:

<input type="hidden" name="old_mobile" value="0123456789" />

Then in your controller get it from the request:

$oldPhone = $request->old_mobile;
Activity icon

Replied to Creating Default Object From Empty Value

@irankhosravi take a look at my edited reply above.

Activity icon

Replied to Creating Default Object From Empty Value

@irankhosravi well, if that's empty, this will never return a result:

$user = User::whereMobile($oldPhone)->first();

If the change is for the currently logged in user, why don't you get the User like this instead:

Who is changing the users phone number btw?

Why getting the user from the phone number, isn't it the logged in user himself changing his phone number?

So this

$user = User::whereMobile($oldPhone)->first();

Can become this:

$user = auth()->user();

?

Activity icon

Replied to Checking Date Payment For My Function Update()

@david2000 dateFormat can be null it has nothing to do with your problem now. What I fail to understand is what is going on :) when you say you are stuck the update doesn't work, what do you mean by that?

Do you have in the DATABASE a payment record that is after '2019-10-11' for the student with ID 1?

Everything seems correct and yet you have a problem which I don't understand what it is?

Activity icon

Replied to Creating Default Object From Empty Value

@irankhosravi that means that you have fields in the user table that are not nullable so you need to provide value for it.

$user->first_name = "something";

Or find the user if already registered in a different way.

I guess that your dd($oldPhone) returns null that's the reason why you cannot update it. So make sure that you pass the oldPhone correctly.. How do you store it in the session?

Activity icon

Replied to Creating Default Object From Empty Value

@irankhosravi so there's your problem.

You can use this instead maybe:

$user = User::whereMobile($oldPhone)->first() ?? new User;

In case there is no user with the old number, create a new one.

Activity icon

Replied to Creating Default Object From Empty Value

@irankhosravi and what about this:

$user = User::whereMobile($oldPhone)->first();
dd($user);

Try testing if there is a row here at all.. because you get the oldPhone from the session.

Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

You cannot use blade syntax in JavaScript.. this code does not work:

var vidSources = [
    @foreach($videos as $video)
    "{{ $video->video_file }}",
    @endforeach
  ];
Activity icon

Replied to Laravel Passport Error: CreateToken Method Doesn't Exist

@bigweld86 just to throw my 2 cents here.. why do you use a custom Auth Controller at all?

Have you tried doing the same in the LoginController, overriding the authenticated method?

protected function authenticated( Request $request, $user )
{
    dd($user->createToken('myApp')->accessToken);

    return redirect($this->redirectTo);
}

As far as I see you don't do anything extra in order to use manual login.

And as I now see it, you've changed the default namespace of the User model. So you must do the same in the config/auth.php providers array, add the correct namespace for the guard:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],
    ...
],
Oct
17
2 days ago
Activity icon

Replied to RFC

@fajar I don't quite understand your question..

But if you want to send a url, you should use a named route instead, and not hard-code the url in the blade like that..

But that's completely different question, so you should start a new discussion with that, and please provide more details on what you mean..

Activity icon

Replied to "numeric Value Expected"

@chrisgrim do you get that error in the browser console then??

Is it maybe the resultRadius different for some reason? When do you get that error?

Activity icon

Replied to RFC

@fajar the error is here

 $this->from('Yosiko Indonesia')

This should be an email address not a name I believe.

 $this->from('email_address', 'Yosiko Indonesia');

The first param is an email.

Activity icon

Replied to RFC

@fajar share the full error please, it is hard to help you this way..

Are your mail settings used correctly in the .env file?

Try using log as a mail driver and test if you get the message in the log at least.

Activity icon

Replied to RFC

@fajar RFC is really general it can mean anything.. show the full error please.

Have you checked if the email is empty for some reason

dd($request->get('email'));

before you send the mail?

Activity icon

Replied to Undefined Variable: Post

@stevenduongtx Okay that's not a fix neither. So please remove the $post from the create method and don't pass it to the view..

Then just add this in the view and you will be good to go:

@if(isset($post)) 
<img src="{{asset("/storage/{$post->image}")}}"  style="width:680px; height:400px">
@endif 

This was the main reason you had the error at first place. Using an image of a post that does not exists.

Activity icon

Replied to Undefined Variable: Post

@stevenduongtx that's not a fix.

Post::all()

returns a collection of posts not one, so whenever you try to access a property out of a collection it will throw that error.. You will need to iterate over it using foreach for example to access each item.

A better option is to create an empty post for example and pass that through..

So in the controller add this

$post = new Post;

instead of Post::all()

Then for the image not to try and load something that does not exists in the view surround it like this:

@if($post->image) 
<img src="{{asset("/storage/{$post->image}")}}"  style="width:680px; height:400px">
@endif 

Hope this helps :)

Activity icon

Replied to "numeric Value Expected"

As I can see in the formats here

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html

Everything seems alright, and as you say hard-coding the values works okay. So I don't think that even if you passed the values as a string will fail unless the format is wrong for some reason.. So before you use the method try dumping both values and make sure that the format in the request is correct..

dd(is_numeric($request->longitude), is_numeric($request->latitude));

this will tell you which one fails so you can find out why..