Commit 434a610b by Aan Choesni Herlingga

bug fix store if content is blank

parent b7188745
...@@ -19,10 +19,11 @@ class CategoryController extends Controller ...@@ -19,10 +19,11 @@ class CategoryController extends Controller
public function __construct( public function __construct(
CategoryRepository $repo, CategoryRepository $repo,
EnCategoryRepository $repoEn EnCategoryRepository $repoEn
){ ) {
$this->repo = $repo; $this->repo = $repo;
$this->repoEn = $repoEn; $this->repoEn = $repoEn;
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
...@@ -32,6 +33,7 @@ class CategoryController extends Controller ...@@ -32,6 +33,7 @@ class CategoryController extends Controller
{ {
if ($request->ajax()) { if ($request->ajax()) {
$data = $this->repo->get(['rEn']); $data = $this->repo->get(['rEn']);
return $this->repo->datatable($data); return $this->repo->datatable($data);
} }
...@@ -52,6 +54,7 @@ class CategoryController extends Controller ...@@ -52,6 +54,7 @@ class CategoryController extends Controller
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request)
...@@ -82,17 +85,18 @@ class CategoryController extends Controller ...@@ -82,17 +85,18 @@ class CategoryController extends Controller
* Display the specified resource. * Display the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id)
{ {
//
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function edit($id) public function edit($id)
...@@ -111,6 +115,7 @@ class CategoryController extends Controller ...@@ -111,6 +115,7 @@ class CategoryController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
...@@ -139,6 +144,7 @@ class CategoryController extends Controller ...@@ -139,6 +144,7 @@ class CategoryController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id)
......
...@@ -20,10 +20,11 @@ class InformationController extends Controller ...@@ -20,10 +20,11 @@ class InformationController extends Controller
public function __construct( public function __construct(
InformationRepository $repo, InformationRepository $repo,
EnInformationRepository $repoEn EnInformationRepository $repoEn
){ ) {
$this->repo = $repo; $this->repo = $repo;
$this->repoEn = $repoEn; $this->repoEn = $repoEn;
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
...@@ -33,6 +34,7 @@ class InformationController extends Controller ...@@ -33,6 +34,7 @@ class InformationController extends Controller
{ {
if ($request->ajax()) { if ($request->ajax()) {
$data = $this->repo->get(['rEn']); $data = $this->repo->get(['rEn']);
return $this->repo->datatable($data); return $this->repo->datatable($data);
} }
...@@ -59,6 +61,7 @@ class InformationController extends Controller ...@@ -59,6 +61,7 @@ class InformationController extends Controller
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request)
...@@ -82,6 +85,11 @@ class InformationController extends Controller ...@@ -82,6 +85,11 @@ class InformationController extends Controller
{ {
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']); $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'])); $content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content']));
$dataEn['information_id'] = $information->id; $dataEn['information_id'] = $information->id;
...@@ -95,17 +103,18 @@ class InformationController extends Controller ...@@ -95,17 +103,18 @@ class InformationController extends Controller
* Display the specified resource. * Display the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id)
{ {
//
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function edit($id) public function edit($id)
...@@ -126,6 +135,7 @@ class InformationController extends Controller ...@@ -126,6 +135,7 @@ class InformationController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
...@@ -156,6 +166,7 @@ class InformationController extends Controller ...@@ -156,6 +166,7 @@ class InformationController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id)
......
...@@ -20,10 +20,11 @@ class PageController extends Controller ...@@ -20,10 +20,11 @@ class PageController extends Controller
public function __construct( public function __construct(
PagesRepository $repo, PagesRepository $repo,
EnPagesRepository $repoEn EnPagesRepository $repoEn
){ ) {
$this->repo = $repo; $this->repo = $repo;
$this->repoEn = $repoEn; $this->repoEn = $repoEn;
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
...@@ -33,6 +34,7 @@ class PageController extends Controller ...@@ -33,6 +34,7 @@ class PageController extends Controller
{ {
if ($request->ajax()) { if ($request->ajax()) {
$data = $this->repo->get(['rEn']); $data = $this->repo->get(['rEn']);
return $this->repo->datatable($data); return $this->repo->datatable($data);
} }
...@@ -59,6 +61,7 @@ class PageController extends Controller ...@@ -59,6 +61,7 @@ class PageController extends Controller
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request)
...@@ -80,6 +83,11 @@ class PageController extends Controller ...@@ -80,6 +83,11 @@ class PageController extends Controller
{ {
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']); $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'])); $content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content']));
$dataEn['page_id'] = $page->id; $dataEn['page_id'] = $page->id;
...@@ -93,17 +101,18 @@ class PageController extends Controller ...@@ -93,17 +101,18 @@ class PageController extends Controller
* Display the specified resource. * Display the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id)
{ {
//
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function edit($id) public function edit($id)
...@@ -124,6 +133,7 @@ class PageController extends Controller ...@@ -124,6 +133,7 @@ class PageController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
...@@ -151,6 +161,7 @@ class PageController extends Controller ...@@ -151,6 +161,7 @@ class PageController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id)
......
...@@ -8,7 +8,6 @@ use App\Models\Webprofile\Categories; ...@@ -8,7 +8,6 @@ use App\Models\Webprofile\Categories;
use App\Repositories\Webprofile\En\PostRepository as EnPostRepository; use App\Repositories\Webprofile\En\PostRepository as EnPostRepository;
use App\Repositories\Webprofile\PostRepository; use App\Repositories\Webprofile\PostRepository;
use Statickidz\GoogleTranslate; use Statickidz\GoogleTranslate;
use Illuminate\Support\Str;
class PostController extends Controller class PostController extends Controller
{ {
...@@ -21,10 +20,11 @@ class PostController extends Controller ...@@ -21,10 +20,11 @@ class PostController extends Controller
public function __construct( public function __construct(
PostRepository $repo, PostRepository $repo,
EnPostRepository $repoEn EnPostRepository $repoEn
){ ) {
$this->repo = $repo; $this->repo = $repo;
$this->repoEn = $repoEn; $this->repoEn = $repoEn;
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
...@@ -34,6 +34,7 @@ class PostController extends Controller ...@@ -34,6 +34,7 @@ class PostController extends Controller
{ {
if ($request->ajax()) { if ($request->ajax()) {
$data = $this->repo->get(['rEn']); $data = $this->repo->get(['rEn']);
return $this->repo->datatable($data); return $this->repo->datatable($data);
} }
...@@ -60,6 +61,7 @@ class PostController extends Controller ...@@ -60,6 +61,7 @@ class PostController extends Controller
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request)
...@@ -74,7 +76,7 @@ class PostController extends Controller ...@@ -74,7 +76,7 @@ class PostController extends Controller
$tipe = 'thumbnail'; $tipe = 'thumbnail';
if ($request->hasFile($tipe)) { 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->upload($img[$tipe], $request, $tipe);
$this->repo->update($img, $save); $this->repo->update($img, $save);
...@@ -92,6 +94,11 @@ class PostController extends Controller ...@@ -92,6 +94,11 @@ class PostController extends Controller
{ {
$trans = new GoogleTranslate(); $trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']); $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'])); $content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content']));
$dataEn['post_id'] = $post->id; $dataEn['post_id'] = $post->id;
...@@ -105,17 +112,18 @@ class PostController extends Controller ...@@ -105,17 +112,18 @@ class PostController extends Controller
* Display the specified resource. * Display the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id)
{ {
//
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function edit($id) public function edit($id)
...@@ -138,6 +146,7 @@ class PostController extends Controller ...@@ -138,6 +146,7 @@ class PostController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
...@@ -154,7 +163,7 @@ class PostController extends Controller ...@@ -154,7 +163,7 @@ class PostController extends Controller
$tipe = 'thumbnail'; $tipe = 'thumbnail';
if ($request->hasFile($tipe)) { 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->upload($img[$tipe], $request, $tipe);
$this->repo->update($img, $post); $this->repo->update($img, $post);
...@@ -177,6 +186,7 @@ class PostController extends Controller ...@@ -177,6 +186,7 @@ class PostController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id)
......
...@@ -15,6 +15,7 @@ class PostRepository extends Repository ...@@ -15,6 +15,7 @@ class PostRepository extends Repository
public function get() public function get()
{ {
} }
public function paginate() 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