PagesController.php 1.74 KB
<?php

namespace App\Http\Controllers;

use App\Http\Requests\RequestSendAdmin;
use App\Mail\MailAdminy;
use App\Mail\MailRepair;
use App\Models\pages;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Redis;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

class PagesController extends Controller
{
    public function pages(pages $pages) {
       $page = pages::query()->where('slug', $pages->slug)->first();

       return view('pages', compact('page'));
    }

    public function form_feedback(RequestSendAdmin $request){
        $all = $request->all();

        foreach ([$request->get('email')] as $recipient) {
            Mail::to($recipient)->send(new MailAdminy($all));
        }

        return redirect()->back()->with('Сообщение было успешно отправлено и будет обработано');
    }

    public function redis() {
        $redis = Redis::connection();
        $redis->set('User:CompanyName', 'РЕКАМОРЕ');
        $id = 1;
        //dd(Redis::get('MyVar'));
        $redis->command('rpush', array("Сообщение1"));
        $redis->command('rpush', array("Сообщение2"));
        $values = $redis->command('lrange', array("mylist", 0, 1));
        dd($values);

    }

    public function excel() {
        $spreadsheet = new Spreadsheet();
        $activeWorksheet = $spreadsheet->getActiveSheet();
        $activeWorksheet->setCellValue('A1', 'Hello World !');

        $writer = new Xlsx($spreadsheet);
        $writer->save('hello_world.xlsx');
    }

    public function private_policy() {
        return view('private_policy');
    }

    public function terms_of_use() {
        return view('terms_of_use');
    }
}