<?php

namespace App\Http\Controllers;
use App\Models\Socialmedia;
use Illuminate\Http\Request;

class SocialmediaController extends Controller
{
    ##UPDATE
    public function updatesocialmedia(Request $request){
        $validate           =   $request->validate([
            'instagram'     => 'required',
            'facebook'      => 'required',
            'youtube'       => 'required',
            'phonenumber'   => 'required',
            'whatsapp'      => 'required',
            'email'         => 'required',
        ]);
        $update          =  SocialMedia::first()->update($request->all());
        if ($update == true) {
            return response()->json(['status' => true,'message'=>'update Success'],200);
        }else{
            return response()->json(['status' => false,'message'=>'failed update'],400);
        }
    }

    ##GET
    public function getsocialmedia(){
        $getdata     = Socialmedia::all();
        if ($getdata == true){
            return response()->json(['status' => true, 'message' => 'Social media Records', 'data' => $getdata], 200);
        } else {
            return response()->json(['status' => false,'data' => 'failed data'], 400);
        }
    }
}
