PATH:
home
/
lab2454c
/
internationalminersbank.com
/
backup
/
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 { public function __construct() { $this->middleware('auth:admin'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $data['socialLinks'] = SocialLink::all(); return view('admin.socialLink.list', $data); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('admin.socialLink.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(); toast($socialLink->name . ' created Successfully!','success'); return redirect()->route('socialLink.index'); } /** * 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.socialLink.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) { toast('No changes done to save','warning'); return redirect()->route('socialLink.index')->withErrors('No changes done to save'); } toast($socialLink->name . ' updated successsfully!','success'); return redirect()->route('socialLink.index'); } /** * 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(); toast($socialLink->name . ' ' . (($socialLink->status == 'inactive') ? 'Disabled' : 'Enabled') . ' successfully!','success'); return redirect()->route('socialLink.index'); } }
[-] HomeBannerController.php
[edit]
[-] EventController.php
[edit]
[-] CategoryController.php
[edit]
[-] PasswordController.php
[edit]
[-] CareerController.php
[edit]
[-] CareerContentController.php
[edit]
[+]
..
[-] EventContentController.php
[edit]
[-] SiteSettingController.php
[edit]
[-] ServiceController.php
[edit]
[-] PageController.php
[edit]
[-] TestimonialController.php
[edit]
[-] HomeTitleController.php
[edit]
[-] SocialLinkController.php
[edit]
[-] FeaturedProductController.php
[edit]
[-] ExploreController.php
[edit]
[-] MinerPageController.php
[edit]
[-] AdminUserController.php
[edit]
[-] LeadershipController.php
[edit]
[-] FaqController.php
[edit]
[-] CommodityTraderPageController.php
[edit]
[-] GalleryController.php
[edit]
[-] LoginController.php
[edit]
[-] MinerContentController.php
[edit]
[-] TraderBannerLinkController.php
[edit]
[-] DashboardController.php
[edit]
[-] MinerBannerLinkController.php
[edit]
[-] CommodityTraderContentController.php
[edit]