Nakov

Nakov

at SOLID Solutions

Member Since 4 Years Ago

Skopje

Experience Points
739,200
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
1710
Lessons
Completed
Best Reply Awards
947
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
739,200 XP
Jul
08
1 day ago
Activity icon

Awarded Best Reply on Pivot Table Extra Field Update

So something like this maybe:

App\User::find(1)->procurements()->save($procurement, ['bided' => 1]);

or this

$user->procurements()->updateExistingPivot(
            $procurement->id,
            ['bided' => 1]
        );

https://laravel.com/docs/7.x/eloquent-relationships#updating-many-to-many-relationships

Activity icon

Replied to Trying To Use SortBy() Or SortByDesc() Gives Error And Last() As Well.

You are trying to use Collection methods on a Eloquent Builder instance.

so this:

 $lastbill = Bill::where('project_id', $project->id)->where('bill_type', 'p')
    ->get() // this should give you collection
    ->sortByDesc('created_at')->first();

same here:

$lastbill = Bill::where('project_id', $project->id)->where('bill_type', 'p')->get()->last();
Activity icon

Replied to Pivot Table Extra Field Update

So something like this maybe:

App\User::find(1)->procurements()->save($procurement, ['bided' => 1]);

or this

$user->procurements()->updateExistingPivot(
            $procurement->id,
            ['bided' => 1]
        );

https://laravel.com/docs/7.x/eloquent-relationships#updating-many-to-many-relationships

Jul
07
2 days ago
Activity icon

Replied to Redirect After POST Call

You cannot return a redirect if you are using fetch on the client side. You should handle the redirect on the client side as well. So

fetch(
    //do the post here
).then(function() { 
    // handle your redirect here, if it was successful. 
});
Jul
05
4 days ago
Activity icon

Replied to Undefined Property, But Other Columns Do Work

@jeroenvanrensen

What I am saying is that this:

public function getPrimaryColumnAttribute()
{
    return $this->primary_column;
}

doesn't make sense.. you can take the value out of the row and column by finding the row which you need and then directly access the column if it exists as you said:

$moonCrud = MoonCrud::find(1);

$moonCrud->primary_column;

Should give you what you want.

Activity icon

Replied to Undefined Property, But Other Columns Do Work

Why would you name the accessor method the same as your column, unless you want to modify the existing value?

In case you want to modify an existing value, then take a look at the documentation for its usage:

https://laravel.com/docs/master/eloquent-mutators#accessors-and-mutators

Basically you need this:

public function getPrimaryColumnAttribute($value)
{
    return $value;
}

Because calling $this->primary_column is like calling the same method over and over again.

Jul
04
5 days ago
Activity icon

Replied to Why My Link Isn't Work? Routes Category/post

@hekmatyar good job on trying to solve it :) you are becoming a programmer :)

so this is what you have in your controller:

$posts = Post::orderBy('created_at', 'desc')->where('status', 'published')->simplePaginate(4);
 
$categories = Category::all();
 
return view('layouts.blog', compact('posts', 'categories'));	

You are passing a collection of Categories, not a single category. Then who knows what you are doing in the view :)

but in order to access a single category, you will need to iterate over your categories:

@foreach($categories as $category)

// THEN HERE YOU WILL HAVE ACCESS TO A $category

@endforeach

You probably have a long way to go and learn the basics :)

Activity icon

Replied to How To Use The Toggle Method For A HasMany Relationship

I don't know for a toggle method, but there is a sync method on Many to Many that provides that. There is already an answer for this here: https://laracasts.com/discuss/channels/eloquent/sync-hasmany

Take a look if it helps your case.

Activity icon

Replied to Why My Link Isn't Work? Routes Category/post

When you use Route model binding the expected column is the ID not the SLUG nor any other custom column unless you tell laravel to do so, so in your Post model add this :

public function getRouteKeyName()
{
    return 'slug';
}

for reference: https://laravel.com/docs/master/routing#route-model-binding

And then just use your named route instead of the url, so it will be:

