52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php namespace TPS\Birzha\Components;
|
|
|
|
use Cms\Classes\ComponentBase;
|
|
use TPS\Birzha\Models\Product;
|
|
use Input;
|
|
use Flash;
|
|
|
|
class MyOrders extends ComponentBase
|
|
{
|
|
/**
|
|
* @var Collection A collection of user's posts
|
|
*/
|
|
public $orders;
|
|
|
|
|
|
|
|
public function componentDetails()
|
|
{
|
|
return [
|
|
'name' => 'MyOrders List',
|
|
'description' => 'List of my orders'
|
|
];
|
|
}
|
|
|
|
public function defineProperties()
|
|
{
|
|
return [
|
|
'perPage' => [
|
|
'title' => 'Number of offers',
|
|
'description' => 'How many offers do you want to display',
|
|
'default' => 12,
|
|
'validationPattern' => '^[0-9]+$',
|
|
'validationMessage' => 'Only numbers allowed'
|
|
],
|
|
];
|
|
}
|
|
|
|
|
|
public function onRun() {
|
|
$this->orders = $this->loadOrders();
|
|
}
|
|
|
|
protected function loadOrders() {
|
|
$perPage = $this->property('perPage');
|
|
return \Auth::user()->orders()
|
|
->orderBy('updated_at', 'desc')
|
|
->paginate($perPage);
|
|
}
|
|
|
|
|
|
}
|