Nakov

Nakov

Member Since 3 Years Ago

Skopje

at SOLID Solutions

Experience Points 167,560
Experience Level 34

2,440 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 1232
Lessons
Completed
Best Reply Awards 76
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

26 Jun
21 hours ago

Nakov left a reply on Collection Reverse Issues

What do you mean by making it more readable? By reversed you expect: Calgary, Alberta, Canada?

I tried the same code from your question in a tinker session and I got the reversed result.

Nakov left a reply on Call To A Member Function Save() On Array

The error is self descriptive, you are trying to call save on an array, why do you have $document[]?

You can do the following instead:

Document::create([
    'user_id'=>$request->get('user_id'),
    'doc_type' => $files,
    'doc_path' => $picName,
]);

Assuming that your Document is an Eloquent model.

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

@CHRON - Please read the documentation. I am using custom form requests in my project and it is never redirect to a different route then the one from which I am submitting the form. I don't have your codebase so it is really hard to tell this way what is going on. Please consider some of the suggestions here, but read the official documentation there are very good examples in it as well. Happy coding!

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

@CHRON - The Custom request automatically does that for you, so for example:

public function store(YourCustomRequest $request)
{
   // the code in here will be executed ONLY if the validation passed. 
   // so the `rules` that you define in the custom request are the same as you define them on the Validator here


  // so create your records here and you are safe that the validation has passed.
}

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

@CHRON - I really don't understand your use case my friend. Why would you have multiple forms on a page that are using the same endpoint to store records? You should just separate that so each form will submit the content to a different url, then each validator will validate what needs to be validated and create the record.

You can also take advantage of the Custom form request where you will put the validation rules and this will handle redirecting back with errors and so on. So your controller method will be responsible just for creating the record.

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

@CHRON - The validator is separate to the creation of the record. So you first validate the data, then if it is valid and this check

if ($validator->fails()) {
         return redirect()->route('customer.create')
         ->withErrors($accountValidated->errors()->merge($infoValidated->errors()))
         ->withInput();
}

is passed, then bellow that you can still use the request data, and also being sure that everything is right in it.

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

@CHRON - The validation is done on the same form request so it can be one. Then in order to create each resource individually you can still use:

Account::create($request->only('email' ...));

And create your other resource with the other fields. The point is you can have one validator per form request, then create the resources as needed.

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

@CHRON - Yes you can, those will be ignored automatically. Same as if you haven't added them in the $fillable array of your modal. The extra fields are ignored preventing mass assignment.

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

@CHRON - Of course it is, I didn't know your business logic and thought that you might need it specifically to be separated, but you can do the following:

$data = Validator::make($request->only([
        'firstname','middlename','lastname', 'email' // ... other fields
    ]),
     [
        'firstname' => 'required|string|min:2',
        'middlename' => 'nullable',
        'lastname' => 'required|string|min:2',
    //and other fields
    ]);

Account::create($data);
25 Jun
1 day ago

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

@CHRON - Then you need to make the array when creating with the field name:

Account::create([
    'email' => $infoValidated['email'],
    ...
]);

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

@CHRON - That's a different error, share that part of the code please.

Nakov left a reply on How To Pass Multiple Variables In WithErrors?

There is a merge method on the MessageBag object so you can try to merge them and return them like this:

if ($accountValidated->fails() || $infoValidated->fails()) {
         return redirect()->route('customer.create')
         ->withErrors($accountValidated->errors()->merge($infoValidated->errors()))
         ->withInput();
}

Please let me know if it does work this way. I have tried merging before, but not your case exactly.

Nakov left a reply on @error Only Rendered As Text

@CHRON - @chron you're welcome. Consider accepting the answer, someone else might find it helpful.

Nakov left a reply on @error Only Rendered As Text

The error directive was added in Laravel 5.8.13 version so update that. And then you can use it like this:

@error('contact_number')
        <span class="invalid-feedback" role="alert">
            <strong>{{ $message }}</strong>
        </span>
@enderror
24 Jun
2 days ago

Nakov left a reply on Why Does Laravel Notifications Table Use UUID Instead Of ID?

And here is a StackOverflow answer to your question. I believe it hits the point as there is no documentation for it in the official docs.

Nakov left a reply on Error Like "Undefined Offset: 1"

@ME10071990 - The way you debug this is when you click on the link and it is working for some of the submenu-s, the page that renders should be the same one as for the link that does not work. So most probably there is some data missing, you will need to debug that on your project, why does it work for one link and not for the other, do it step by step setting some debug points. I really don't see anything wrong in the views that you shared so far.

Nakov left a reply on Error Missing Required Parameters

@CQ522138 - You can mark my answer as a "Best answer" if it helped you. Happy coding.

Nakov left a reply on Error Missing Required Parameters

@CQ522138 - In your controller, in post_register_tutor you are redirecting to a named route without passing the id of the tutor, so try changing the bottom two lines with this:

$tutor = $tutor->save();

return redirect()->route('pages.registration', $tutor->id);

Nakov left a reply on Error Like "Undefined Offset: 1"

@ME10071990 - First of, why do you have empty @else block. You can remove that line if you don't use it.