{{ route('show', [$category, $post]) }}

And it should work.

Activity icon

Replied to How To Clear Cache After Logout

Using browser back button is normal case, but still being able to interact with the site as if there was a logged in user, that means that you are not guarding your endpoints with the auth middleware.So check your routes file for that, and group the protected endpoints with the auth middleware.

Also why do you need to specify the guard on the Auth facade, isn't it web your default guard or you have changes in your auth.php file?

Activity icon

Replied to Website

The Laravel docs maybe? https://laravel.com/docs/7.x/routing

it says all of that :)

Jul
03
6 days ago
Activity icon

Replied to Laravel Project Not Working

You have a problem with permissions on your folders. Here is an extensive answer on how to solve permission problems: https://stackoverflow.com/a/37266353/1457270

Jul
01
1 week ago
Activity icon

Replied to Error: BadMethodCallException Method Illuminate\Database\Eloquent\Collection::with Does Not Exist.

@luis100079 to what is your myFollowers a hasMany?

$this->hasMany(User::class);

or what?

if it is a User or whatever model, in there you are missing the chat_received relationship.. for example:

public function chat_received()
{
    return $this->belongsTo(ChatReceived::class);
}
Activity icon

Replied to Error: BadMethodCallException Method Illuminate\Database\Eloquent\Collection::with Does Not Exist.

It means that the with() method does not exists on a Collection instance :)

Try this:

return $user->myFollowers()->with('chat_received:id,message')->get();
Activity icon

Replied to Error On Email Validation

@van1310 I answered the question that you initially asked. Now for this one, I really don't know what input data you are using.

  • another thing is that you have this one:
$user_data = CompanyOnboardingForm1::select('user_id','created_tab_no')->where('id', $request->id)->first();

which uses the $request->id and then you check if that one exists and it is passed.

So you need to check your data and your rule.

The initial question is already resolved.

Activity icon

Replied to Error On Email Validation

You cannot use conditionals in an array like that directly. Extract that part

$rules = [
    'company_email' => 'required|email|unique:users,email,NULL,NULL,deleted_at,NULL'
];

if ($request->id)
{
  $rules = [
    'company_email' => 'required|email|unique:users,email,' . $user_data->user_id . ',id,deleted_at,NULL',
  ];
}

$validator = Validator::make($request->all(), $rules);
Jun
30
1 week ago
Activity icon

Replied to Illuminate/Database/QueryException While Seeding The Database With Fake

I guess this line:

$tenant->mother_meter()->save($mother_meter);

throws the exception. Since you are saying to attach a mother meter to a tenant, and your mother_meter table does not have any tenant_id field which needs to be referenced.

Make sure that in your Tenant model, your relationship to mother_meter is setup correctly. I cannot understand your fields based on the image, so I cannot help much more.

public function mother_meter()
{
     return $this->hasMany(MotherMeter::class, 'COLUMN_NAME_HERE_FROM_THE_MOTHER_METER_TABLE', 'id');
}

id is the ID on the local Tenant table.

Jun
29
1 week ago
Activity icon

Awarded Best Reply on How To Get Users Login Logs

@noblemfd maybe like this:

$haventLoggedIn = User::whereDate('last_login_at', '<', now()->subDays(30))
	->orWhereNull('last_login_at')
	->get();
Activity icon

Replied to How To Get Users Login Logs

@noblemfd maybe like this:

$haventLoggedIn = User::whereDate('last_login_at', '<', now()->subDays(30))
	->orWhereNull('last_login_at')
	->get();
Activity icon

Replied to How To Get Users Login Logs

For the first:

$loggedIn = User::whereBetween('last_login_at', [now()->subDays(30), now()])->get();

And for the 2nd.

$haventLoggedIn = User::whereDate('last_login_at', '<', now()->subDays(30))->get();

Try this :)

Activity icon

Replied to WhereBetween Without Year, Is Possible?

You can by using a raw query. For example:

