Skip to content

Commit 314d550

Browse files
committed
Added Term and Updated Readme, Customer and QueryBuilderTrait
1 parent 81e5e74 commit 314d550

File tree

7 files changed

+131
-2
lines changed

7 files changed

+131
-2
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,20 @@
44
[![Quality Score](https://img.shields.io/scrutinizer/g/Codexshaper/laravel-woocommerce.svg?style=flat-square)](https://scrutinizer-ci.com/g/Codexshaper/laravel-woocommerce)
55
[![Latest Version on Packagist](https://img.shields.io/packagist/v/Codexshaper/laravel-woocommerce.svg?style=flat-square)](https://packagist.org/packages/Codexshaper/laravel-woocommerce)
66

7-
# Laravel Woocommerce
7+
# Description
88
WooCommerce Rest API for Laravel. You can Get, Create, Update and Delete your woocommerce product using this package easily.
99

10+
[Documentation](https://codexshaper.github.io/docs/laravel-woocommerce/)
11+
12+
## Authors
13+
14+
* **Md Abu Ahsan Basir** - [github](https://github.com/maab16)
15+
16+
## License
17+
18+
- **[MIT license](http://opensource.org/licenses/mit-license.php)**
19+
- Copyright 2020 © <a href="https://github.com/Codexshaper/laravel-woocommerce/blob/master/LICENSE" target="_blank">CodexShaper</a>.
20+
1021
#Install
1122

1223
```

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"Tag": "Codexshaper\\WooCommerce\\Models\\Tag",
5353
"Tax": "Codexshaper\\WooCommerce\\Models\\Tax",
5454
"TaxClass": "Codexshaper\\WooCommerce\\Models\\TaxClass",
55+
"Term": "Codexshaper\\WooCommerce\\Models\\Term",
5556
"Variation": "Codexshaper\\WooCommerce\\Models\\Variation",
5657
"WooCommerce": "Codexshaper\\WooCommerce\\Facades\\WooCommerce"
5758
}

src/Facades/Term.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Codexshaper\WooCommerce\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class Term extends Facade
8+
{
9+
/**
10+
* Get the registered name of the component.
11+
*
12+
* @return string
13+
*/
14+
protected static function getFacadeAccessor()
15+
{
16+
return 'Codexshaper\WooCommerce\Models\Term';
17+
}
18+
}

src/Models/Customer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ class Customer extends BaseModel
99
use QueryBuilderTrait;
1010

1111
protected $endpoint = 'customers';
12+
13+
protected function downloads($id)
14+
{
15+
$this->endpoint = "customers/{$id}/downloads";
16+
return self::all();
17+
}
1218
}

src/Models/Term.php

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
namespace Codexshaper\WooCommerce\Models;
4+
5+
use Codexshaper\WooCommerce\Facades\WooCommerce;
6+
7+
class Term extends BaseModel
8+
{
9+
protected $endpoint;
10+
11+
/**
12+
* Retrieve all Items.
13+
*
14+
* @param integer $attribute_id
15+
* @param array $options
16+
*
17+
* @return array
18+
*/
19+
protected function all($attribute_id, $options = [])
20+
{
21+
return WooCommerce::all("products/attributes/{$attribute_id}/terms", $options);
22+
}
23+
24+
/**
25+
* Retrieve single Item.
26+
*
27+
* @param int $attribute_id
28+
* @param int $id
29+
* @param array $options
30+
*
31+
* @return object
32+
*/
33+
protected function find($attribute_id, $id, $options = [])
34+
{
35+
return collect(WooCommerce::find("products/attributes/{$attribute_id}/terms/{$id}", $options));
36+
}
37+
38+
/**
39+
* Create new Item.
40+
*
41+
* @param int $attribute_id
42+
* @param array $data
43+
*
44+
* @return object
45+
*/
46+
protected function create($attribute_id, $data)
47+
{
48+
return WooCommerce::create("products/attributes/{$attribute_id}/terms", $data);
49+
}
50+
51+
/**
52+
* Update Existing Item.
53+
*
54+
* @param int $attribute_id
55+
* @param int $id
56+
* @param array $data
57+
*
58+
* @return object
59+
*/
60+
protected function update($attribute_id, $id, $data)
61+
{
62+
return WooCommerce::update("products/attributes/{$attribute_id}/terms/{$id}", $data);
63+
}
64+
65+
/**
66+
* Destroy Item.
67+
*
68+
* @param int $attribute_id
69+
* @param int $id
70+
* @param array $options
71+
*
72+
* @return object
73+
*/
74+
protected function delete($attribute_id, $id, $options = [])
75+
{
76+
return WooCommerce::delete("products/attributes/{$attribute_id}/terms/{$id}", $options);
77+
}
78+
79+
/**
80+
* Batch Update.
81+
*
82+
* @param int $attribute_id
83+
* @param array $data
84+
*
85+
* @return object
86+
*/
87+
protected function batch($attribute_id, $data)
88+
{
89+
return WooCommerce::create("products/attributes/{$attribute_id}/terms/batch", $data);
90+
}
91+
}

src/Models/Variation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Variation extends BaseModel
1111
/**
1212
* Retrieve all Items.
1313
*
14+
* @param integer $product_id
1415
* @param array $options
1516
*
1617
* @return array
@@ -23,6 +24,7 @@ protected function all($product_id, $options = [])
2324
/**
2425
* Retrieve single Item.
2526
*
27+
* @param int $product_id
2628
* @param int $id
2729
* @param array $options
2830
*

src/Traits/QueryBuilderTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function delete($id, $options = [])
9191
*/
9292
protected function batch($data)
9393
{
94-
return WooCommerce::create('{$this->endpoint}/batch', $data);
94+
return WooCommerce::create("{$this->endpoint}/batch", $data);
9595
}
9696

9797
/**

0 commit comments

Comments
 (0)