本文整理匯總了PHP中app\Post::whereDelete_status方法的典型用法代碼示例。如果您正苦於以下問題:PHP Post::whereDelete_status方法的具體用法?PHP Post::whereDelete_status怎麽用?PHP Post::whereDelete_status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Post
的用法示例。
在下文中一共展示了Post::whereDelete_status方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postEdit
public function postEdit($id = null)
{
$check_post_active = Post::whereDelete_status(0)->whereId($id)->first();
if ($check_post_active) {
$data = Input::all();
$validator = Post::validate($data);
if ($validator->fails()) {
return Redirect::to('admin/post/edit/' . $id)->withInput()->withErrors($validator);
} else {
$check_post_active->title = $data['title'];
$check_post_active->content = $data['content'];
$check_post_active->category_id = $data['category'];
$destination_path = './public/images/post/';
// upload path
if (isset($data['remove_image'])) {
if ($check_post_active->image) {
if (File::exists($destination_path . $check_post_active->image)) {
File::delete($destination_path . $check_post_active->image);
}
}
$check_post_active->image = "";
} else {
if (Input::file('image')) {
$extension = Input::file('image')->getClientOriginalExtension();
// getting image extension
$file_name = str_random(8) . '.' . $extension;
// renameing image
if (Input::file('image')->move($destination_path, $file_name)) {
if ($check_post_active->image != "" && File::exists($destination_path . $check_post_active->image)) {
File::delete($destination_path . $check_post_active->image);
}
$check_post_active->image = $file_name;
}
}
}
$check_post_active->save();
Session::flash('edit_status', ['status' => 'success', 'message' => 'Edit post is success!']);
return redirect()->back();
}
} else {
return redirect('post/edit');
}
}
示例2: getPosts
/**
* Function manager posts
* @author Tran Van Moi
* @since 2015/06/01
* @return response
*/
public function getPosts()
{
$data['posts'] = Post::whereDelete_status(0)->join('categories', 'posts.category_id', '=', 'categories.id')->select('posts.id', 'posts.title', 'posts.content', 'posts.image', 'posts.created_at', 'posts.updated_at', 'categories.name as category_name')->orderBy('posts.created_at', 'desc')->orderBy('posts.updated_at', 'desc')->get();
return view('admin/post', $data);
}