Report::whereRaw("(DATE_FORMAT(date, '%m-%d') BETWEEN ? and ?)", ['05-30', '06-30'])->get();
Jun
28
1 week ago
Activity icon

Awarded Best Reply on How Can I Make $faker->paragraph Longer?

And here is the definition of the method itself:

@method string paragraph($nbSentences = 3, $variableNbSentences = true)

which means the default is 3 sentences, so it can't be short as a sentence. But still you can pass bigger number:

$faker->paragraph(10)

as an example.

Activity icon

Replied to How Can I Make $faker->paragraph Longer?

And here is the definition of the method itself:

@method string paragraph($nbSentences = 3, $variableNbSentences = true)

which means the default is 3 sentences, so it can't be short as a sentence. But still you can pass bigger number:

$faker->paragraph(10)

as an example.

Activity icon

Awarded Best Reply on Changing Minimum Characters For Password

Open up RegisterController which you can find within App\Http\Controllers\Auth and change this line:

'password' => 'required|string|min:8|confirmed',

you see the min:8 rule there.

Activity icon

Replied to Laravel 7 Eloquent Chain Error

Or you can use the optional helper method

https://laravel.com/docs/7.x/helpers#method-optional

but that will just return null.

Anyhow, I don't think that this part will work neither: ->group->users. So you should rethink what you are trying to achieve here.

Activity icon

Replied to Changing Minimum Characters For Password

Open up RegisterController which you can find within App\Http\Controllers\Auth and change this line:

'password' => 'required|string|min:8|confirmed',

you see the min:8 rule there.

Jun
27
1 week ago
Activity icon

Awarded Best Reply on Laravel: Id From Input, To Store Controller

@linc

So first of all, you need to close the form after all the input elements.

<form name="form" action="{{route('payment.process')}}"  method="post">
@csrf
@method('POST')
    <div class="form-group">
        <input type="hidden"  class="form-control" name="promotion" id="promotion" value="{{ $promotion->id }}">
    </div>
    <button type="button" class="btn btn-success" id="submit-button"> Conferma e attiva la promo </button>
</form>

and then because you have name="promotion" in the controller you will have to use the same attribute as in the name, so here:

dd($request->input('promotion'));
Activity icon

Replied to Laravel: Id From Input, To Store Controller

@linc

So first of all, you need to close the form after all the input elements.

<form name="form" action="{{route('payment.process')}}"  method="post">
@csrf
@method('POST')
    <div class="form-group">
        <input type="hidden"  class="form-control" name="promotion" id="promotion" value="{{ $promotion->id }}">
    </div>
    <button type="button" class="btn btn-success" id="submit-button"> Conferma e attiva la promo </button>
</form>

and then because you have name="promotion" in the controller you will have to use the same attribute as in the name, so here:

dd($request->input('promotion'));
Activity icon

Replied to Images Not Showing Up In View!!

Did you forget to run php artisan storage:link maybe?

https://laravel.com/docs/master/filesystem#the-public-disk

This will create a symlink within your public directory, which will make those images available to show.

Activity icon

Replied to PLUCK Is Giving Lesser Values Than Actual In Table

@saadaan good, so exactly what I said :)

Activity icon

Replied to Generate Factory With Custom Data

Maybe like this:

foreach(['a','b','c','d','e','f'] as $category)
{
    factory(Category::class)->create(['name' => $category]);
}
Activity icon

Replied to PLUCK Is Giving Lesser Values Than Actual In Table

Okay, take a look at your laravel configuration, so in your .env file check what DB connection are you using, and make sure you are connected to the same database to which you are running manual queries in.

And I don't understand your point with the latest comment :) so you got all then, what's the matter?

EDIT

So it might be because of duplicates, you don't have values. As that tries to return a KEY => VALUE array.

Activity icon

Replied to PLUCK Is Giving Lesser Values Than Actual In Table

When you say the table has all the values, are you looking in the township_code table in the database, or you tried doing this:

dd(DB::table("township_code")->count());
Activity icon

Replied to PLUCK Is Giving Lesser Values Than Actual In Table

