本文整理匯總了PHP中app\models\News::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP News::update方法的具體用法?PHP News::update怎麽用?PHP News::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\News
的用法示例。
在下文中一共展示了News::update方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionUpdate
public function actionUpdate()
{
if (!isset($_GET['id'])) {
header("HTTP/1.0 404 Not Found");
throw new E404Exception('Requested param cannot be null');
}
if (!isset($_POST['NewsHeader']) || !isset($_POST['NewsPreview']) || !isset($_POST['NewsText']) || !isset($_POST['NewsTags'])) {
header("HTTP/1.0 404 Not Found");
throw new E404Exception('Required params can not be null');
}
$NewsRecord = new News();
$NewsRecord->NewsHeader = $_POST['NewsHeader'];
$NewsRecord->NewsPreview = $_POST['NewsPreview'];
$NewsRecord->NewsText = $_POST['NewsText'];
$NewsRecord->NewsTags = $_POST['NewsTags'];
$NewsId = (int) $_GET['id'];
$NewsRecord->WHERE = [':NewsId' => $NewsId];
$NewsRecord->update();
header('Location: ./index.php');
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param News $news
* @return \Illuminate\Http\Response
* @internal param int $id
*/
public function update(Request $request, News $news)
{
$news->fill($request->all());
$news->update();
return redirect()->route('admin.news.index');
}