Пример #1
0
 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();
 }
Пример #2
0
 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();
     }
 }
Пример #3
0
 public function load($id)
 {
     $this->model = User::find($id);
     return !empty($this->model);
 }