예제 #1
0
 public function randomSeed()
 {
     // create random data
     $this->resetTables();
     $faker = Faker::create();
     factory(App\Property::class, 200)->create();
     // seed the feature tables
     foreach (PropertyFeatures::getFeatureCodes() as $feature) {
         $featureTable = $feature . 's';
         // create the features
         $data = [];
         for ($i = 1; $i <= 15; $i++) {
             $data[] = array('id' => $i, 'name' => $faker->word, 'sortPos' => $i);
         }
         DB::table($featureTable)->insert($data);
         // assign some features to each property
         $pivotTable = $feature < 'property' ? $feature . '_property' : 'property_' . $feature;
         $featureKey = $feature . '_id';
         for ($prop = 1; $prop <= App\Property::all()->count(); $prop++) {
             // pick a random number of features to add
             $n = rand(1, 15);
             // reset the faker unique setting
             $faker->unique(true)->numberBetween(1000, 2000);
             for ($j = 0; $j < $n; $j++) {
                 // pick a random architecture
                 $feature_id = $faker->unique()->numberBetween(1, 15);
                 DB::table($pivotTable)->insert([$featureKey => $feature_id, 'property_id' => $prop]);
             }
         }
     }
     //        // for all the properties created above
     //        for ($prop=1; $prop<=App\Property::all()->count(); $prop++) {
     //            // pick a random number of architectures to add
     //            $n = rand(1,10);
     //            $faker->unique(true)->numberBetween(1000, 2000);
     //            for ($j=0; $j < $n; $j++) {
     //                // pick a random architecture
     //                $arch = $faker->unique()->numberBetween(1, App\Architecture::all()->count());
     //                DB::table('architecture_property')->insert([
     //                    'architecture_id' => $arch,
     //                    'property_id' => $prop
     //                ]);
     //            }
     //            // pick a random number of exterior features to add
     //            $n = rand(1,10);
     //            $faker->unique(true)->numberBetween(1000, 2000);
     //            for ($j=0; $j < $n; $j++) {
     //                // pick a random exterior feature
     //                $ext = $faker->unique()->numberBetween(1, App\ExteriorFeature::all()->count());
     //                DB::table('exterior_feature_property')->insert([
     //                    'exterior_feature_id' => $ext,
     //                    'property_id' => $prop
     //                ]);
     //            }
     //        }
 }
예제 #2
0
Route::get('announcement/{id}', 'PropertyController@show');
Route::get('user/announcements', 'UserController@showAnnouncements');
Route::get('user', 'UserController@index');
Route::patch('user', 'UserController@update');
Route::get('guestbook', function () {
    return view('guestbook');
});
Route::get('api/messages', function () {
    return App\Message::all();
});
Route::post('api/messages', function () {
    return App\Message::create(Request::all());
});
Route::get('test', function () {
    return view('angular');
});
Route::get('test/get', function () {
    return App\Property::all();
});
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
/*  
Route::get('/', function () {
    return view('app');
});
*/