本文整理匯總了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' => '新增成功!'));
}