mirror of
https://github.com/Cybrarist/Discount-Bandit.git
synced 2026-11-24 19:49:54 +01:00
add global search hotkey add community stores where users can import/export stores from new repository fix media markt 404 on crawling add currency resource, so users can modify the rate without the need for API add new '*' in case there are multiple fields in schema add basic code for plugin support to test it in production, shouldn't affect anything add warning message if ntfy is added without topic
75 lines
1.6 KiB
PHP
75 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\StoreProductRequest;
|
|
use App\Http\Requests\UpdateProductRequest;
|
|
use App\Models\Product;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ProductController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index(Request $request)
|
|
{
|
|
$validated = $request->validate([
|
|
'search' => ['required', 'string'],
|
|
]);
|
|
|
|
return Product::whereLike('name', "%{$validated['search']}%")
|
|
->pluck('name', 'id');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(StoreProductRequest $request)
|
|
{
|
|
$validated = $request->validated();
|
|
|
|
Auth::user()->products()
|
|
->create($validated);
|
|
|
|
return response()->json(['message' => 'Product Created Successfully']);
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(Product $product)
|
|
{
|
|
$product->load([
|
|
'links',
|
|
'links.link_histories',
|
|
'categories',
|
|
]);
|
|
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(Product $product)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(UpdateProductRequest $request, Product $product)
|
|
{
|
|
//
|
|
}
|
|
|
|
public function snooze(Product $product)
|
|
{
|
|
$product->update(['snoozed_until' => today()->addDay()]);
|
|
|
|
return "Product Snoozed Successfully Until ".today()->addDay()->toDateTimeString();
|
|
}
|
|
}
|