So you say this error appears when you click on a specific link from your menu. So you error is most probably in that view. I cannot see anything wrong in the code that you shared. I assume that this view with the menu renders right as you can click on links.

So in your view when you render the content for the specific page you have a foreach loop which throws the error, if you can share that code as well I'll try to help.

Nakov left a reply on Error Like "Undefined Offset: 1"

@ME10071990 - So your error is not coming from the controller but your view. And undefined offset means that you are trying to access an index of an array which does not exists.

Share your view where you have the menu.

Nakov left a reply on Error Like "Undefined Offset: 1"

You should share your code (what you are trying to do), in the view or controller so someone can help.

Nakov left a reply on PHP Traits

Here you go.

Nakov left a reply on Email Verification Problem

@CHRON - Please read what I said in the first comment. It is not secure to allow verification of an email without the user being logged in, also it needs to know which user you are verifying the email for, it updates an email_verified_at field in the users table.

Nakov left a reply on Email Verification Problem

@CHRON - And it does, but you need to be logged in. It cannot verify a not logged in user because of what I said above.

Nakov left a reply on Email Verification Problem

The verification of email updates a email_verified_at field in the users table, which means in order to associate it with a user you've got to be logged in. So I don't see the problem here. Can you share more on why do you think there is a problem here? What do you expect?

23 Jun
3 days ago

Nakov left a reply on Unknown Database Laravel 5.8 New Registration Of User

@MUAZZAMAZAZ - Then try running php artisan config:clear to make sure that you have not cached the config. And also make sure that you don't override the protected $connection property in your User model.

Nakov left a reply on Unknown Database Laravel 5.8 New Registration Of User

@MUAZZAMAZAZ - Then make sure that your .env file is in the root of your project and it does not have any extension on it, for example it is not called .env.txt or whatever else. Check your database.php config file that it reads from the env('DB_DATABASE').

Nakov left a reply on Unknown Database Laravel 5.8 New Registration Of User

In your database have you created a database called laravel because Laravel won't do that for you.

In your terminal you can run

> mysql -uroot -p

// then

> create database laravel;

Nakov left a reply on Laravel Set Date To D-M-Y On Carbon

@ADHIK13TH - You need localization for that, fr_FR is just an example that Snapey gave you, that's a French locale. You can take a look on other answers here for example on how to solve this.

Nakov left a reply on Laravel Set Date To D-M-Y On Carbon

@ADHIK13TH - Which one did you tried? You show an example above that your date has a value of 2019-06-19

If you try in tinker you will get this:

>>> (new Carbon\Carbon("2019-06-19"))->format('d-F-Y');
=> "19-June-2019"

So make sure that your date is not null and you are using one of the approaches I gave you above.

Nakov left a reply on Laravel Set Date To D-M-Y On Carbon

In your Training model add this:

protected $casts = [
    'date' => 'date:d-F-Y',
];
22 Jun
4 days ago

Nakov left a reply on The DELETE Method Is Not Supported For This Route

@UFODISKO - You are getting that because your destroy method signature is wrong. If you notice the route, you first are passing a $channel then the $thread so change it to this:

public function destroy($channel, Thread $thread)
{
    $thread->delete();
    if (request()->wantsJson()) {
        return response([], 204);
    }
   return redirect('/threads');
}

Nakov left a reply on The DELETE Method Is Not Supported For This Route

You are missing the delete route, he may not showed it but you should add it, so bellow your get route to the path, add the delete route like this:

// bellow this one
Route::get('/threads/{channel}/{thread}', ['as' => 'thread.show', 'uses' => '[email protected]']);
// this is missing
Route::delete('threads/{channel}/{thread}', '[email protected]');

Nakov left a reply on Carbon Date/Time Limits On Functions Such As AddDays()

And here is a very good StackOverflow answer to the question and confirmation on what @deansatch said above.

Nakov left a reply on Laravel 5.7 , Where Clause With Multiple Values

@MICHEAL - Does not work means that you don't get any results back, or what is the problem. You can try to debug it by printing out the query using dd($data->toSql()); before you call the $data->get(). And make sure that the SQL query is as it should be. Try it on your database make sure that it is correct.

Nakov left a reply on Laravel 5.7 , Where Clause With Multiple Values

The last condition when you check for both I don't think it is needed because you already are filtering using both.

So you can delete this part:

if ($request->driverid and $request->routeid) {
    $data->where([
        'trips.driver_id', '=' , $request->driverid,
        'trips.route_id', '=' ,  $request->routeid
    ]);
}

Because this:

if ($request->driverid) {
    $data->where('trips.driver_id', $request->driverid);
}

// and this
if ($request->routeid){
    $data->where('trips.route_id' , $request->routeid);          
}

are already filtered by.

If you do the opposite, like this:

if ($request->driverid and $request->routeid) {
    $data->where([
        'trips.driver_id' => $request->driverid,
        'trips.route_id'  =>  $request->routeid
    ]);
} else {
    if ($request->driverid) {
        $data->where('trips.driver_id', $request->driverid);
    }

    if ($request->routeid){
        $data->where('trips.route_id' , $request->routeid);          
    }
}

