diff --git a/app/Console/Commands/UserChangeInformation.php b/app/Console/Commands/UserChangeInformation.php new file mode 100644 index 0000000..62e3a68 --- /dev/null +++ b/app/Console/Commands/UserChangeInformation.php @@ -0,0 +1,85 @@ +first_name; + + $fistNameLength = strlen(utf8_decode($fistName)); + + $user->update([ + 'first_name_length' => $fistNameLength + ]); + } + + /** + * Execute the console command. + * + * @return int + */ + public function handle() + { + + $users = User::all(); + + foreach ($users as $user) { + + $business = Business::find($user->business_id); + + if (!is_null($business)) { + + if ($business->user_id == $user->id) { + + $this->firstNameLengthUpdate($user); + $business->user()->attach($user->id, [ + 'responsibility' => $user->responsibility, + 'is_owner' => 1 + ]); + $this->info("add and update user : $user->id"); + + } else { + + $this->firstNameLengthUpdate($user); + $business->user()->attach($user->id, [ + 'responsibility' => $user->responsibility + ]); + $this->info("add and update user : $user->id"); + } + } + + } + + + } +}