@saadaan pluck returns a collection, so what would this give: $tcode->count()?

Jun
26
1 week ago
Activity icon

Awarded Best Reply on Register New User

@msslgomez I believe that the problem is that your input name is password_confirm while based on the validation rule, the name of the field should be password_confirmation instead.

https://laravel.com/docs/master/validation#rule-confirmed

So change this

password_confirm: this.reg_form.password_confirm,

with

password_confirmation: this.reg_form.password_confirm,
Activity icon

Replied to Register New User

@msslgomez I believe that the problem is that your input name is password_confirm while based on the validation rule, the name of the field should be password_confirmation instead.

https://laravel.com/docs/master/validation#rule-confirmed

So change this

password_confirm: this.reg_form.password_confirm,

with

password_confirmation: this.reg_form.password_confirm,
Activity icon

Awarded Best Reply on Cashier: Create Subscription Specifying Stripe Data

@msr2406 There is a noProrate() method on the subscription actually.. Take a look here:

https://laravel.com/docs/master/billing#subscription-quantity

So you can call it as such:

$user->subscription()->noProrate();
Jun
24
2 weeks ago
Activity icon

Replied to How To Make The Application Show The Specific Error To The User

@noblemfd

$exception->getMessage()

should contain more specific error message than your custom one.

Activity icon

Replied to Laravel Accessor Attribute Not Working In Vuejs Template

Your naming is a bit off and the format of the date

// here should be due_date if that's a column you are adding, I assume that `date` already
// exists in your database
protected $appends = ['due_date'];

public function getDueDateAttribute()
{
    return Carbon::parse($this->attributes['date'])->format('d/m/Y');
}

now before you pipe it to a formatter, try printing it out as it is:

  <td>{{ product.due_date }}</td>

isn't this showing anything?

Jun
22
2 weeks ago
Activity icon

Awarded Best Reply on App\Mail\ContactMe

@hemantadsl you are missing an import.

Add:

use App\Mail\ContactMe;

in your controller.

Activity icon

Awarded Best Reply on Foreach( App\Post::all() As $post ){ Return $post->user->name; }

@luis100079 return stops the execution on any other call. So that's why it returns just the first one.

You can try the following instead:

$posts = Post::with('user:id,name')->get();

Now all of the posts will have the user name.

Activity icon

Replied to Foreach( App\Post::all() As $post ){ Return $post->user->name; }

@luis100079 return stops the execution on any other call. So that's why it returns just the first one.

You can try the following instead:

$posts = Post::with('user:id,name')->get();

Now all of the posts will have the user name.

Jun
20
2 weeks ago
Activity icon

Replied to ->with() Is Sometimes Session, Sometimes Variable, Why?

The name of the method is the same, it is called on two different objects, and the behavior is different.

It is like two guys with the same name 😃 nothing wrong with that.

Activity icon

Replied to ->with() Is Sometimes Session, Sometimes Variable, Why?

Because the response type is different. When you redirect, then you are hitting another controller action which returns the view that needs to be displayed. So in order to preserve the data that you are trying to pass, laravel uses flash session using the with() method: https://laravel.com/docs/7.x/redirects#redirecting-with-flashed-session-data

And when you respond with an HTML rendered view, using the view() helper, the with() method passes the data directly to the view and you get the values that you've passed by using their keys (variables): https://laravel.com/docs/7.x/views#passing-data-to-views

Jun
19
2 weeks ago
Activity icon

Awarded Best Reply on Column Not Found

You can try and provide the idColumn as a last parameter: https://laravel.com/docs/master/validation#rule-unique

public function rules()
{
    return [
        'name' => ['required', 'string', 'unique:rooms,name,'.$this->room->name . ',name']
    ];
}
Activity icon

Replied to Column Not Found

You can try and provide the idColumn as a last parameter: https://laravel.com/docs/master/validation#rule-unique

public function rules()
{
    return [
        'name' => ['required', 'string', 'unique:rooms,name,'.$this->room->name . ',name']
    ];
}