You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: actions.md
+1-14Lines changed: 1 addition & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,24 +28,11 @@ use Illuminate\Http\Request;
28
28
public function actions(Request $request): array
29
29
{
30
30
return [
31
-
new SendPasswordResetNotification(),
31
+
new SendPasswordResetNotification,
32
32
];
33
33
}
34
34
```
35
35
36
-
Alternatively, you can use `withActions` method on an object that resolves actions. It can be useful when you just want to hook into the object for some reason.
37
-
38
-
```php
39
-
use App\Root\Actions\SendPasswordResetNotification;
40
-
use Illuminate\Http\Request;
41
-
42
-
$resource->withActions(static function (Request $request): array {
> Before moving on, you may check the [tax documentation](/docs/tax) about managing taxes.
178
-
179
177
The `Cart` model uses the `Itemable` trait, which allows the model to interact with its `Taxable` models. Taxes are stored on the `Item` and `Shipping` models.
180
178
181
179
There are several methods to retrieve the aggregated tax for the model:
> Before moving on, you may check the [shipping documentation](/docs/shipping) about managing shipping methods.
218
-
219
213
```php
220
-
use Bazar\Support\Facades\Cart;
214
+
use Cone\Bazar\Support\Facades\Cart;
221
215
222
216
// Get the calculated shipping cost
223
217
Cart::getModel()->shipping->getCost();
@@ -238,7 +232,7 @@ However, this behavior can be controlled by the lock/unlock mechanism. When the
238
232
> Note, you may retrieve the `Cart` model using the `Cart` facade for this feature.
239
233
240
234
```php
241
-
use Bazar\Models\Cart;
235
+
use Cone\Bazar\Models\Cart;
242
236
243
237
$cart = Cart::first();
244
238
@@ -264,7 +258,7 @@ This can be extremely useful in the checkout process. Locking the cart can make
264
258
To keep the database clean, carts without owners **expire in 3 days**. To retrieve the expired carts, you may use the `expired()` query scope on the `Cart` model:
265
259
266
260
```php
267
-
use Bazar\Models\Cart;
261
+
use Cone\Bazar\Models\Cart;
268
262
269
263
$expired = Cart::expired()->get();
270
264
```
@@ -309,8 +303,8 @@ Like shipping and payment gateway, Bazar manages multiple cart drivers as well.
309
303
Registering cart drivers works almost the same as registering shipping methods or payment gateways. All custom drivers should extend the `Bazar\Cart\Driver` class, which holds one abstract method: `resolve()`.
310
304
311
305
```php
312
-
use Bazar\Cart\Driver;
313
-
use Bazar\Models\Cart;
306
+
use Cone\Bazar\Cart\Driver;
307
+
use Cone\Bazar\Models\Cart;
314
308
315
309
class TokenDriver extends Driver
316
310
{
@@ -333,7 +327,7 @@ class TokenDriver extends Driver
333
327
Now, let's register the driver using the `Bazar\Support\Facades\Cart` facade:
334
328
335
329
```php
336
-
use Bazar\Support\Facades\Cart;
330
+
use Cone\Bazar\Support\Facades\Cart;
337
331
338
332
Cart::extend('custom', function ($app): CustomDriver {
339
333
return new CustomDriver(
@@ -353,17 +347,17 @@ Taxes are stored on the `Item` and the `Shipping` models. Both implement the `Ta
353
347
You may register taxes using the `Tax` facade. You can pass a number, a `Closure`, or a class (that implements the `Bazar\Contracts\Tax` interface) along with the name of the tax.
354
348
355
349
```php
356
-
use Bazar\Support\Facades\Tax;
350
+
use Cone\Bazar\Support\Facades\Tax;
357
351
358
352
// Fix tax
359
353
Tax::register('fix-20', 20);
360
354
```
361
355
362
356
```php
363
357
// Custom closure tax
364
-
use Bazar\Models\Shipping;
365
-
use Bazar\Contracts\LineItem;
366
-
use Bazar\Support\Facades\Tax;
358
+
use Cone\Bazar\Models\Shipping;
359
+
use Cone\Bazar\Contracts\LineItem;
360
+
use Cone\Bazar\Support\Facades\Tax;
367
361
368
362
Tax::register('custom-percent', function (LineItem $model) {
@@ -372,10 +366,10 @@ Tax::register('custom-percent', function (LineItem $model) {
372
366
373
367
```php
374
368
// Class tax
375
-
use Bazar\Contracts\Tax as Contract;
376
-
use Bazar\Contracts\LineItem;
377
-
use Bazar\Models\Shipping;
378
-
use Bazar\Support\Facades\Tax;
369
+
use Cone\Bazar\Contracts\Tax as Contract;
370
+
use Cone\Bazar\Contracts\LineItem;
371
+
use Cone\Bazar\Models\Shipping;
372
+
use Cone\Bazar\Support\Facades\Tax;
379
373
380
374
class CustomTax implements Contract
381
375
{
@@ -395,7 +389,7 @@ Tax::register('complex-tax', new CustomTax);
395
389
You may remove registered taxes using the `Tax` facade.
396
390
397
391
```php
398
-
use Bazar\Support\Facades\Tax;
392
+
use Cone\Bazar\Support\Facades\Tax;
399
393
400
394
Tax::remove('complex-tax');
401
395
```
@@ -405,7 +399,7 @@ Tax::remove('complex-tax');
405
399
You may disable tax calculation globally in some scenarios. To do so, call the `disable` method on the `Tax` facade.
406
400
407
401
```php
408
-
use Bazar\Support\Facades\Tax;
402
+
use Cone\Bazar\Support\Facades\Tax;
409
403
410
404
Tax::disable();
411
405
```
@@ -423,15 +417,15 @@ Discounts are stored on the `Item` and the `Shipping` models. Both implement the
423
417
You may register discounts using the `Discount` facade. You can pass a number, a `Closure`, or a class (that implements the `Bazar\Contracts\Discount` interface) along with the name of the discount.
424
418
425
419
```php
426
-
use Bazar\Support\Facades\Discount;
420
+
use Cone\Bazar\Support\Facades\Discount;
427
421
428
422
// Fix discount
429
423
Discount::register('fix-20', 20);
430
424
```
431
425
432
426
```php
433
427
// Custom closure discount
434
-
use Bazar\Support\Facades\Discount;
428
+
use Cone\Bazar\Support\Facades\Discount;
435
429
436
430
Discount::register('custom-percent', function (Discountable $model) {
437
431
return $model->getTotal() * 0.3;
@@ -440,9 +434,9 @@ Discount::register('custom-percent', function (Discountable $model) {
440
434
441
435
```php
442
436
// Class discount
443
-
use Bazar\Contracts\Discount as Contract;
444
-
use Bazar\Contracts\Discountable;
445
-
use Bazar\Support\Facades\Discount;
437
+
use Cone\Bazar\Contracts\Discount as Contract;
438
+
use Cone\Bazar\Contracts\Discountable;
439
+
use Cone\Bazar\Support\Facades\Discount;
446
440
447
441
class CustomDiscount implements Contract
448
442
{
@@ -462,7 +456,7 @@ Discount::register('complex-discount', new CustomDiscount);
462
456
You may remove registered discounts using the `Discount` facade.
> The available aggregate functions: `count`, `min`, `max`, `sum`,`avg`.
597
+
> The available aggregate functions: `count`, `min`, `max`, `sum` and`avg`.
586
598
587
599
#### Grouping
588
600
@@ -602,6 +614,14 @@ $field->groupOptionsBy(static function (Model $model): string {
602
614
603
615
#### Subresources
604
616
617
+
When relation fields need more robust management you might convert it as a subresource. That means, instead of rendering a `<select>` on the resource form, the relation field gets its own CRUD interfaces as it would be a resource.
618
+
619
+
```php
620
+
$field->asSubResource();
621
+
```
622
+
623
+
Subresources appear on the parent resource models's show route.
624
+
605
625
### BelongsTo
606
626
607
627
The `BelongsTo` field is typically a handler for an existing `Illuminate\Database\Eloquent\Relations\BelongsTo` relation:
0 commit comments