Answer the question
In order to leave comments, you need to log in
Where can I find good tutorials on drawing in photoshop cc?
Recommend drawing lessons in
Where can I find good drawing lessons in photoshop cc?. I’m not a beginner myself, it turned out so strange, I can do something in between, but I can’t just draw a house or a vector circle. Before that, he somehow studied on his own, without lessons and other benefits.
Answer the question
In order to leave comments, you need to log in
What version of Yii? If the second, then it's probably easier to do so.
<?php
public static function getFullInfo($id)
{
$driverCar = DriverCar::findOne([
'mifar_card_id' => $id
]);
if (empty( $driverCar ) ) return false;
//Если тут одна сущность то делаем так
// Но у объекта дожны быть методы getCar и getDriver в которых используется $this->hasOne()
$car = $driverCar->сar;
$driver = $driverCar->driver;
$object = array();
if ($driverCar->сar->use_group_tariff && $driverCar->сar->group_tariff_id)
{
$groupTariff = GroupTariff::findOne([
'id' => $driverCar->сar->group_tariff_id
]);
$object = [
'town' => $groupTariff->town,
'town_center' => $groupTariff->town_center,
'km_price' => $groupTariff->km_price,
]
}
else
{
$driverTariff = DriverTariff::findOne([
'driver_id' => $driverCar->driver->id
]);
$object = [
'town' => $driverTariff->town,
'town_center' => $driverTariff->town_center,
'km_price' => $driverTariff->km_price,
]
}
$object = array(
'company' => $driverCar->сar->getCarBrand();
'model' => $driverCar->сar->model;
'color' => $driverCar->сar->color;
'object' = $driverCar->сar->number;
'full_name' = $driverCar->driver->getFullName();
'serial_number' = $driverCar->driver->serial_number;
);
return (object)$object;
}
//Или так от структуры зависит и логики
class Driver extends ActiveRecord{
public function getCar()
{
return $this->hasOne(Car::className(),['mifar_card_id' => 'id' ])
->viaTable('{{%driverCar}}',['driver_id' => 'id']);
}
public function getTariff(){
return $this->hasOne(DriverTariff::className(),['driver_id' => 'id'])
}
}
class Car extends ActiveRecord{
public function getTariff(){
return $this->hasOne(GroupTariff::className(), ['id' => 'driver_id'])
}
}
interface IGetTariff{
public function getTown();
public function getTownCenter();
public function getKmPrice();
}
class GroupTariff extends ActiveRecord implements GetTariff{}
class DriverTariff extends ActiveRecord implements GetTariff{}
class FullDriverCarInfo extends Model{
public static function getFullInfo( $driverId ){
$driver = Driver::findOne('id'=>$driverId);
if( empty($driver) ) return;
/** @var $tariff IGetTariff */
if( $driver->сar->use_group_tariff && $driver->сar->group_tariff_id ){
$tariff = $driver->car->getTariff();
}else{
$tariff = $driver->getTariff();
}
$result = array(
'town' => $tariff->getTown(),
'town_center' => $tariff->getTownCenter(),
'km_price' => $tariff->getKmPrice(),
'company' => $driver->сar->getCarBrand();
'model' => $driver->сar->model;
'color' => $driver->сar->color;
'object' = $driver->сar->number;
'full_name' = $driver->getFullName();
'serial_number' = $driver->serial_number;
);
//Так если это отдельная модель
$this->setAttributes( $result );
return $this;
//Или
return (object)$result;
}
}
namespace app;
use yii\base\Object;
use yii\db\ActiveRecord;
/**
* @property integer $mifar_card_id
* @property integer $car_id
* @property integer $driver_id
* @property Car $car
* @property Driver $driver
* @property TariffInterface $tariff
*/
class DriverCar extends ActiveRecord
{
public function getCar()
{
return $this->hasOne(Car::class, ['id' => 'car_id']);
}
public function getDriver()
{
return $this->hasOne(Driver::class, ['id' => 'driver_id']);
}
public function getTariff()
{
return $this->car->tariff ?: $this->driver->tariff;
}
}
interface chargeableInterface
{
public function getTariff();
}
/**
* @property integer $group_tariff_id
* @property GroupTariff $tariff
* @property string $model
* @property string $color
* @property string $number
*/
class Car extends ActiveRecord implements chargeableInterface
{
public function getTariff()
{
return $this->hasOne(GroupTariff::class, ['id' => 'group_tariff_id']);
}
public function getCarBrand()
{
}
}
/**
* @property DriverTariff $tariff
* @property string $serial_number
*/
class Driver extends ActiveRecord implements chargeableInterface
{
public function getTariff()
{
return $this->hasOne(DriverTariff::class, ['driver_id' => 'id']);
}
public function getFullName()
{
}
}
interface TariffInterface
{
public function getTown();
public function getTownCenter();
public function getKmPrice();
}
/**
* @property integer $driver_id
*/
class DriverTariff extends ActiveRecord implements TariffInterface
{
public function getTown()
{
}
public function getTownCenter()
{
}
public function getKmPrice()
{
}
}
class GroupTariff extends ActiveRecord implements TariffInterface
{
public function getTown()
{
}
public function getTownCenter()
{
}
public function getKmPrice()
{
}
}
class DriverCarInfo extends Object
{
/**
* @var DriverCar|null
*/
private $_model;
public function setModel(DriverCar $model)
{
$this->_model = $model;
}
public function getTown()
{
return $this->_model->tariff->getTown();
}
public function getTownCenter()
{
return $this->_model->tariff->getTownCenter();
}
public function getKmPrice()
{
return $this->_model->tariff->getKmPrice();
}
public function getCompany()
{
return $this->_model->car->getCarBrand();
}
public function getModel()
{
return $this->_model->car->model;
}
public function getColor()
{
return $this->_model->car->color;
}
public function getNumber()
{
return $this->_model->car->number;
}
public function getFullName()
{
return $this->_model->driver->getFullName();
}
public function getSerialNumber()
{
return $this->_model->driver->serial_number;
}
}
function getFullInfo($id)
{
$model = DriverCar::findOne(['mifar_card_id' => $id]);
return $model === null ? null : new DriverCarInfo(['model' => $model]);
}
I advise my channel :) https://www.youtube.com/user/DigitalDesignGoodLes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question