Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers\Contents;
- use App\Http\Controllers\Controller;
- use App\Models\Corporate;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Redirect;
- class AboutsController extends Controller
- {
- /**
- * Constructor
- *
- * @return void
- */
- public function __construct() {
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function index()
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- return view('dashboard.contents.abouts.index');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function csrIndex()
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $csr = json_decode(Corporate::all('csr')[0]->csr);
- return view('dashboard.contents.abouts.csr.index', ['csr' => $csr]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function csrCreate()
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- return view('dashboard.contents.abouts.csr.create');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function csrEdit($id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $csr = json_decode(Corporate::all('csr')[0]->csr)[$id];
- return view('dashboard.contents.abouts.csr.update', ['csr' => $csr, 'id' => $id]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function csrStore(Request $request)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $csr = Corporate::find(1);
- $existingdata = json_decode(Corporate::all('csr')[0]->csr);
- $newdata = json_decode('{ "title_en": "'.$request->title_en.'", "title_id": "'.$request->title_id.'", "content_en": "'.$request->content_en.', "content_id": "'.$request->content_id.', "datetime": "'.date('Y-m-d H:i:s').'" }');
- $result = array_push($existingdata, $newdata);
- $csr->update([
- 'csr' => json_encode($existingdata)
- ]);
- return redirect()->route('abouts.csrIndex')->with('alert-success', 'Data berhasil ditambah!');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function csrUpdate(Request $request, $id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $csr = Corporate::find(1);
- $existingdata = json_decode(Corporate::all('csr')[0]->csr);
- $existingdata[$id] = json_decode('{ "title_en": "'.$request->title_en.'", "title_id": "'.$request->title_id.'", "content_en": "'.$request->content_en.', "content_id": "'.$request->content_id.', "datetime": "'.date('Y-m-d H:i:s').'" }');
- $csr->update([
- 'csr' => json_encode($existingdata)
- ]);
- return redirect()->route('abouts.csrIndex')->with('alert-success', 'Data berhasil diubah!');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function csrDestroy($id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $social = Corporate::find(1);
- $existingdata = json_decode(Corporate::all('csr')[0]->csr);
- unset($existingdata[$id]);
- $csr->update([
- 'csr' => json_encode($existingdata)
- ]);
- return redirect()->route('abouts.csrIndex')->with('alert-success', 'Data berhasil dihapus!');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function socialIndex()
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $social = json_decode(Corporate::all('social_media')[0]->social_media);
- return view('dashboard.contents.abouts.social.index', ['social' => $social]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function socialCreate()
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- return view('dashboard.contents.abouts.social.create');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function socialEdit($id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $social = json_decode(Corporate::all('social_media')[0]->social_media)[$id];
- return view('dashboard.contents.abouts.social.update', ['social' => $social, 'id' => $id]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function socialStore(Request $request)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $social = Corporate::find(1);
- $existingdata = json_decode(Corporate::all('social_media')[0]->social_media);
- $newdata = json_decode('{ "media": "'.$request->media.'", "link": "'.$request->link.'" }');
- $result = array_push($existingdata, $newdata);
- $social->update([
- 'social_media' => json_encode($existingdata)
- ]);
- return redirect()->route('abouts.socialIndex')->with('alert-success', 'Data berhasil ditambah!');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function socialUpdate(Request $request, $id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $social = Corporate::find(1);
- $existingdata = json_decode(Corporate::all('social_media')[0]->social_media);
- $existingdata[$id] = json_decode('{ "media": "'.$request->media.'", "link": "'.$request->link.'" }');
- $social->update([
- 'social_media' => json_encode($existingdata)
- ]);
- return redirect()->route('abouts.socialIndex')->with('alert-success', 'Data berhasil diubah!');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function socialDestroy($id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $social = Corporate::find(1);
- $existingdata = json_decode(Corporate::all('social_media')[0]->social_media);
- unset($existingdata[$id]);
- $social->update([
- 'social_media' => json_encode($existingdata)
- ]);
- return redirect()->route('abouts.socialIndex')->with('alert-success', 'Data berhasil dihapus!');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function timelineIndex()
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $timeline = json_decode(Corporate::all('timelines')[0]->timelines);
- return view('dashboard.contents.abouts.timeline.index', ['timeline' => $timeline]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function timelineCreate()
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- return view('dashboard.contents.abouts.timeline.create');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function timelineEdit($id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $timeline = json_decode(Corporate::all('timelines')[0]->timelines)[$id];
- return view('dashboard.contents.abouts.timeline.update', ['timeline' => $timeline, 'id' => $id]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function timelineStore(Request $request)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $timeline = Corporate::find(1);
- $existingdata = json_decode(Corporate::all('timelines')[0]->timelines);
- $newdata = json_decode('{ "year": '.$request->year.', "event": '.json_encode($request->event).' }');
- $result = array_push($existingdata, $newdata);
- $timeline->update([
- 'timelines' => json_encode($existingdata)
- ]);
- return redirect()->route('abouts.timelineIndex')->with('alert-success', 'Data berhasil ditambah!');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function timelineUpdate(Request $request, $id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $timeline = Corporate::find(1);
- $existingdata = json_decode(Corporate::all('timelines')[0]->timelines);
- $existingdata[$id] = json_decode('{ "year": '.$request->year.', "event": '.json_encode($request->event).' }');
- $timeline->update([
- 'timelines' => json_encode($existingdata)
- ]);
- return redirect()->route('abouts.timelineIndex')->with('alert-success', 'Data berhasil diubah!');
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function timelineDestroy($id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- $timeline = Corporate::find(1);
- $existingdata = json_decode(Corporate::all('timelines')[0]->timelines);
- unset($existingdata[$id]);
- $timeline->update([
- 'timelines' => json_encode($existingdata)
- ]);
- return redirect()->route('abouts.timelineIndex')->with('alert-success', 'Data berhasil dihapus!');
- }
- /**
- * Show the form for creating a new resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function create()
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- return view('dashboard.contents.abouts.create');
- }
- /**
- * Store a newly created resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function store(Request $request)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- }
- /**
- * Display the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function show($id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- return view('dashboard.contents.abouts.view');
- }
- /**
- * Show the form for editing the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function edit($id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- return view('dashboard.contents.abouts.update');
- }
- /**
- * Update the specified resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function update(Request $request, $sectionName)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- }
- /**
- * Remove the specified resource from storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function destroy($id)
- {
- if (!Auth::check())
- {
- return redirect()->route('login');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement