本文整理汇总了PHP中Shop::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::create方法的具体用法?PHP Shop::create怎么用?PHP Shop::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created shop in storage.
*
* @return Response
*/
public function store()
{
$shopValidator = Validator::make($data = Input::all(), Shop::$rules);
if ($shopValidator->fails()) {
return Redirect::back()->withErrors($shopValidator)->withInput();
}
/* Shop */
if (Input::has('createShop')) {
Shop::create($data);
}
$message = "登録しました。";
if (Input::has('deleteShop')) {
$s = Shop::where('Tenpo', Input::get('Tenpo'))->first();
Shop::destroy($s->id);
$message = "削除しました。";
if (Input::has('selectedShop')) {
Input::replace(array('selectedShop', ''));
}
}
if (Input::has('updateShop')) {
$messages = array('required' => '新しい店舗名を入力してください。');
$shopValidator = Validator::make($data = Input::all(), Shop::$update_rules, $messages);
if ($shopValidator->fails()) {
return Redirect::back()->withErrors($shopValidator)->withInput();
}
$s = Shop::where('Tenpo', Input::get('Tenpo'))->first();
Shop::destroy($s->id);
$data['Tenpo'] = $data['new_shopName'];
Shop::create($data);
$message = "更新しました。";
}
return Redirect::route('employees.index')->with('message', $message);
}
示例2: Shop
if(isset($_POST['submit'])) {
$shop = new Shop();
foreach($_POST AS $key => $value) {
if(in_array($key, $allowed)) {
$$key = $value;
if(in_array($key, $required) && $value == '') {
$errors[] = "The field <strong>{$key}</strong> is required.";
}
}
}
if(count($errors) < 1) {
if($shop->create($world, $name, $owner, $managers, $creator, $position1, $position2, $money, $stock)) {
$success = "Created shop {$name}, <a href='editor.php?edit={$name}'>edit</a> or <a href='add-item.php?name={$name}'>add items</a>?";
} else {
$errors[] = "Could not create shop {$name}!";
}
}
}
if(count($errors) > 0):
echo '<p><strong>There was an error processing the form.</strong></p>';
echo '<ul>';
foreach($errors as $error):
echo "<li>$error</li>";
endforeach;
示例3: new_shop
public function new_shop()
{
$rules = array('shop_name' => 'required');
$validator = Validator::make(Input::all(), $rules);
if (!$validator->fails()) {
$user = Shop::create(Input::only('shop_name'));
$user->save();
return Redirect::to('admin/shops')->with('success', 'Shop created successfully!');
} else {
return Redirect::back()->withErrors($validator);
}
}