reimplemented management functionality

This commit is contained in:
flash 2016-12-21 21:11:03 +01:00
parent ceab147eb3
commit 2e7f22c7d6
3 changed files with 22 additions and 22 deletions

View file

@ -61,6 +61,7 @@ class HomeController extends Controller
} }
$news = DB::table('news_posts') $news = DB::table('news_posts')
->whereNull('deleted_at')
->whereIn('category_id', explode(',', config('general.homepage-news'))) ->whereIn('category_id', explode(',', config('general.homepage-news')))
->limit(3) ->limit(3)
->get(); ->get();

View file

@ -42,6 +42,7 @@ class NewsController extends Controller
->get(); ->get();
$posts = DB::table('news_posts') $posts = DB::table('news_posts')
->whereNull('news_posts.deleted_at')
->join('news_categories', function (JoinClause $join) { ->join('news_categories', function (JoinClause $join) {
$join->on('news_posts.category_id', '=', 'news_categories.category_id') $join->on('news_posts.category_id', '=', 'news_categories.category_id')
->where('news_categories.category_hidden', '=', 0); ->where('news_categories.category_hidden', '=', 0);

View file

@ -130,24 +130,24 @@ class Post
*/ */
public function save(): void public function save(): void
{ {
// // Create submission data, insert and update take the same format $data = [
// $data = [ 'category_id' => $this->category->id,
// 'news_category' => $this->category, 'user_id' => $this->user->id,
// 'user_id' => $this->user, 'post_title' => $this->title,
// 'news_timestamp' => $this->time, 'post_text' => $this->text,
// 'news_title' => $this->title, ];
// 'news_content' => $this->text,
// ];
// // Update if id isn't 0 // Update if id isn't 0
// if ($this->id) { if ($this->id) {
// DB::table('news') $data['updated_at'] = Carbon::now();
// ->where('news_id', $this->id)
// ->update($data); DB::table('news_posts')
// } else { ->where('post_id', $this->id)
// $this->id = DB::table('news') ->update($data);
// ->insertGetId($data); } else {
// } $this->id = DB::table('news_posts')
->insertGetId($data);
}
} }
/** /**
@ -155,11 +155,9 @@ class Post
*/ */
public function delete(): void public function delete(): void
{ {
// DB::table('news') DB::table('news_posts')
// ->where('news_id', $this->id) ->where('post_id', $this->id)
// ->delete(); ->update(['deleted_at' => Carbon::now()]);
// $this->id = 0;
} }
/** /**