Then you should be good. I removed the = in the multiple checks, as it is a default condition, so you can avoid it.

20 Jun
6 days ago

Nakov left a reply on Illuminate\Database\QueryException : SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

@LITTLEBOBY - Happy to help. Please mark the answer above as the Best Answer so it might help someone else looking for the same issue.

Nakov left a reply on Illuminate\Database\QueryException : SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

@LITTLEBOBY - As I said, you have to change your other factories, not to use random numbers for their relationships, but to also use a factory to create and persist a new record. The record must exist in order to add a relation. So change all your factories based on the first one that I gave you.

I hope I am clear.

Nakov left a reply on Illuminate\Database\QueryException : SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

@LITTLEBOBY - You should follow my code. Your code now does not make sense.

// this will never work.
'created_by' => factory(Meetup::class, 100)->create(['created_by' => $user->id]),

You forgot to import the User that's why you have the error, so either use :

$user = factory(App\User::class)->create();

or put

use App\User;

above the $factory definition.

Nakov left a reply on Illuminate\Database\QueryException : SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

@LITTLEBOBY - No it will not be an existing one, but it will create and persist a new one, and it will associate it with it. If you want to make a relationship to an existing one, you can do the following:

$user = factory(User::class)->create();

factory(Meetup::class, 50)->create(['created_by' => $user->id]);

Nakov left a reply on Illuminate\Database\QueryException : SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

You cannot use a random number as a foreign key, the relationship must exist in order to relate to it, so I will give you an example just for your MeetupSeeder, you can change the rest:

use App\User;
use App\Group;

$factory->define(App\Meetup::class, function (Faker $faker) {
    return [
        'title' => $faker->text(30),
        'description' => $faker->text(200),
        'place' => $faker->streetAddress(),
        'created_by' => factory(User::class),
        'group_id' => factory(Group::class),
        'time_happening' =>$faker->dateTime($max = 'now', $timezone = null)
    ];
});

This will also create a user and associate it with the meetup, and a group which will also be associated with this meetup.

Nakov left a reply on Issue Submitting Form Data From Bootstrap 4 Modal

@MATTB - You should add the dd above the return, like this:

public function rules()
{
    dd(request()->all());

        return [
            //
            'username'=>'required',
            'email'=>'required',
            'password'=>'required',
            'firstName'=>'required',
            'lastName'=>'required',
            'role'=>'required',
        ];

}
19 Jun
1 week ago

Nakov left a reply on How To Get A Excerpt From The Input Data From The Body?

@FORTEIRP - Start fresh it won't hurt. I don't know why it shows on top, but at least all the others are here.

Nakov left a reply on How To Get A Excerpt From The Input Data From The Body?

@FORTEIRP - If you are talking about the {!! !!} around the text area, no it won't escape the html tags, you can escape html tags when you are printing the content, so {!! "<p>test</p>" !!} the paragraph will be escaped.

$post = new Post;

You are creating new post each time this way, so your post with id 1 should not be deleted.

I hope I helped with this reply now, but after this you can accept the answer that helped you and create a new discussion in order to get a response to your problem quicker.

Nakov left a reply on Issue Submitting Form Data From Bootstrap 4 Modal

@MATTB - And you have the import at the top? If you do it is clear that the validation fails. Check in your modal do you have each field name correctly as you are validating, and make sure that you provide each field, as it is required which means it will fail validation if you don't have value for it.

You can add dd(request()->all()) within your rules method in the validation and make sure that you have all the fields there.

Nakov left a reply on Issue Submitting Form Data From Bootstrap 4 Modal

@MATTB - I mean there must be something.. you should check in your browser console, if you get any errors, or in the network tab in the console if the request has been sent or what is going on. I am using form collective in my project and from what you've shown I cannot see anything suspicious.

Nakov left a reply on Issue Submitting Form Data From Bootstrap 4 Modal

@MATTB - Can you try with a regular submit button instead of the Form::submit one.

<button type="submit" class="btn btn-primary">
   Add User
</button>

Nakov left a reply on Issue Submitting Form Data From Bootstrap 4 Modal

Do you have a validation on your form request before hitting the store method on your controller? Maybe the validation is failing and you don't show any errors, but you close the modal anyway.

  • You can debug it by dd(request()->all()) in your controller and check if you get the data.

Nakov left a reply on Default Laravel Notification --> Data Is Not Working

In your Company model do you have use the Notifiable trait like this:

...
use Illuminate\Notifications\Notifiable;

class Company extends Model {

    use Notifiable;

...

}
18 Jun
1 week ago

Nakov left a reply on How To Get A Excerpt From The Input Data From The Body?

I don't see in your code where you are setting the excerpt column, so there are couple of ways to achieve this, you can add it here like this:

$post->excerpt = str_limit($request->body, 100);

Make sure that in your Post model you've got the excerpt in the $fillable array.

The second approach is to use setter in your model:

public function setExcerptAttribute($value)
{
    $this->attributes['excerpt'] = str_limit($value, 100);
}

But then again in your controller you will have to add this:

$post->excerpt = $request->body;