|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
|
6
|
|
|
use App\Http\Requests\Admin\CreateUpdatePriceCategory; |
|
7
|
|
|
use App\PriceCategory; |
|
8
|
|
|
use Illuminate\Support\Facades\Log; |
|
9
|
|
|
|
|
10
|
|
|
class PriceCategoryController extends Controller |
|
11
|
|
|
{ |
|
12
|
|
|
public function create(CreateUpdatePriceCategory $request) |
|
13
|
|
|
{ |
|
14
|
|
|
$validated = $request->validated(); |
|
15
|
|
|
$category = PriceCategory::create([ |
|
16
|
|
|
'name' => $validated['name'], |
|
17
|
|
|
'description' => $validated['description'], |
|
18
|
|
|
'price' => $validated['price'] |
|
19
|
|
|
]); |
|
20
|
|
|
// On successfull creation redirect the browser to the overview |
|
21
|
|
|
return redirect() |
|
22
|
|
|
->route('admin.dependencies.prices.category.get', $category) |
|
23
|
|
|
->with('status', 'Created ' . $category->name . '!'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function get(PriceCategory $category) |
|
27
|
|
|
{ |
|
28
|
|
|
return view('admin.dependencies.manage-price-category', ['category' => $category]); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function update(PriceCategory $category, CreateUpdatePriceCategory $request) |
|
32
|
|
|
{ |
|
33
|
|
|
$validated = $request->validated(); |
|
34
|
|
|
|
|
35
|
|
|
$category->name = $validated['name']; |
|
36
|
|
|
$category->description = $validated['description']; |
|
37
|
|
|
$category->price = $validated['price']; |
|
38
|
|
|
$category->save(); |
|
39
|
|
|
|
|
40
|
|
|
// On successfull update redirect the browser to the overview |
|
41
|
|
|
return redirect() |
|
42
|
|
|
->route('admin.dependencies.prices.category.get', $category) |
|
43
|
|
|
->with('status', 'Updated ' . $category->name . '!'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function delete(PriceCategory $category) |
|
47
|
|
|
{ |
|
48
|
|
|
Log::info('Deleting priceCategory#' . $category->id . ' (' . $category->name . ')'); |
|
49
|
|
|
|
|
50
|
|
|
$category->delete(); |
|
51
|
|
|
|
|
52
|
|
|
// On successfull deletion redirect the browser to the overview |
|
53
|
|
|
return redirect() |
|
54
|
|
|
->route('admin.dependencies.dashboard') |
|
55
|
|
|
->with('status', 'Deleted price category successfull!'); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|