404 when access via route edit

-3

My viewer

@extends('tamplate.menu')

@section ('content')     

Products

    Home                                                    New item                                             Description                 Price                 Amount                 Registration date                                                  @forelse ($ products as $ product)                        {{product-> description}}             {{product-> value_unit.'R $ '}}              {{product-> quantity}}             {{product-> data_cad}}                 To edit                 @empty                     

No product registered

        @endforelse                      @endsection

My routes    Route :: group (['prefix' => 'product'], function () {     // Route :: get ('product', 'ProductController @ create');         Route :: resource ('/', 'ControllerProduct');         // Route :: get ('edit / {{id}}', 'ControllerProduct @ edit');         // Route :: get ('/ edit / {id}', 'ProductController @ edit');         // Route :: match (['get', 'post'], '/ update / {id}', 'ProductController @ update');     // Route :: get ('/ product', 'ProductController @ index'); });

My controller '

Namespace App \ Http \ Controllers;

use Illuminate \ Http \ Request; use App \ Http \ Requests \ ProductStoreFormRequest; use App \ Product;

class ControllerProduct 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 utilizar href="{{route ('edit', 1)}}" em minha view para redirecionar ao método edit ', page not found.

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

    
asked by anonymous 27.10.2017 / 17:37

1 answer

0

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

Route

Use this outside the prefix and test!

    
30.10.2017 / 11:37