Пример #1
0
 public static function getAll($rental_id = null, $requester_user_id = null, $property_id = null)
 {
     $query = self::orderBy(array_keys(self::$orderBy)[0], array_values(self::$orderBy)[0]);
     if ($rental_id) {
         $query->where('rental_id', intval($rental_id));
     } elseif ($property_id and ($property = Property::find($property_id)) instanceof Property) {
         $query->whereIn('rental_id', array_map(create_function('$a', 'return $a->id;'), $property->rentals->all()));
     }
     if ($requester_user_id) {
         $query->where('requester_user_id', intval($requester_user_id));
     }
     return $query->paginate(self::$pageSize);
 }
Пример #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(Rental::class, Property::all()->count() * RENTAL_SEED_MULTI)->create();
 }
Пример #3
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id = null)
 {
     return view('rental::rental.detail', ['rental' => Rental::find($id), 'properties' => Property::getAll(null, PHP_INT_MAX)]);
 }
Пример #4
0
    for ($i = 0; $i < random_int(0, 5); $i++) {
        $array['options'][] = [$faker->word => $faker->randomNumber()];
    }
    $array['options'] = json_encode($array['options']);
    return $array;
});
$factory->define(PropertyLog::class, function (Faker\Generator $faker) {
    $array = ['property_id' => $faker->randomElement(Property::all()->all())->id, 'type' => $faker->word, 'content' => $faker->sentences(random_int(1, 20), true), 'comments' => []];
    for ($i = 0; $i < random_int(0, 5); $i++) {
        $array['comments'][] = $faker->sentences(random_int(1, 3), true);
    }
    $array['comments'] = json_encode($array['comments']);
    return $array;
});
$factory->define(Rental::class, function (Faker\Generator $faker) {
    $array = ['property_id' => $faker->randomElement(Property::all()->all())->id, 'dailyAmount' => $faker->randomFloat(4, 500 / 30, 2000 / 30), 'from' => random_int(0, 1) === 0 ? null : $faker->dateTimeBetween('-10 years'), 'to' => random_int(0, 1) === 0 ? null : $faker->dateTimeBetween('now', '+10 years'), 'media_ids' => []];
    for ($i = 0; $i < random_int(1, 10); $i++) {
        $array['media_ids'][] = $faker->randomElement(Media::all()->all())->id;
    }
    $array['media_ids'] = json_encode($array['media_ids']);
    return $array;
});
$factory->define(AdminAccess::class, function (Faker\Generator $faker) {
    do {
        $array = ['rental_id' => $faker->randomElement(Rental::all()->all())->id, 'role_id' => $faker->randomElement(Role::all()->all())->id, 'canManage' => $faker->boolean(), 'canManage' => $faker->boolean(), 'canIssue' => $faker->boolean(), 'canDocument' => $faker->boolean(), 'canStatement' => $faker->boolean(), 'canMessage' => $faker->boolean()];
    } while (AdminAccess::where(['rental_id' => $array['rental_id'], 'role_id' => $array['role_id']])->get()->count() > 0);
    return $array;
});
$factory->define(Issue::class, function (Faker\Generator $faker) {
    return ['requester_user_id' => $faker->randomElement(User::all()->all())->id, 'rental_id' => $faker->randomElement(Rental::all()->all())->id, 'status' => $faker->words(random_int(1, 2), true)];
});
Пример #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Property::destroy($id);
     return Redirect::to('property');
 }