本文整理汇总了PHP中Banner::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Banner::create方法的具体用法?PHP Banner::create怎么用?PHP Banner::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Banner
的用法示例。
在下文中一共展示了Banner::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
* POST /banners
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Banner::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
if (isset($data['banner_name'])) {
$data = $this->uploadFile($data, 'banner_name');
}
Banner::create($data);
return Redirect::to('/banners')->withMessage("Created Banner");
}
示例2: create
public function create()
{
if (!$this->has_post()) {
return redirect_message(array('admin', $this->get_class(), 'add'), array('_flash_message' => '非 POST 方法,錯誤的頁面請求。'));
}
$posts = OAInput::post();
$cover = OAInput::file('cover');
if (!$cover) {
return redirect_message(array('admin', $this->get_class(), 'add'), array('_flash_message' => '請選擇照片(gif、jpg、png)檔案,或提供照片網址!', 'posts' => $posts));
}
if ($msg = $this->_validation_posts($posts)) {
return redirect_message(array('admin', $this->get_class(), 'add'), array('_flash_message' => $msg, 'posts' => $posts));
}
$posts['sort'] = Banner::count();
$create = Banner::transaction(function () use($posts, $cover) {
return verifyCreateOrm($banner = Banner::create(array_intersect_key($posts, Banner::table()->columns))) && $banner->cover->put($cover);
});
if (!$create) {
return redirect_message(array('admin', $this->get_class(), 'add'), array('_flash_message' => '新增失敗!', 'posts' => $posts));
}
return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '新增成功!'));
}