You see, I've already got my Laravel project to work on a web server, which is at 000webhost. Now I have a new problem, which I need to print PDF documents: For starters, I have a table Game with these values:
Schema::create('juegos', function (Blueprint $table){
$table->increments('id');
$table->integer('numero')->unique();
$table->string('nombre');
$table->unsignedInteger('agrupacion_id');
$table->foreign('agrupacion_id')->references('id')->on('agrupacions');
$table->text('materiales');
$table->text('organizacion');
$table->text('desarrollo');
$table->string('foto');
$table->text('observaciones');
$table->text('variantes');
$table->timestamps();
});
This is the PDF document that will be printed:
@extends('layouts.app')
<html lang="es">
<body>
<font size="15" style="display: inline;">Juego Nº {{$j->numero}}: {{$j->nombre}}</font> <img style="width: 68px; height: 68px;" align="right" src="{{url($j->ruta())}}"/>
<hr>
<div class="row justify-content-center">
<div class="col-md-5 card card-1">
<div class="card-body">
<p><b>Materiales:</b> {{$j->materiales}}</p><br>
<p><b>Agrupación de los jugadores:</b> {{$j->agrupacion->nombre}}</p><br>
<h3>Organización:</h3>
<p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->organizacion}}</p>
<br><br><br>
<h3>Desarrollo del juego</h3>
<p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->desarrollo}}</p>
@if($j->observaciones!="*")
<br><br>
<h3>Reglas y observaciones:</h3>
<p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->observaciones}}</p>
@endif
@if($j->variantes!="*")
<br><br>
<h3>Variantes:</h3>
<p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->variantes}}</p>
@endif
<?php
$contenidos=$j->enlaces;
?>
@if(count($contenidos))
<br><br><br>
<h3>Contenidos:</h3>
@foreach($contenidos as $contenido)
<span class="badge badge-cat badge-info">{{$contenido->contenido->nombre}}</span>
@endforeach
@endif
</div>
</div>
</div>
</body>
</html>
And this the controller:
public function imprimir(Juego $j){
$pdf = PDF::loadView('pdf.juego', compact('j'));
$salida=$pdf->output();
$ruta='C:/Users/pcx/Desktop/Juego '.$j->numero.' '.$j->nombre.'.pdf';
file_put_contents($ruta, $salida);
return back()->with('message',['success','El PDF con los datos del juego se han creado con exito. Buscalo en tu escritorio.']);
}
When I used localhost, this worked fine, but now I run into this error message:
Does anyone know how this is solved? Edito: I have currently introduced modifications to confif / mail.php:
<?php
return [
'driver' => env('MAIL_DRIVER', 'sendmail'),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
Now when I try to print a PDF, this comes out:
It seems to be a firewall problem in my browser (Firefox). Does anyone know what I should do?