<?php

namespace App\Http\Controllers;
date_default_timezone_set('America/Mexico_city');
use Illuminate\Http\Request;
use Illuminate\Session\SessionManager;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use App\Mail\EnvioMails;//Archivo PHP que se creo para el envio de archivos
use App\Mail\ServicioSocial;
use App\Http\Requests;
use App\Http\Requests\CreateLeyendaRequest;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use App\Actividad;
use App\Alumno;
use App\Autorizacion;
use App\Calendario;
use App\Carrera;
use App\Carta;
use App\Dependencia;
use App\Evaluacion;
use App\EvaluacionAlumno;
use App\EventoCalendario;
use App\Leyenda;
use App\Membrete;
use App\Programa;
use App\RenglonEvaluacion;
use App\Reporte;
use App\ReporteEvaluacion;
use App\Respuesta;
use App\Solicitud;
use App\SubirArchivo;
use App\TipoArchivo;
use App\TipoMembrete;
use File;
use put;
use DB;
use PDF;
use Download;
use View;
use App;
use Mail;
use Session;
use csrf_token;
use QrCode;
use Validator;

class LeyendaController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('membretes.leyendas');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(CreateLeyendaRequest $request)
    {
        $ley = strtr(strtoupper($request['leyenda']),"àèìòùáéíóúçñäëïöü", "ÀÈÌÒÙÁÉÍÓÚÇÑÄËÏÖÜ");

        DB::beginTransaction();

        $leyenda = new Leyenda();
        $leyenda->leyenda_ley = $ley;
        $leyenda->save();

        if ($leyenda) {
            DB::commit();
            return response()->json(['exito'=>'La leyenda se subió con éxito.']);
        }else{
            DB::rollBack();
            return response()->json(['error'=>'Ocurrió un error, vuelve a intentarlo.']);
        }
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
