Method Illuminate\Database\Query\Builder::withTrash... | Fórum | School of Net

Deseja poder participar de nosso fórum e tirar todas as suas dúvidas?
Clique aqui e assine nosso plano de acesso ilimitado. Saiba mais.

por JOAO MATHEUS

1 ano, 7 meses atrás JOAO MATHEUS

Method Illuminate\Database\Query\Builder::withTrashed does not exist.

Ao passar o onlyTrashed com o get estou tendo o erro do titulo da pergunta.``` Codifique aqui ``` <?php namespace App\Http\Controllers; use App\Product; use Illuminate\Http\Request; use App\Http\Resources\Product as ProductResource; use App\Http\Resources\Products as ProductsResource; class ProductController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { Product::withTrashed()->find(2)->restore(); return new ProductsResource(Product::onlyTrashed()->get()); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param \App\Product $product * @return \Illuminate\Http\Response */ public function show(Product $product) { } /** * Show the form for editing the specified resource. * * @param \App\Product $product * @return \Illuminate\Http\Response */ public function edit(Product $product) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Product $product * @return \Illuminate\Http\Response */ public function update(Request $request, Product $product) { // } /** * Remove the specified resource from storage. * * @param \App\Product $product * @return \Illuminate\Http\Response */ public function destroy(Product $product) { // } }

2 Respostas