Пример #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $property = ['id' => $request->all()['property_id'], 'description' => $request->all()['property_description']];
     $property_details = ['id' => $request->all()['property_detail_id'], 'type' => $request->all()['property_details_type'], 'carParks' => ($tmp = trim($request->all()['property_details_carParks'])) === '' ? null : intval($tmp), 'bedrooms' => ($tmp = trim($request->all()['property_details_bedrooms'])) === '' ? null : intval($tmp), 'bathrooms' => ($tmp = trim($request->all()['property_details_bathrooms'])) === '' ? null : intval($tmp), 'options' => self::stripPropertyDetailOptions($request)];
     $address = ['id' => $request->all()['address_id'], 'street' => $request->all()['address_street'], 'suburb' => $request->all()['address_suburb'], 'state' => $request->all()['address_state'], 'country' => $request->all()['address_country'], 'postcode' => $request->all()['address_postcode']];
     $address = Address::store($address['street'], $address['suburb'], $address['state'], $address['country'], $address['postcode'], $address['id']);
     $property = Property::store($property['description'], $address, $property['id']);
     PropertyDetail::store($property, $property_details['type'], $property_details['carParks'], $property_details['bedrooms'], $property_details['bathrooms'], $property_details['options'], $property_details['id']);
     return Redirect::route('property.index');
 }
Пример #2
0
    return ['mimeType' => $mimeType, 'name' => $name, 'path' => '/media/' . basename($newPath)];
});
$factory->define(Role::class, function (Faker\Generator $faker) {
    return ['name' => $faker->words(random_int(1, 3), true), 'description' => $faker->sentences(random_int(1, 5), true)];
});
$factory->define(Action::class, function (Faker\Generator $faker) {
    return ['name' => $faker->words(random_int(1, 3), true), 'description' => $faker->sentences(random_int(1, 5), true)];
});
$factory->define(Permission::class, function (Faker\Generator $faker) {
    do {
        $array = ['action_id' => $faker->randomElement(Action::all()->all())->id, 'role_id' => $faker->randomElement(Role::all()->all())->id, 'permitted' => $faker->boolean(80)];
    } while (Permission::where(['action_id' => $array['action_id'], 'role_id' => $array['role_id']])->get()->count() > 0);
    return $array;
});
$factory->define(Property::class, function (Faker\Generator $faker) {
    return ['address_id' => $faker->randomElement(Address::all()->all())->id, 'description' => $faker->sentences(random_int(1, 20), true)];
});
$factory->define(PropertyDetail::class, function (Faker\Generator $faker) {
    $array = ['property_id' => $faker->randomElement(Property::all()->all())->id, 'type' => $faker->word, 'carParks' => random_int(0, 5) === 0 ? null : random_int(0, 3), 'carParks' => random_int(0, 5) === 0 ? null : random_int(0, 3), 'bedrooms' => random_int(0, 10) === 0 ? null : random_int(1, 5), 'bathrooms' => random_int(0, 10) === 0 ? null : random_int(1, 3), 'options' => []];
    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']);