Commit 434a610b by Aan Choesni Herlingga

bug fix store if content is blank

parent b7188745
......@@ -19,10 +19,11 @@ class CategoryController extends Controller
public function __construct(
CategoryRepository $repo,
EnCategoryRepository $repoEn
){
) {
$this->repo = $repo;
$this->repoEn = $repoEn;
}
/**
* Display a listing of the resource.
*
......@@ -32,6 +33,7 @@ class CategoryController extends Controller
{
if ($request->ajax()) {
$data = $this->repo->get(['rEn']);
return $this->repo->datatable($data);
}
......@@ -51,7 +53,8 @@ class CategoryController extends Controller
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
......@@ -81,18 +84,19 @@ class CategoryController extends Controller
/**
* Display the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($id)
......@@ -109,8 +113,9 @@ class CategoryController extends Controller
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
......@@ -138,7 +143,8 @@ class CategoryController extends Controller
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
......
......@@ -20,10 +20,11 @@ class InformationController extends Controller
public function __construct(
InformationRepository $repo,
EnInformationRepository $repoEn
){
) {
$this->repo = $repo;
$this->repoEn = $repoEn;
}
/**
* Display a listing of the resource.
*
......@@ -33,6 +34,7 @@ class InformationController extends Controller
{
if ($request->ajax()) {
$data = $this->repo->get(['rEn']);
return $this->repo->datatable($data);
}
......@@ -58,7 +60,8 @@ class InformationController extends Controller
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
......@@ -82,6 +85,11 @@ class InformationController extends Controller
{
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']);
if (strip_tags($data['content']) == null) {
$data['content'] = 'kosong';
}
$content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content']));
$dataEn['information_id'] = $information->id;
......@@ -94,25 +102,26 @@ class InformationController extends Controller
/**
* Display the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$data = $this->repo->findId($id);
$categories = Categories::pluck('name', 'id');
$data = [
'data' => $data,
'categories' => $categories,
......@@ -124,8 +133,9 @@ class InformationController extends Controller
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
......@@ -155,7 +165,8 @@ class InformationController extends Controller
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
......
......@@ -20,10 +20,11 @@ class PageController extends Controller
public function __construct(
PagesRepository $repo,
EnPagesRepository $repoEn
){
) {
$this->repo = $repo;
$this->repoEn = $repoEn;
}
/**
* Display a listing of the resource.
*
......@@ -33,6 +34,7 @@ class PageController extends Controller
{
if ($request->ajax()) {
$data = $this->repo->get(['rEn']);
return $this->repo->datatable($data);
}
......@@ -58,7 +60,8 @@ class PageController extends Controller
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
......@@ -80,6 +83,11 @@ class PageController extends Controller
{
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']);
if (strip_tags($data['content']) == null) {
$data['content'] = 'kosong';
}
$content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content']));
$dataEn['page_id'] = $page->id;
......@@ -92,25 +100,26 @@ class PageController extends Controller
/**
* Display the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$data = $this->repo->findId($id);
$categories = Categories::pluck('name', 'id');
$data = [
'data' => $data,
'categories' => $categories,
......@@ -122,8 +131,9 @@ class PageController extends Controller
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
......@@ -150,7 +160,8 @@ class PageController extends Controller
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
......
......@@ -8,7 +8,6 @@ use App\Models\Webprofile\Categories;
use App\Repositories\Webprofile\En\PostRepository as EnPostRepository;
use App\Repositories\Webprofile\PostRepository;
use Statickidz\GoogleTranslate;
use Illuminate\Support\Str;
class PostController extends Controller
{
......@@ -21,10 +20,11 @@ class PostController extends Controller
public function __construct(
PostRepository $repo,
EnPostRepository $repoEn
){
) {
$this->repo = $repo;
$this->repoEn = $repoEn;
}
/**
* Display a listing of the resource.
*
......@@ -34,6 +34,7 @@ class PostController extends Controller
{
if ($request->ajax()) {
$data = $this->repo->get(['rEn']);
return $this->repo->datatable($data);
}
......@@ -59,7 +60,8 @@ class PostController extends Controller
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
......@@ -74,7 +76,7 @@ class PostController extends Controller
$tipe = 'thumbnail';
if ($request->hasFile($tipe)) {
$img[$tipe] = $save->id . '.' . $request->file($tipe)->guessClientExtension();
$img[$tipe] = $save->id.'.'.$request->file($tipe)->guessClientExtension();
$this->repo->upload($img[$tipe], $request, $tipe);
$this->repo->update($img, $save);
......@@ -92,6 +94,11 @@ class PostController extends Controller
{
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']);
if (strip_tags($data['content']) == null) {
$data['content'] = 'kosong';
}
$content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content']));
$dataEn['post_id'] = $post->id;
......@@ -104,18 +111,19 @@ class PostController extends Controller
/**
* Display the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($id)
......@@ -123,7 +131,7 @@ class PostController extends Controller
$setting = webprofilesetting();
$data = $this->repo->findId($id, ['rEn']);
$categories = Categories::pluck('name', 'id');
$data = [
'data' => $data,
'categories' => $categories,
......@@ -136,8 +144,9 @@ class PostController extends Controller
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
......@@ -154,7 +163,7 @@ class PostController extends Controller
$tipe = 'thumbnail';
if ($request->hasFile($tipe)) {
$img[$tipe] = $post->id . '.' . $request->file($tipe)->guessClientExtension();
$img[$tipe] = $post->id.'.'.$request->file($tipe)->guessClientExtension();
$this->repo->upload($img[$tipe], $request, $tipe);
$this->repo->update($img, $post);
......@@ -176,7 +185,8 @@ class PostController extends Controller
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
......
......@@ -15,6 +15,7 @@ class PostRepository extends Repository
public function get()
{
}
public function paginate()
{
}
......
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