Nakov

Nakov

at SOLID Solutions

Member Since 4 Years Ago

Skopje

Experience Points
654,690
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
1613
Lessons
Completed
Best Reply Awards
822
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
654,690 XP
Jan
26
7 hours ago
Activity icon

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

The error says it all

$data = User::where('email',$request->get('email'))->first();

This results in null. Use firstOrFail it will throw an exception as the user with the given email could not be found.

Activity icon

Replied to Form Not Submitting In Remote Server

@mrkarma4ya 403 means forbidden access, so that will happen if you have a resource authorization and the user is not allowed to hit the route. It could also happen if you have a Custom request where you add a validation, so the authorize method returns false within, make it return true or add an authorization there as you need it.

Activity icon

Replied to Form Not Submitting In Remote Server

@mrkarma4ya

Make sure you have APP_KEY in your .env file.

Comment out all the other routes above the one that does not work and make sure there is no conflict between two routes.

If you are making an AJAX request you can debug it why it is not posting, check the network tab as well.

Jan
24
2 days ago
Activity icon

Awarded Best Reply on Laravel Mutator Not Converting Null Into Empty String

@bigweld86

Then make it optional, because you don't have control of the source code. I bet it tries to call the accessor without a parameter

public function getPhoneAttribute(?string $phone)

// or

public function getPhoneAttribute(string $phone = null) 
Activity icon

Replied to Checkbox Validation Error Message Displaying Wrongly

@rider

for a checkbox to exist in the request at least one needs to be selected.

Then you are missing the error blade directive that I have shared above. That prints the error on the view.

Jan
23
3 days ago
Activity icon

Replied to Laravel Mutator Not Converting Null Into Empty String

@bigweld86

Then make it optional, because you don't have control of the source code. I bet it tries to call the accessor without a parameter

public function getPhoneAttribute(?string $phone)

// or

public function getPhoneAttribute(string $phone = null) 
Activity icon

Replied to Laravel Mutator Not Converting Null Into Empty String

@bigweld86

or just remove the type check on the accessor

public function getPhoneAttribute($phone) 
Activity icon

Replied to Custom Function In Resource Route ?

Resource controller is just like any other controller which just gives you the 7 default actions, but you can modify them add new whatever you want

https://laravel.com/docs/master/controllers#restful-supplementing-resource-controllers

Activity icon

Awarded Best Reply on SQLSTATE[01000]: Warning: 1265 Data Truncated For Column

@hetalpatel

Why I see you are trying to add 3' for a category_id.. Remove the ' from the value.

Jan
22
4 days ago
Activity icon

Awarded Best Reply on How To Change Is_active To 2 Instead To Delete

Something like this?

public function destroy(Request $request, $id)
{
    $department = OrgDepartment::find($id);
    $department->is_active = 2;
    $department->save();

    Session::flash('success', 'Department deleted successfully.');
    return redirect()->route('organization.departments.index');
}
Activity icon

Replied to How To Change Is_active To 2 Instead To Delete

Something like this?

public function destroy(Request $request, $id)
{
    $department = OrgDepartment::find($id);
    $department->is_active = 2;
    $department->save();

    Session::flash('success', 'Department deleted successfully.');
    return redirect()->route('organization.departments.index');
}
Activity icon

Replied to SQLSTATE[01000]: Warning: 1265 Data Truncated For Column

@hetalpatel

Why I see you are trying to add 3' for a category_id.. Remove the ' from the value.

Activity icon

Replied to Checkbox Validation Error Message Displaying Wrongly

@rider

If you just don't use the Form collective package you will be much better of, for example:

<div class="form-check form-check-inline">
    <input type="checkbox" name="client_category[]" id="inlineCheckbox1" value="1" />    
    <label class="form-check-label" for="inlineCheckbox1">Shipper</label>
</div>

<div class="form-check form-check-inline">
    <input type="checkbox" name="client_category[]" id="inlineCheckbox2" value="2" />    
    <label class="form-check-label" for="inlineCheckbox2">Carrier</label>
</div>

<div class="form-check form-check-inline">
    <input type="checkbox" name="client_category[]" id="inlineCheckbox3" value="3" />    
    <label class="form-check-label" for="inlineCheckbox3">Broker</label>
</div>

<div class="form-check form-check-inline">
    <input type="checkbox" name="client_category[]" id="inlineCheckbox4" value="4" />    
    <label class="form-check-label" for="inlineCheckbox4">Others</label>
</div>

@error('client_category') 
    <p> {{ $message }} </p>
@enderror 
Activity icon

Replied to How Do You Publish Laravel Project ?

@jukka

I use DigitalOcean with backups on, and I use Laravel Forge. There are good series here on Laracasts for using both.

Activity icon

Replied to Upload Store File Return Wrong Path

@deshiloh I don't see anything dirty in this approach :) I'll do the same :)

Activity icon

Replied to Laravel Permission

@bony how will you authorize a person to perform an action to a resource while not knowing the permission name? How will you know the action that the user wants to perform? And by you here I mean the programmer.

Activity icon

Replied to Upload Store File Return Wrong Path

@deshiloh I believe you are doing it right, but have you checked it the merge works properly?

What if you try before the create on the model to dump dd($request->except(['_token']));?

Or try replacing merge with add.

Activity icon

Awarded Best Reply on Save Data In Multiple Tables At Once

@siewlon6093

An example of what? Of your exact software that you are building ?

You need to define relationships as you want them, I gave you a link to the documentation, and there over 1500 videos on Laracasts for you to learn Laravel.

Activity icon

Replied to Save Data In Multiple Tables At Once

@siewlon6093

An example of what? Of your exact software that you are building ?

You need to define relationships as you want them, I gave you a link to the documentation, and there over 1500 videos on Laracasts for you to learn Laravel.

Activity icon

Awarded Best Reply on Undefined Variable: Products

@slowhand

So in your adminNewlesson.blade.php view are trying to use $products which you are not passing to the view. You should do the same as you did for the lessons.blade.php view:

public function adminNewlesson()
{
    $products = Product::all();
    return view('admin.adminNewlesson', compact('products'));
}
Activity icon

Replied to Undefined Variable: Products

@slowhand if it helped please hit the "Best Answer" button on my reply above :)

Activity icon

Replied to Save Data In Multiple Tables At Once

@siewlon6093

You have no reference between a Customer and a User, so you need to define your relationship, and then update a column that you want.

Please watch some videos here on Laravel if you are new and learn the process, or follow the documentation as well.

Here is the documentation for the relationships: https://laravel.com/docs/master/eloquent-relationships

Activity icon

Replied to Undefined Variable: Products

@slowhand

So in your adminNewlesson.blade.php view are trying to use $products which you are not passing to the view. You should do the same as you did for the lessons.blade.php view:

public function adminNewlesson()
{
    $products = Product::all();
    return view('admin.adminNewlesson', compact('products'));
}
Activity icon

Replied to Unknown Column

@siewlon6093 the solution is to add this:

$table->boolean('last_login_at')->nullable();

to your customers table migration.

Activity icon

Replied to Unknown Column

@siewlon6093

You will get that error because there is no such column in the customers table. You have it in your users table.

Activity icon

Replied to Unknown Column

@siewlon6093 just in case it is case-sensitive, try this instead:

$user->last_login_at =1;

you have it with a capital L.

Activity icon

Replied to Unclear "customize Timestamps"

@untymage

Well it won't do that for you. You will have to remove the

$table->timestamps();

And create your own.

If you click through in your IDE, and the underlying code is this:

public function timestamps($precision = 0)
{
    $this->timestamp('created_at', $precision)->nullable();

    $this->timestamp('updated_at', $precision)->nullable();
}

So there is no way to change those with a constant on a model. But create them yourself.

Activity icon

Replied to Unclear "customize Timestamps"

@untymage

Have you done this

So first i have to remove the $table->timestamps(); in the migration, Then create the $table->timestamp('last_update') in the migration

Before you ran the migration? Check your database and make sure that your fields got the new names.

Activity icon

Replied to Difference Between Passport And Airlock

Hey @mammadataei

Take a look at this great post : https://divinglaravel.com/authentication-and-laravel-airlock

The last part gives you the answer as well :) but please read it fully, it will clear things up for you.

Jan
21
5 days ago
Activity icon

Replied to Adding JSON From EXCEL

The same conversation was going on here , https://laracasts.com/discuss/channels/laravel/dynamic-data but @mehmetanbaki finds it hard to understand

Activity icon

Awarded Best Reply on Controller Not Validating After First Error

@pllaguno

The thing is that the cookie allows only 4kb of data, and in your case you are exceeding it, which makes the session not being able to contain the data and display it back to the view.

As the errors from the validation are stored in a session variable called errors and returned to the view. So using file gives it a bigger storage.

Activity icon

Replied to Controller Not Validating After First Error

@pllaguno

The thing is that the cookie allows only 4kb of data, and in your case you are exceeding it, which makes the session not being able to contain the data and display it back to the view.

As the errors from the validation are stored in a session variable called errors and returned to the view. So using file gives it a bigger storage.

Activity icon

Replied to Controller Not Validating After First Error

@pllaguno

If you are on a 6.* version of laravel prior to 6.11 the SESSION_DRIVER by default is set to cookie.

