PATH:
home
/
lab2454c
/
healthvalidate.com
/
app
/
Http
/
Controllers
/
admin
<?php namespace App\Http\Controllers\admin; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\SocialLink; use Illuminate\Support\Facades\Storage; use Illuminate\Http\File; class SocialLinkController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $data['socialLinks'] = SocialLink::all(); return view('admin.dashboard.social_links.list', $data); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('admin.dashboard.social_links.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $values = $request->validate([ "name" => 'required|string|max:50|unique:social_links,name', "logo"=>'required|image|max:1000', "link"=>'required|url|max:300' ]); if (isset($values['logo'])) { $values['logo'] = Storage::putFile('public/social', new File($request->logo)); } $socialLink = new SocialLink(); $socialLink->fill($values); $socialLink->save(); return redirect()->route('admin.socialLink.index')->with('success', 'Social added Successfully!'); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit(SocialLink $socialLink) { $data['socialLink'] = $socialLink; return view('admin.dashboard.social_links.edit', $data); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, SocialLink $socialLink) { $changed = false; $values = $request->validate([ "name" => 'required|string|max:50|unique:social_links,name,'. $socialLink->id, "logo"=>'nullable|image|max:1000', "link"=>'required|url|max:300' ]); if ($request->logo) { Storage::delete($socialLink->logo); $values['logo'] = Storage::putFile('public/social', new File($request->logo)); } $socialLink->fill($request->except('logo')); if (isset($values['logo'])) { $socialLink->logo = $values['logo']; } if ($socialLink->isDirty()) { $socialLink->save(); $changed = true; } if (! $changed) { return redirect()->route('admin.socialLink.index')->withErrors('No changes done to save'); } return redirect()->route('admin.socialLink.index')->with('success', 'Social Updated Successfully!'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(SocialLink $socialLink) { if ($socialLink->status == 'active') { $socialLink->status = 'inactive'; } else { $socialLink->status = 'active'; } $socialLink->save(); return redirect()->route('admin.socialLink.index')->with('success', 'Changes Saved!'); } }
[+]
..
[-] ChecklistContentController.php
[edit]
[-] DynamicPageController.php
[edit]
[-] ManageAdminAuthentication.php
[edit]
[-] SocialLinkController.php
[edit]
[-] CopyrightController.php
[edit]
[-] BannerImageController.php
[edit]
[-] GalleryController.php
[edit]
[-] VaccinationReviewContentController.php
[edit]
[-] LegalConsentController.php
[edit]
[-] HelpController.php
[edit]
[+]
dashboard