| Current Path : /var/www/html/dyna-crm/models/ |
| Current File : /var/www/html/dyna-crm/models/Product.php |
<?php
namespace app\models;
use Yii;
use app\models\Vendor;
use app\models\Company;
/**
* This is the model class for table "product".
*
* @property int $id
* @property string $uuid
* @property string $name
* @property string $uom
* @property int $parent_id
* @property string $sku
* @property string $cost
* @property string $retail_price
* @property string $selling_price
* @property int $status
* @property string $photo
* @property int $brand_id
* @property int $cat_id
* @property string $keywords
* @property string $descr
* @property string $benefits
* @property int $vendor_id
* @property string $weblink
* @property string $created_dt
* @property int $created_by
* @property string $updated_dt
* @property int $updated_by
*/
class Product extends \yii\db\ActiveRecord {
public $file;
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'product';
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['uuid', 'name', 'uom', 'selling_price', 'status', 'brand_id', 'cat_id', 'vendor_id', 'com_id'], 'required'],
[['parent_id', 'status', 'brand_id', 'cat_id', 'vendor_id', 'created_by', 'updated_by'], 'integer'],
[['keywords', 'descr', 'benefits'], 'string'],
[['created_dt', 'updated_dt', 'alt_name', 'publish_level', 'retail_price', 'cost', 'stock_alert'], 'safe'],
[['name', 'sku', 'photo', 'weblink'], 'string', 'max' => 255],
[['uom', 'cost', 'retail_price', 'selling_price'], 'string', 'max' => 20],
[['uuid'], 'unique'],
[['file'], 'file'],
[['parent_id'], 'default', 'value' => '0'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'id' => 'ID',
'uuid' => 'Uuid',
'name' => 'Product Name',
'uom' => 'Product UOM',
'parent_id' => 'Parent Product',
'sku' => 'Product SKU',
'cost' => 'AXIS Cost',
'retail_price' => 'Retail Price',
'selling_price' => "Member's Price",
'status' => 'Status',
'photo' => 'Photo',
'brand_id' => 'Brand',
'cat_id' => 'Category',
'keywords' => 'Keywords Related',
'descr' => 'Product Description',
'benefits' => 'Product Benefits',
'vendor_id' => 'Vendor',
'weblink' => 'Weblink',
'created_dt' => 'Created Dt',
'created_by' => 'Created By',
'updated_dt' => 'Updated Dt',
'updated_by' => 'Updated By',
'file' => 'Product Image',
'com_id' => 'Company',
'alt_name' => 'Product Alternate Name',
'publish_level' => 'Publish Level'
];
}
public function getname($id) {
$output = '';
if (($model = static::findOne($id)) !== null) {
$output = $model->name;
}
return $output;
}
public function getuom($id) {
$output = '';
if (($model = static::findOne($id)) !== null) {
$output = $model->uom;
}
return $output;
}
public function getsku($id) {
$output = '';
if (($model = static::findOne($id)) !== null) {
$output = $model->sku;
}
return $output;
}
public function getprice($id) {
$output = '';
if (($model = static::findOne($id)) !== null) {
$output = $model->selling_price;
}
return $output;
}
public function getvendordetails($id) {
$output = '';
if (($model1 = static::findOne($id)) !== null) {
if (($model = Vendor::findOne($model1->vendor_id)) !== null) {
$output = $model->id . '<->' . $model->name . '<->' .
$model->address1 . '<->' .
$model->address2 . '<->' .
$model->postcode . '<->' .
$model->city . '<->' .
$model->state . '<->' .
$model->country . '<->' .
$model->contact_name . '<->' .
$model->contact_no;
}
}
return $output;
}
public function getvendor($id) {
$output = '';
if (($model = static::findOne($id)) !== null) {
$output = $model->vendor_id;
}
return $output;
}
public function getcompany($id) {
$output = '';
if (($model = static::findOne($id)) !== null) {
$output = $model->com_id;
}
return $output;
}
public function getbrand($id) {
$output = '';
if (($model = static::findOne($id)) !== null) {
$output = $model->brand_id;
}
return $output;
}
}