Skip to content

Instantly share code, notes, and snippets.

@Spriz
Created January 21, 2019 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Spriz/9b76bcfc07785d578e3c2b8df2581753 to your computer and use it in GitHub Desktop.
Save Spriz/9b76bcfc07785d578e3c2b8df2581753 to your computer and use it in GitHub Desktop.
<?php
/**
* @return \Cake\Http\Response|null
*/
public function add()
{
$vendorId = $this->request->getData('vendor_id');
if (empty($vendorId)) {
$vendorId = $this->request->getQuery('vendor_id');
}
$vendor = $this->VendorProductPriceFiles->CompaniesVendors->Vendors->get($vendorId);
$companiesVendor = $this->CompaniesVendors->findOrCreate([
'CompaniesVendors.company_id' => $this->Auth->user('company_id'),
'CompaniesVendors.vendor_id' => $vendor->id,
]);
if ($this->request->is(['POST'])) {
$companiesVendor = $this->CompaniesVendors->patchEntity($companiesVendor,[
'delivery_price' => $this->request->getData('delivery_price'),
'free_delivery_price' => $this->request->getData('free_delivery_price'),
]);
$vendorProductPriceFile = $this->VendorProductPriceFiles->newEntity([
'vendor_id' => $this->request->getData('vendor_id'),
'file' => $this->request->getData('file'),
'companies_vendor' => $companiesVendor,
]);
if ($this->VendorProductPriceFiles->save($vendorProductPriceFile)) {
//
}
//
}
$this->set(compact('vendor'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment