404 when accessing via route Edit

Asked

Viewed 66 times

-3

my Viewer

@extends('tamplate.menu')

@Section('content')

Products


New item Description Price Amount Registration date @forelse($products as $product) {{$product->Description}} {{$product->valor_unit. 'R$'}} {{$product->quantity}} {{$product->data_cad}} Edit @Empty

no registered product

@endforelse @endsection

my routes Route::group(['prefix'=>'product'],Function(){ //Route::get('product','Productocontroller@create'); Route::Resource('/','Controllerproduto'); //Route::get('Edit/{id}}','Controllerproduto@edit'); //Route::get('/Edit/{id}','Productocontroller@edit'); //Route::match(['get','post'],'/update/{id}','Productocontroller@update'); //Route::get('/product','Productocontroller@index'); });

My controller `

namespace App Http Controllers;

use Illuminate Http Request; use App Http Requests Productostoreformrequest; use App Product;

class Controllerproduto extends Controller { /** * Display a Listing of the Resource. * * @Return Illuminate Http Response */ private $product;

public function __construct(Produto $produto){
    $this->produto = $produto;
}
public function index()
{
    $produtos = $this->produto->all();

    return view('produtos.exibe_produtos',compact('produtos'));
}

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

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
     $dados = $request->all();
    if($dados['data_cad'] == ''){
        $dados['data_cad'] = '2015-10-10';
    }


    $insert = $this->produto->create($dados);
    /*$validate = validator($dados,$this->produto->rules,$messages);
    if( $validate->fails()){
        return redirect()->back()
                         ->withErrors($validate)
                         ->withInput();
    }else{

    }
    //$this->validate($request, $this->produto->rules);
    $insert = $this->produto->create($dados);


    */


        return redirect('produto');

}

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

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

/**
 * 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)
{
    //
}

} Ao utilizarhref="{{ route('Edit',1)}}"em minhaviewpara redirecionar ao métodoEdit`, page not found.

Using the href="{{route('create')}}", works properly.

aqui esta o print do meu codigo[![][1][1]

  • 5

    Post your code, not everyone can open the image.

  • I’m new to this forum, I don’t know how it works exactly

1 answer

0

to use the RESOURCE method on the route, do not put inside the prefix.

Route::Resource('product','Controllerproduct');

uses this out of the prefix and forehead!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.