public function accept() { $this->follower = User::find($this->relation->getStartNode()->getId()); $this->follow = User::find($this->relation->getEndNode()->getId()); $this->follow->friends()->attach($this->follower); $this->relation->delete(); }
public function run() { $faker = \Faker\Factory::create(); $ids = []; for ($i = 0; $i < $this->nodes_count; $i++) { $user = User::create(['name' => $faker->name]); $range = array_slice($ids, max(0, $i - 10)); shuffle($range); $user->friends()->attach(array_slice($range, 0, rand(0, 5))); $ids[] = $user->getKey(); } }
public function load($id) { $this->model = User::find($id); return !empty($this->model); }