Error url $ feed-id

1

Hello, I'm working on a system with feed scheme. Clicking "Edit" displays the following error:

  

SQLSTATE [22P02]: Invalid text representation: 7 ERROR: invalid input   syntax for integer: "$ feed- > id" (SQL: select * from "feeds" where   "feeds". "id" = $ feed-> id limit 1)

I noticed in the URL where it was to have something like:

http://localhost:8000/feed/2/update

It appears as:

http://localhost:8000/feed/$feed->id/update

How to solve this? I hope you have made my point clear. Thank you in advance.

Codes:

home.blade.php (home)

@extends('layouts.app')

@section('content')
<div class="container">
   @forelse($feeds as $feed)
      <h1>{{$feed->title}}</h1>
      <p>{{$feed->description}}</p>
      <b>Publicado por: {{$feed->user->name}}</b>
      <a href="{{url('/feed/$feed->id/update')}}">Editar</a>
      <hr>
   @empty
      <p>Nenhum chamado cadastrado!</p>
   @endforelse
</div>
@endsection

web.php (routes)

<?php
Route::get('/', function () {
return view('auth/login');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

Route::get('feed/{id}/update', 'HomeController@update');

HomeController.php (controller)

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\feed;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(feed $feed)
    {
        //$feeds = $feed->all();
        $feeds = $feed->where('user_id', auth()->user()->id)->get();

        return view('home', compact('feeds'));
    }

    public function update($idFeed)
    {
        $feed = feed::find($idFeed);

        return view('feed-update', compact('feed'));
    }
}

feed-update.blade.php (feed view)

@extends('layouts.app')

@section('content')
<div class="container">
    <h1>{{$feed->title}}</h1>
    <p>{{$feed->description}}</p>
    <b>Publicado por: {{$feed->user->name}}</b>    
</div>
@endsection
    
asked by anonymous 19.04.2018 / 20:27

1 answer

1

I believe the problem is in this% excerpt of the home.blade.php file where $ feed-> id is inside single quotation marks. Please try the following:

<a href="{{url('/feed/' . $feed->id .'/update')}}">Editar</a>

Or also:

<a href="{{url(sprintf( '/feed/%s/update', $feed->id ))}}">Editar</a>
    
19.04.2018 / 20:52