Commit f8a698ff by Aan Choesni Herlingga

jika kategori dihapus pada post index

parent 1fb09616
...@@ -35,11 +35,11 @@ class PostRepository extends Repository ...@@ -35,11 +35,11 @@ class PostRepository extends Repository
return DataTables::of($data) return DataTables::of($data)
->addIndexColumn() ->addIndexColumn()
->addColumn('action', function ($row) { ->addColumn('action', function ($row) {
$btn = '<a href="' . url('/webprofile/posts/' . $row->id . '/edit') . '" data-toggle="tooltip" data-id="' . $row->id . '" data-original-title="' . trans('label.edit') . '" class="edit btn btn-warning btn-round btn-sm edit">' . trans('label.edit') . '</a>'; $btn = '<a href="'.url('/webprofile/posts/'.$row->id.'/edit').'" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="'.trans('label.edit').'" class="edit btn btn-warning btn-round btn-sm edit">'.trans('label.edit').'</a>';
$btn = $btn . ' <a href="javascript:void(0)" data-toggle="tooltip" data-id="' . $row->id . '" data-original-title="' . trans('label.delete') . '" class="btn btn-danger btn-round btn-sm delete">' . trans('label.delete') . '</a>'; $btn = $btn.' <a href="javascript:void(0)" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="'.trans('label.delete').'" class="btn btn-danger btn-round btn-sm delete">'.trans('label.delete').'</a>';
$btn = $btn . '<br>'; $btn = $btn.'<br>';
return $btn; return $btn;
}) })
...@@ -49,38 +49,42 @@ class PostRepository extends Repository ...@@ -49,38 +49,42 @@ class PostRepository extends Repository
} else { } else {
$str = '<div style="color: red;"><i class="fa fa-times"></i></div>'; $str = '<div style="color: red;"><i class="fa fa-times"></i></div>';
} }
return $str; return $str;
}) })
->addColumn('category', function ($row) { ->addColumn('category', function ($row) {
$str = $row->rCategory->name; $str = '';
if ($row->rCategory) {
$str = $row->rCategory->name;
}
return $str; return $str;
}) })
->addColumn('post_date', function ($row) { ->addColumn('post_date', function ($row) {
$str = ''; $str = '';
if($row->post_status == 1) { if ($row->post_status == 1) {
$str .= '<div style="color: green;">' . trans('label.publish') . '</div>'; $str .= '<div style="color: green;">'.trans('label.publish').'</div>';
} }
if($row->post_status == 0) { if ($row->post_status == 0) {
$str .= '<div style="color: red;">' . trans('label.draft') . '</div>'; $str .= '<div style="color: red;">'.trans('label.draft').'</div>';
} }
$str .= Date('d-m-Y', strtotime($row->post_date)); $str .= date('d-m-Y', strtotime($row->post_date));
return $str; return $str;
}) })
->addColumn('sum', function ($row) { ->addColumn('sum', function ($row) {
$str = trans('label.viewer') . ' : ' . $row->viewer . '<br>'; $str = trans('label.viewer').' : '.$row->viewer.'<br>';
$str .= trans('label.command') . ' : ' . $row->comment_count; $str .= trans('label.command').' : '.$row->comment_count;
return $str; return $str;
}) })
->addColumn('title', function ($row) { ->addColumn('title', function ($row) {
$str = $row->title . '<br>'; $str = $row->title.'<br>';
if ($row->rEn) { if ($row->rEn) {
$str .= '<i style="color: blue;">' . $row->rEn['title'] . '</i>'; $str .= '<i style="color: blue;">'.$row->rEn['title'].'</i>';
} }
return $str; return $str;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment