PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / trunk
Fluent Support – Helpdesk & Customer Support Ticket System vtrunk
2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 68 releases
fluent-support / app / Http / Controllers / ProductController.php

ProductController.php in Fluent Support – Helpdesk & Customer Support Ticket System trunk, at app/Http/Controllers/ProductController.php

74 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Http\Controllers;
4
5 use FluentSupport\App\Http\Requests\ProductRequest;
6 use FluentSupport\App\Models\Product;
7 use FluentSupport\Framework\Http\Request\Request;
8
9 class ProductController extends Controller
10 {
11 /**
12 * index method will return the list of product
13 * @param Request $request
14 * @param Product $product
15 * @return array
16 */
17 public function index( Request $request, Product $product )
18 {
19 return $product->getProducts( $request->getSafe('search', 'sanitize_text_field') );
20 }
21
22 /**
23 * get method will get product by id and return
24 * @param Product $product
25 * @param int $product_id
26 * @return array
27 */
28 public function get( Product $product, $product_id )
29 {
30 return $product->getProduct( $product_id );
31 }
32
33 /**
34 * creare method will create new product
35 * @param Request $request
36 * @param Product $product
37 * @return array
38 * @throws \FluentSupport\Framework\Validator\ValidationException
39 */
40 public function create( ProductRequest $request, Product $product )
41 {
42 $data = $request->all();
43
44 return $product->createProduct( $data );
45 }
46
47
48 /**
49 * update methd will update an exiting product by id
50 * @param Request $request
51 * @param Product $product
52 * @param int $product_id
53 * @return array
54 * @throws \FluentSupport\Framework\Validator\ValidationException
55 */
56 public function update( ProductRequest $request, Product $product, $product_id )
57 {
58 $data = $request->all();
59
60 return $product->updateProduct( $product_id, $data );
61 }
62
63 /**
64 * delete method will delete an existing product by id
65 * @param Product $product
66 * @param int $product_id
67 * @return array
68 */
69 public function delete( Product $product, $product_id )
70 {
71 return $product->deleteProduct( $product_id );
72 }
73 }
74