本文整理汇总了PHP中Place::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Place::create方法的具体用法?PHP Place::create怎么用?PHP Place::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Place
的用法示例。
在下文中一共展示了Place::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created place in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Place::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
Place::create($data);
return Redirect::route('places.index');
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
for ($i = 0; $i < 100; $i++) {
$place = Place::create(['name' => $faker->name, 'lat' => $faker->latitude, 'lon' => $faker->longitude, 'address1' => $faker->streetAddress, 'city' => $faker->city, 'state' => $faker->stateAbbr, 'zip' => rand(10000, 30000), 'website' => $faker->url, 'phone' => $faker->phoneNumber]);
foreach (User::all() as $user) {
if (rand(0, 2) == 1) {
$place->checkins()->create(['user_id' => $user->id]);
}
}
}
}
示例3: run
public function run()
{
Eloquent::unguard();
/**
* Clearing table
*/
DB::table('places')->delete();
/**
* Creating places
*/
Place::create(array('plc_title' => '-'));
// default - do not delete!
/**
* Reporting result to console
*/
$this->command->info('Default location created.');
}