<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class SettingsController extends Controller
{
    public function companySettings()
    {
        // রিপোর্ট কন্ট্রোলার থেকে এখানে শিফট করা হইলো
        $company = DB::table('company_profiles')->first();
        return view('admin.settings.company', compact('company'));
    }

    public function updateCompanySettings(Request $request)
    {
        $data = [
            'school_name'      => $request->school_name,
            'slogan'           => $request->slogan,
            'contact_number'   => $request->contact_number,
            'email'            => $request->email,
            'address'          => $request->address,
            'currency_symbol'  => $request->currency_symbol,
            'updated_at'       => now(),
        ];

        if ($request->hasFile('logo')) {
            $data['logo'] = $request->file('logo')->store('logos', 'public');
        }

        DB::table('company_profiles')->where('id', $request->id)->update($data);

        return back()->with('success', 'প্রতিষ্ঠানের তথ্য আপডেট হয়েছে!');
    }
}