Add this to your .env file it will work:

SESSION_DRIVER=file
Activity icon

Replied to Remove Button After 30 Minutes.

@msslgomez

I still don't get it why it will be an infinite loop, when it should just check for the number of replies or comments that you have, but that will be it.

You should also apply the check only if the comment or reply is written by the current user, and not for every single item, which will reduce the number of times the difference is checked.

Activity icon

Replied to Remove Button After 30 Minutes.

@msslgomez

The other check can be done server side, before you return the comments/replies to the front-end, and add an additional flag to the comment itself i the current user is authorized to edit..

But there is no way an infinite loop can be triggered on the front-end as well. So I will do it as we've already discussed as well. Unless there is something that I am missing, this is the way to go.

Activity icon

Replied to Remove Button After 30 Minutes.

@msslgomez

I don't get it how will you create an infinite loop. You will have to check for each item, when it was created. So I don't have an idea on your view or how do you display the items/comments.

Activity icon

Replied to Remove Button After 30 Minutes.

@msslgomez

Why an infinite loop? Just call the method when the component has been created as I've shown you above and that's it.

Activity icon

Replied to Remove Button After 30 Minutes.

@msslgomez please watch some Vue tutorials or read the documentation my friend, as these are basics..

created: function () {
    // add it here
},

mounted: function () {
    // or add it here
},

Or computed property: https://vuejs.org/v2/guide/computed.html#ad

Activity icon

Replied to Dynamic Data

@mehmetanbaki

You cannot create columns in a database dynamically with an Excel import.

Activity icon

Replied to Remove Button After 30 Minutes.

@msslgomez

I just gave you an example, keep in mind that that code uses moment() library which you need to look on Google on how to include it in your project, and use it with Vue, here is how: https://stackoverflow.com/questions/34308004/moment-js-with-vuejs

Then you will add it as a computed property, or when the Vue component is created.

Activity icon

Replied to Remove Button After 30 Minutes.

@msslgomez

Something like this:

let minutes = moment().diff(moment(this.comment.created_at), 'minutes');

if(minutes > 30) {
   this.dialogFormVisible = false;
}
Activity icon

Replied to Remove Button After 30 Minutes.

@msslgomez

why not checking the comment created_at date, if it is more then 30 minutes, then disable the button.

You can use MomentJS library to check that.

Activity icon

Replied to Dynamic Data

@mehmetanbaki

No I think that you don't understand me :)

In your CustomerImport, try this:

class CustomerImport implements ToModel, WithHeadingRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        dd($row);

        return new Customer([
            'data' => json_encode($row),
        ]);
    }
}

This will tell you what data you have for each row in the Excel file.

Then you will replace each of those with the columns that exist in your DATABASE:

class CustomerImport implements ToModel, WithHeadingRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        return new Customer([
            'CustomerName' => $row[INDEX_OR_NAME_OF_THE_COLUMN],
            'Gender' => $row[INDEX_OR_NAME_OF_THE_COLUMN],
            'Address' => $row[INDEX_OR_NAME_OF_THE_COLUMN],
            'City' => $row[INDEX_OR_NAME_OF_THE_COLUMN],
            'PostalCode' => $row[INDEX_OR_NAME_OF_THE_COLUMN],
            'Country' => $row[INDEX_OR_NAME_OF_THE_COLUMN],
        ]);
    }
}

Just replace in the brackets what you see above with the index value for example $row[0] will return CustomerName, or if there is a named key, use the name..

I hope you understand now :)

Activity icon

Replied to Dynamic Data

@mehmetanbaki you can stop refreshing the page, you will get notification by email and here on Laracasts when someone replies to your post.

As I said, you need this:

return new Customer([
            'CustomerName' => $row['customer_name'],
  // add all other fields here
        ]);

This

 return new Customer([
            'data' => json_encode($row),
        ]);

will never work!

Activity icon

Replied to Dynamic Data

@mehmetanbaki

There is no data column in the Customer table, so that's wrong.

What does the $row returns for you, is it an array of items?

You will need to create an instance of the customer, for example:

 return new Customer([
            'CustomerName' => $row['customer_name'],
  // add all other fields here
        ]);

or something like that, or if the headers in the Excel file match the columns in your database, just use what I've shown you in the first reply.

DEBUG what you have in the row, using dd($row);.

Activity icon

Awarded Best Reply on Name For This?

"Data casting", not type hinting.

Activity icon

Replied to Name For This?

"Data casting", not type hinting.

Activity icon

Replied to Name For This?

@konstruktionsplan

The (int) before is used to cast the value coming from $request->get('site') into integer, in case it is a string for example '1' it will become 1.