Я создаю систему управления активами и пытаюсь проверить, находится ли дата покупки в определенном финансовом году, чтобы я мог обновить столбец года в таблице активов. У меня есть этот код в моем контроллере:
Я создаю систему управления активами и пытаюсь проверить, находится ли дата покупки в определенном финансовом году, чтобы я мог обновить столбец года в таблице активов. У меня есть этот код в моем контроллере:
/** * Set to null if empty * @param $input */ public function setCategoryIdAttribute($input) { $this->attributes['category_id'] = $input ? $input : null; }
/** * Set to null if empty * @param $input */ public function setStatusIdAttribute($input) { $this->attributes['status_id'] = $input ? $input : null; }
/** * Set to null if empty * @param $input */ public function setLocationIdAttribute($input) { $this->attributes['location_id'] = $input ? $input : null; }
/** * Set to null if empty * @param $input */ public function setAssignedUserIdAttribute($input) { $this->attributes['assigned_user_id'] = $input ? $input : null; }
/** * Set attribute to date format * @param $input */ public function setPurchaseDateAttribute($input) { if ($input != null && $input != '') { $this->attributes['purchase_date'] = Carbon::createFromFormat(config('app.date_format'), $input)->format('Y-m-d'); } else { $this->attributes['purchase_date'] = null; } }
/** * Get attribute from date format * @param $input * * @return string */ public function getPurchaseDateAttribute($input) { $zeroDate = str_replace(['Y', 'm', 'd'], ['0000', '00', '00'], config('app.date_format'));
/** * Set to null if empty * @param $input */ public function setVendorIdAttribute($input) { $this->attributes['vendor_id'] = $input ? $input : null; }
/** * Set attribute to money format * @param $input */ public function setPurchasePriceAttribute($input) { $this->attributes['purchase_price'] = $input ? $input : null; }
/** * Set attribute to date format * @param $input */ public function setWarrantyAttribute($input) { if ($input != null && $input != '') { $this->attributes['warranty'] = Carbon::createFromFormat(config('app.date_format'), $input)->format('Y-m-d'); } else { $this->attributes['warranty'] = null; } }
/** * Get attribute from date format * @param $input * * @return string */ public function getWarrantyAttribute($input) { $zeroDate = str_replace(['Y', 'm', 'd'], ['0000', '00', '00'], config('app.date_format'));
/** * Set attribute to date format * @param $input */ public function setAssignedDateAttribute($input) { if ($input != null && $input != '') { $this->attributes['assigned_date'] = Carbon::createFromFormat(config('app.date_format'), $input)->format('Y-m-d'); } else { $this->attributes['assigned_date'] = null; } }
/** * Get attribute from date format * @param $input * * @return string */ public function getAssignedDateAttribute($input) { $zeroDate = str_replace(['Y', 'm', 'd'], ['0000', '00', '00'], config('app.date_format'));