MINI MINI MANI MO

Path : /var/www/html/sistemas/spid/app/Http/Controllers/
File Upload :
Current File : /var/www/html/sistemas/spid/app/Http/Controllers/ActaController.php

<?php

namespace App\Http\Controllers;

use App\Models\actaSesion;
use App\Models\AsuntosOrdenDia;
use App\Models\EventoVotos;
use App\Models\MarcoJuridico;
use App\Models\OrdenDia;
use Dflydev\DotAccessData\Data;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;

class ActaController extends Controller
{
    private $request;

    public function __construct(Request $request) {
        $this->request=$request;
//        $this->middleware('auth');
    }

    public function index()
    {
        $actaActual = actaSesion::where('status' ,1 )->first();
        if (auth()->user()->DatosUsers->tipo_usuario == 1) {
            return view('pantalla.createActas', compact('actaActual'));
        }else{
            return redirect('cerrar');
        }
    }

    public function store(Request $request)
    {
        $evento = EventoVotos::where('estatus', 1)->first();

        $directorio = 'public/actas/';
        Storage::makeDirectory($directorio);
        $uuid = str::uuid();
        $path = 'actas/' . $uuid . '.pdf';
        $pdf = $request->file('acta')->storeAs($directorio, $uuid . '.pdf');
        $evento = $evento->id;

        $actasAct = actaSesion::where('status',1)->get();
        if(count($actasAct)){
            foreach ($actasAct as $act){
                $actasDesactivar = actaSesion::find($act->id);
                $acta["status"] = false;
                $actasDesactivar->update($acta);
            }
        }

        $actas["path_acta"] = $path;
        $actas["id_evento"] = $evento;
        $actas["status"] = 1;
        $acta = actaSesion::create($actas);

        return redirect('acta');
    }

    public function  getActas(){
//        $acta = actaSesion::where('status',true)->get();
//        if (count($acta)){
//            $url = $acta[0]->path_acta ;
//            $file = Storage::get($url);
//            $fileMime = Storage::mimeType($url);
//            return response($file, 200)->header('Content-Type', $fileMime);
//        }else{
//            return view('pantalla.inhabilitado');
//        }
        $evento = EventoVotos::where('estatus', 1)->first();
        $acta = actaSesion::where('id_evento', $evento->id)->where('status', 1)->first();
        if ($acta){
            $url = $acta->path_acta;
            return view('sistemaVotos.indexActaDip', compact('url'));
        }else{
            return view('pantalla.inhabilitado');
        }
    }

    public function  getOrden(){
//        $acta = OrdenDia::where('status',true)->get();
//        if (count($acta)){
//            $url = $acta[0]->path_orden ;
//            $file = Storage::get($url);
//            $fileMime = Storage::mimeType($url);
//            return response($file, 200)->header('Content-Type', $fileMime);
//        }else{
//            return view('pantalla.inhabilitado');
//        }
        $evento = EventoVotos::where('estatus', 1)->first();
        $acta = OrdenDia::where('id_evento', $evento->id)->where('status', 1)->first();
        if ($acta){
            $url = $acta->path_orden;
            return view('sistemaVotos.indexOrdenDip', compact('url'));
        }else{
            return view('pantalla.inhabilitado');
        }
    }

    public function  getAsuntos(){
        $evento = EventoVotos::where('estatus', 1)->first();
        if ($evento->asuntos){
            return view('sistemaVotos.indexAsuntosDip', compact('evento'));
        }else{
            return view('pantalla.inhabilitado');
        }
    }

    public function  getMarco(){
        $marco = MarcoJuridico::where('status',true)->get();
        if (count($marco)){
            return view('pantalla.documentos', compact('marco'));
        }else{
            return view('pantalla.inhabilitado');
        }
    }

    public function getFile($ID) {
        $documento = MarcoJuridico::find($ID);
        $url = $documento->path_marco ;
        $file = Storage::get($url);
        $fileMime = Storage::mimeType($url);
        return response($file, 200)->header('Content-Type', $fileMime);

    }

    public function ObtenerDetalleDocumento($id) {
        $documento = MarcoJuridico::where('status',1)->get();
        return $documento;
    }

    public function show($id){
        $acta = actaSesion::find($id);
        $url = '/public/'.$acta->path_acta;
        $file = Storage::get($url);
        $fileMime = Storage::mimeType($url);
        return response($file, 200)->header('Content-Type', $fileMime);
    }
}

OHA YOOOO