本文整理汇总了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();
}