araeuchle

Experience

1,450

0 Best Reply Awards

  • Member Since 5 Months Ago
  • 11 Lessons Completed
  • 0 Favorites

28th January, 2018

araeuchle started a new conversation Count Self Referencing Relations • 4 months ago

Hey guys,

Okay i am working on a laravel 5.5 project.

We have a user table and in this user table we have a parent field. The parent declines the parent relationship of this object.

So each user can have 1 parent but a user can have multiple children.

 public function parent()
{
    return $this->belongsTo(User::class, 'parent_id', 'id');
}

public function children()
{
    return $this->hasMany(User::class, 'parent_id', 'id');
}

What i want to achieve is. I need to count 5 levels deep how many children a user has.

so i want something like:

Level 1: 585 Level 2: 1539 Level 3: 3294 Level 4: 4949 Level 5: 15939

Without loading the actual objects for sure, as it would kill the page performance.

How can i achieve this with laravel? Heres what i tried, but it loads all the subchildren in a collection.

 $sum = User::with('parent')->where('id','=', $user->id)->get();

Somebody can help me out with that?

Just to be more specific:

Lets say User A is parent of B and C

B is parent of D, E, F C has no children.

The correct output should be:

Level 1: 2 Level 2: 3 (as C has no children)

I want to be able to call it like this:

$user->children(2)->count() Which should output the number of children on level 2

is this possible?

21st January, 2018

araeuchle left a reply on Can't Connect To AWS API • 5 months ago

Hmm that is wierd @JoshBruce I've openend up a ticket on AWS support. i cant even create server in any region.

20th January, 2018

araeuchle left a reply on Can't Connect To AWS API • 5 months ago

Okay first problem is solved. i can now connect to AWS when using forge. But i cant create new server.

Getting this error:

Whoops! There were some problems with your input.

The server provider was unable to create your server. Either try contacting your server provider for more details or add a new server provider credential in your account profile.

araeuchle started a new conversation Can't Connect To AWS API • 5 months ago

Hey guys, so today ive registered in AWS and Laravel Forge as well as Laravel Envoyer. Firstable i wanted to create the server on AWS. Ok i've logged into my account in AWS and created a new IAM User. I've created a new Group called Root and attached AdministratorAccess Permission to it. Then i've created AWS API Key and Secret. I've copy & pasted and entered a custom profile name. (I think the profile name can be what i want?) In Laravel Forge when i hit Add Credentials i am getting the error:

Whoops! There were some problems with your input.

Invalid API credentials.

Can u guys tell me what i did wrong? Thanks :)

15th January, 2018

araeuchle started a new conversation Laravel Forge And AWS Hosting Environment • 5 months ago

Hey guys. Ok firstable, Laravel Forge is super awesome! i totally love the idea behind it. But i have one question if this scenario can be achieved with it:

Ok we are going to have the following infrastructure with AWS:

1 Loadbalancer 2 Application Server (EC2 Instances) 1 Amazon Aurora DB 1 Storage Server (Amazon S3)

The application needs to be able to scale horizontally dynamically depending on traffic. Deployments should effect all EC2 Instances running by AWS. Storage Server should be connected to all EC2 instances. It should be possible to select Availability Zones were the servers should be hosted.

Any tip if this can be achieved with forge?

14th January, 2018

araeuchle left a reply on Task Scheduling In A Big Environment With Two Or More Application Servers • 5 months ago

@martinbean: ok awesome! that what i was looking for! thanks for your help!

13th January, 2018

araeuchle left a reply on Task Scheduling In A Big Environment With Two Or More Application Servers • 5 months ago

My understanding problem atm is the following:

The command is called at the same time. so Laravel will have two instances trying to execute the jobs. How is decided which app is executing the job AND is the job really blocked when hit by the other instance first? :)

araeuchle left a reply on Task Scheduling In A Big Environment With Two Or More Application Servers • 5 months ago

@martinbean: Thanks for your answer.

So lets assume i have two application servers running and are connected through Load Balancer. I am build a job and add the job. when i call withoutOverlapping() it should prevent to be Double Triggered. is this right? :)

araeuchle started a new conversation Task Scheduling In A Big Environment With Two Or More Application Servers • 5 months ago

Hello guys. My first post here! We have started creating a new web application using Laravel 5.5. We are expecting to have several thousands of users so we will host this application on AWS using a Load Balancer and two application servers for the start.

To my question: I have given the following task to create a Job that runs daily at 00:00. Check if a user have birthday, if he has birthday, sent him an email. Also check for his age and depending on his new age he gets a new user role.

I realised that Laravel's build Task Scheduler should be perfect for it, but it wants me to a cronjob every one minute. So i am looking for some solution were i can build something that is really reliable to call long running tasks.

Any help is really appreciated!

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.