They ask me to show the data of a user (using their id), I have created the table and the model with artisan, I have filled two objects in the phpmyadmin database, in the model I have Put this:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Firma extends Model
{
protected $table = 'empleados'; // Nombre de la tabla
protected $primaryKey = 'id_empleado'; // Clave primaria
// Columnas de la tabla
protected $fillable = ['id_perfil','nombre_empleado','puesto','telefono_empleado','email_empleado','direccion_empleado','status_empleado','date_added'];
}
On the controller this:
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
// Incluimos el modelo
use App\Firma;
class FirmaController extends Controller
{
// Creamos un método para atender la peticion llamado show
public function Index($id)
{
// Buscamos el id en la tabla
$dato = Auth::user()->id;
// retornamos la vista con los datos
return view('firmas')->with('dato', $dato);
// with() nos permite pasar variables a la vista
// el primer parámetros es el nombre con el que estará disponible en la vista
// el segundo son los datos.
}
}
I defined the route:
Route::get('/firmas', 'FirmaController@index')->name('firmas');
But when I want to show the data that the table has in the database like this:
{{ $dato->nombre }}
I get the error:
Too few arguments to function App\Http\Controllers\FirmaController::Index(), 0 passed and exactly 1 expected"
I do not know what I'm doing wrong, I just want to show data that I have in a table and follow this tutorial