58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php namespace TPS\Birzha\Components;
|
|
|
|
use Cms\Classes\ComponentBase;
|
|
use TPS\Birzha\Models\Category;
|
|
use TPS\Birzha\Models\Product;
|
|
use TPS\Birzha\Models\City;
|
|
use Session;
|
|
use DB;
|
|
|
|
class CategoryProfile extends ComponentBase
|
|
{
|
|
|
|
public $category;
|
|
public $users;
|
|
|
|
public function componentDetails() {
|
|
return [
|
|
'name' => 'Category profile',
|
|
'description' => 'Category profile page component',
|
|
];
|
|
}
|
|
|
|
|
|
|
|
public function defineProperties()
|
|
{
|
|
return [
|
|
'categorySlug' => [
|
|
'title' => 'Select by category :slug',
|
|
'description' => 'Select by category',
|
|
'type' => 'string',
|
|
'default' => ''
|
|
],
|
|
];
|
|
}
|
|
|
|
|
|
|
|
public function onRun() {
|
|
$this->users = $this->getCategoryUsers();
|
|
$this->category = $this->getCategory();
|
|
}
|
|
|
|
protected function getCategory(){
|
|
$cSlug = $this->property('categorySlug');
|
|
$category = Category::transWhere('slug', $cSlug, Session::get('rainlab.translate.locale'))->with('users')->first();
|
|
return $category;
|
|
}
|
|
|
|
protected function getCategoryUsers(){
|
|
$cSlug = $this->property('categorySlug');
|
|
$category = Category::where('slug', $cSlug)->first();
|
|
$users = $category->users()->get();
|
|
// dd($users);
|
|
return $users;
|
|
}
|
|
}
|