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