本文整理匯總了PHP中app\models\News::GetSingleNews方法的典型用法代碼示例。如果您正苦於以下問題:PHP News::GetSingleNews方法的具體用法?PHP News::GetSingleNews怎麽用?PHP News::GetSingleNews使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\News
的用法示例。
在下文中一共展示了News::GetSingleNews方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: GetSingleNews
public function GetSingleNews($id)
{
$n = News::GetSingleNews($id);
$news = $n[0];
$data["news"] = $news;
$latestNews = News::GetLatestNews(3);
$data["latestNews"] = $latestNews;
return view("single_news", ["data" => $data]);
}
示例2: EditSelectedNews
public function EditSelectedNews($id)
{
$title = $_POST["newsTitle"];
$text = $_POST["newsText"];
$author = $_POST["newsAuthor"];
if (Input::hasFile("news_picture")) {
$file = Input::file("news_picture");
$folder = '/images/';
$destinationPath = public_path() . $folder;
$filename = str_random(6) . '_' . $file->getClientOriginalName();
$img_path = $folder . $filename;
$uploadSuccess = $file->move($destinationPath, $filename);
$pd = News::GetSingleNews($id);
$img = $pd[0]->news_image;
if (File::exists(public_path() . $img)) {
File::delete(public_path() . $img);
}
} else {
$n = News::GetSingleNews($id);
$img_path = $n[0]->news_image;
}
News::UpdateNews($title, $text, $img_path, $author, $id);
return Redirect::back();
}