I have a model Printer
, a model Category
, and a model for the relation between the two models CategoryPrinterRel
In the CategoryPrinterRel
model I need a unique validator between the $category_id
, and the client of the printer $printer->client_id
Up till now I have tried
public function rules()
{
[['category_id', $this->printer->client_id], 'unique', 'targetAttribute' => ['category_id']]
}
Is there any other way to do this though?
The problem with the method I'm using is that when the printer
object is empty, trying $this->printer->client_id
gives an error