ProductQueryController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Http\Controllers\Seller;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\ProductQuery;
  5. use Auth;
  6. use Illuminate\Http\Request;
  7. class ProductQueryController extends Controller
  8. {
  9. /**
  10. * Retrieve queries that belongs to current seller
  11. */
  12. public function index()
  13. {
  14. $queries = ProductQuery::where('seller_id', Auth::id())->latest()->paginate(20);
  15. return view('seller.product_query.index', compact('queries'));
  16. }
  17. /**
  18. * Retrieve specific query using query id.
  19. */
  20. public function show($id)
  21. {
  22. $query = ProductQuery::find(decrypt($id));
  23. return view('seller.product_query.show', compact('query'));
  24. }
  25. /**
  26. * Store reply against the question from seller panel
  27. */
  28. public function reply(Request $request, $id)
  29. {
  30. $this->validate($request, [
  31. 'reply' => 'required',
  32. ]);
  33. $query = ProductQuery::find($id);
  34. $query->reply = $request->reply;
  35. $query->save();
  36. flash(translate('Replied successfully!'))->success();
  37. return redirect()->route('seller.product_query.index');
  38. }
  39. }