Exemplo n.º 1
0
function load_streets()
{
    if (!DB::schema('mock-data')->hasTable('streets')) {
        DB::schema('mock-data')->create('streets', function ($table) {
            # Define some fields.
            $table->increments('id');
            $table->string('name', 50);
        });
    } else {
        Street::truncate();
    }
    $fp = fopen(get_filename('streets.txt'), 'r');
    $count = 0;
    while (!feof($fp)) {
        $name = trim(fgets($fp));
        if (strlen($name) > 0) {
            $street = new Street();
            $street->name = $name;
            $street->save();
            $count++;
        } else {
            continue;
        }
    }
    fclose($fp);
    return $count;
}
Exemplo n.º 2
0
 /**
  * Return a street name
  *
  * @return string
  */
 public function getStreet()
 {
     $number = rand(100, 9999);
     $street_name = Street::orderByRaw(Database::random())->first()->name;
     return $number . ' ' . $street_name;
 }