Nakov

Nakov

at SOLID Solutions

Member Since 4 Years Ago

Skopje

Experience Points
696,800
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
1644
Lessons
Completed
Best Reply Awards
889
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 50
696,800 XP
Mar
29
1 day ago
Activity icon

Awarded Best Reply on Call To A Member Function Threads() On Null

@siewlon6093

Is your route auth protected?

If it is not then it means that $request->user() is equal to null hence the error.

Activity icon

Replied to Call To A Member Function Threads() On Null

@siewlon6093

Is your route auth protected?

If it is not then it means that $request->user() is equal to null hence the error.

Mar
28
2 days ago
Activity icon

Awarded Best Reply on How Pass More Param To EditColumn Method

You should use use instead of with to pass a variable to a closure.

->editColumn('id', function ($storageSpace) use ($colorsCollection){
Mar
27
3 days ago
Activity icon

Awarded Best Reply on Clean Up Route's File

If it is just a view without a controller, you can use it like this:

Route::view('legals/cookie', 'legals.cookie');

https://laravel.com/docs/master/routing#view-routes

Activity icon

Replied to Clean Up Route's File

If it is just a view without a controller, you can use it like this:

Route::view('legals/cookie', 'legals.cookie');

https://laravel.com/docs/master/routing#view-routes

Activity icon

Replied to Problem With Unique Field Validation On Update In Controller

Here is the documentation: https://laravel.com/docs/7.x/validation#rule-unique

Take a look where it says : Forcing A Unique Rule To Ignore A Given ID.

And here is an example: https://stackoverflow.com/a/33553894/1457270

Activity icon

Replied to Select Raw Data With Date_format

@akmadhwa just add this one to your model:

public function getCreatedAtAttribute($value)
{
    return Carbon::parse($value)->format('Y-m-d H:i');
}

And then use it:

$user = User::first();
$user->created_at; // 2020-03-27 12:20
Activity icon

Awarded Best Reply on Socialite: Redirect Based On Role After Logged In

@james_bhatta seems like you have a route named for the role, so wouldn't this be enough?

public function authenticated(Request $request, User $user)
{
    $role = $user->role;

    return redirect()->route($role);
}

And do the same one line in the controller. I don't see a route for a customer but. I guess you should have one.

Activity icon

Replied to Select Raw Data With Date_format

@akmadhwa is your table called customer or customers?

Why do you need to specify it?

Just this does not work:

 $query = $this->model::selectRaw('DATE_FORMAT(created_at, "%Y-%m-%d %H:%i"));

What is your model instance here?

Activity icon

Replied to Laravel + Vue Scripts Won't Work Unless Page Is Refreshed

Unfortunately I don't know how to help you based on your message that it is not working.

Check the documentation: https://laravel.com/docs/master/mix#browsersync-reloading

Activity icon

Replied to Laravel + Vue Scripts Won't Work Unless Page Is Refreshed

@jaycarter watch just watches for changes in the files and recompiles them, but in order to let the browser know that you've changed something you need to swap those. So that's what hot reload does. You should read the blog post.

You should have a line like this in your package.json in the scripts:

"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",

try running npm run hot instead.

Mar
26
4 days ago
Activity icon

Awarded Best Reply on Checkbox Insert

@heimdall what type of field is your category_id? If it is an integer, you might need to loop through the array and persist a row for each of the categories:

foreach(request("categorybox") as $category_id)
{
    $category_dish = new category_dish();
    $category_dish->category_id = $category_id;
    $category_dish->dish_id = $Dishs->id;
    $category_dish->save();
}

And I would guess that you are validating that at least one checkbox is selected, otherwise nothing will be saved here.

Activity icon

Replied to Checkbox Insert

@heimdall what type of field is your category_id? If it is an integer, you might need to loop through the array and persist a row for each of the categories:

foreach(request("categorybox") as $category_id)
{
    $category_dish = new category_dish();
    $category_dish->category_id = $category_id;
    $category_dish->dish_id = $Dishs->id;
    $category_dish->save();
}

And I would guess that you are validating that at least one checkbox is selected, otherwise nothing will be saved here.

Activity icon

Replied to SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'name' Cannot Be Null

@dostogir I would guess that you have a name for the user, and you are missing it here to add, so add:

$user->name = 'Some name';

somewhere before you do $user->save();.

Activity icon

Replied to Socialite: Redirect Based On Role After Logged In

@james_bhatta all of those methods are parts of AuthenticatesUsers trait. And LoginController uses it, so check how the LoginController works and make your adjustments.

Mar
25
5 days ago
Activity icon

Awarded Best Reply on Create Method With Validating Only Some Fields

@moshemo you cannot do it in one go, or rather it will look ugly, you can do it this way:

$validated = request()->validate(['title' => 'required']);

Article::create(request()->only('excerpt', 'body') + $validated);

or just add them as nullable and not required

Article::create(request()->validate([
 'title' => 'required',
 'excerpt' => 'nullable',
 'body' => 'nullable'
]));
Activity icon

Replied to Create Method With Validating Only Some Fields

@moshemo you cannot do it in one go, or rather it will look ugly, you can do it this way:

$validated = request()->validate(['title' => 'required']);

Article::create(request()->only('excerpt', 'body') + $validated);

or just add them as nullable and not required

Article::create(request()->validate([
 'title' => 'required',
 'excerpt' => 'nullable',
 'body' => 'nullable'
]));
Activity icon

Replied to Socialite: Redirect Based On Role After Logged In

@james_bhatta seems like you have a route named for the role, so wouldn't this be enough?

public function authenticated(Request $request, User $user)
{
    $role = $user->role;

    return redirect()->route($role);
}

And do the same one line in the controller. I don't see a route for a customer but. I guess you should have one.

Activity icon

Replied to Protecting API Routes With Middleware

There is. You can just create Policies, and authorize the users for the access in the controller, instead of the middleware.

Mar
24
6 days ago
Activity icon

Awarded Best Reply on Sanctum Csrf Cookie

@ezrab_ here is a tutorial that you might find useful: https://medium.com/@godilite/using-laravel-airlock-with-vuejs-1d343ee6f10

And no you should not check for each request if the cookie is set, this is done only on login/registration.

And once you have successfully registered the user, you should not be required to login again. You will need to create a token for the registered user, and then use that token to authenticate/authorize the user.

Mar
23
1 week ago
Activity icon

Replied to Resource Instead Of Response()->json()

@splendidkeen Unfortunately I don't have your project to look on this for you, you will have to find why it returns an array in some cases and an Object in another case. Because clearly you get the error when you response from the controller is an Object instead of an Array like the getUsers returns.

So once again make sure that you return the same response both times. I am out now my friend, sorry but I have work to do.

Activity icon

Replied to Resource Instead Of Response()->json()

@splendidkeen try putting a console.log within the computed method to make sure that always the result of this.users is an array as some is a function on an Array in Javascript. If it somehow happens to not be, then add a guard based on the result that you get, to avoid calling some on undefined for example, in case this.users can be undefined at some point. Or make sure that you have initialized it to an [] array at least.

Activity icon

Awarded Best Reply on Resource Instead Of Response()->json()

@splendidkeen no it is not crazy.. You are getting data with Array of data, and data is not an object in your case which has a users key.

Does just this do the trick:

this.users = data;

instead of data.users

Activity icon

Replied to Authentication Process With Laravel & Vue

Well, that's what I suggested as well :) based on your first question above.

Activity icon

Replied to Resource Instead Of Response()->json()

@splendidkeen no it is not crazy.. You are getting data with Array of data, and data is not an object in your case which has a users key.

Does just this do the trick:

this.users = data;

instead of data.users

Activity icon

Replied to Authentication Process With Laravel & Vue

@paddelboot I assume you read the documentation for Sanctum. I don't understand how is Sanctum a 3d party client authorization.

Activity icon

Replied to Resource Instead Of Response()->json()

@splendidkeen that's why I said you should log the results in order to ensure that you get same data type back..

try this :

$.ajax({
    context: this,
    type : 'get',
    url : "/search",
    data:{ 'search': this.search },
    success: function (data) {
        console.log(data);
        this.users = data.users;
    }
});

Using context here.

And make sure that the browser console spits out an array of objects.

Activity icon

Awarded Best Reply on Yaira DataTable Insert Not Inline

@palla451 because you cannot use Laravel helpers within a JS file:

ajax: "{{ route('inputs.index') }}",

this can be used in .blade.php but not in .js file.. You should change the URL's.

Mar
22
1 week ago
Activity icon

Replied to How Pass More Param To EditColumn Method

You should use use instead of with to pass a variable to a closure.

->editColumn('id', function ($storageSpace) use ($colorsCollection){
Activity icon

Replied to Vue Components With Laravel

And no error in the browser console? I doubt that..

Check your Hero.vue file and make sure you are following the correct syntax for a Vue file, and you don't have any syntax errors in there.

Also if you do this:

Vue.component('Hero', require('./components/Hero.vue'));

You don't have to do this:

import Hero from './components/Hero';

nor adding it to the components object of the app Vue instance.

Activity icon

Awarded Best Reply on Vue Components With Laravel

@sinon nothing happened is not a helpful answer at all.

You make sure that you include the .js file in which you added the components.

And try to register them this way instead:

Vue.component('navbar', require('./components/Navbar.vue'));

and use it in your #app element as:

<navbar></navbar>
Activity icon

Replied to Vue Components With Laravel

@sinon nothing happened is not a helpful answer at all.

You make sure that you include the .js file in which you added the components.

And try to register them this way instead:

Vue.component('navbar', require('./components/Navbar.vue'));

and use it in your #app element as:

<navbar></navbar>
Activity icon

Replied to Vue Components With Laravel

And you recompiled the assets? npm run dev ?

Activity icon

Replied to Yaira DataTable Insert Not Inline

@palla451 because you cannot use Laravel helpers within a JS file:

ajax: "{{ route('inputs.index') }}",

this can be used in .blade.php but not in .js file.. You should change the URL's.

Activity icon

Replied to Resource Instead Of Response()->json()

Steps that I will try is delete the lines that I doubt that don't work while doing a search and putting them back one by one until I find what causes the problem exactly.

Check the response from both getUsers and doSearch and make sure that the data returned has the same structure and same data type ie, array of objects.

Don't know how else to help here.

Activity icon

Replied to Resource Instead Of Response()->json()

Does your collection contains empty items? And is each item an object?

Activity icon

Replied to Resource Instead Of Response()->json()

As it is undefined than you should check if there are any users before you do the logic, maybe this will do it:

atLeastOneOpened() {
      return this.users !== undefined && this.users.some(friend => friend.session && friend.session.open);
},
Activity icon

Replied to Resource Instead Of Response()->json()

@splendidkeen you keep using the old way.. but you said this:

which lacks the information structured in the UserResource

So I am saying that you need to return the UserResource with the filtered collection, so you get the same response as with the one that works.

Activity icon

Replied to Resource Instead Of Response()->json()

Try adding this:

success: function (data) {
    console.log(data);
    self.users = data.users;
}

when you do the search, and make sure you get the data correctly.

Activity icon

Replied to Resource Instead Of Response()->json()

@splendidkeen for some reason your this.users is undefined. So in your Vue component do you set the result from the response to the this.users the same way as when you call the getUsers() method?

Activity icon

Replied to Resource Instead Of Response()->json()

@splendidkeen and why not returning the same UserResource from the doSearch method?

$filteredUsers = // perform the filter based on the search


return UserResource::collection($filteredUsers); 

This does not work?

Mar
21
1 week ago
Activity icon

Replied to Sanctum Csrf Cookie

@ezrab_ here is a tutorial that you might find useful: https://medium.com/@godilite/using-laravel-airlock-with-vuejs-1d343ee6f10

And no you should not check for each request if the cookie is set, this is done only on login/registration.

And once you have successfully registered the user, you should not be required to login again. You will need to create a token for the registered user, and then use that token to authenticate/authorize the user.

Activity icon

Replied to Set A From Email, From A Form Contact

@floatinghero105

this is probably because this request("email") contains the same mail that you are hard-coding..

So in your controller, before you send the email, try debugging that using :

dd(request("email"));

And you probably want the ->from() to be set to an email from which you want the receiver of the email to get the message from and not set it dynamically as you do.

Activity icon

Replied to Validation In Controller Or Service Layer

I would put it in a custom form request: https://laravel.com/docs/7.x/validation#form-request-validation

so the controller passes already validated data to the service layer.

Activity icon

Awarded Best Reply on Laravel 7 + MailHog

@konstruktionsplan share the code which you use to send an email.

you have MAIL_FROM_ADDRESS set to null. Are you setting ->from('email address here') explicitly while sending an email?