public function getLeavesByName($name, $type, $hasParticipant = false) { if ($type != 'village' || $type != 'village_tract') { if ($hasParticipant) { return Location::whereName($name)->whereType($type)->first()->leaves()->has('participants'); } else { return Location::whereName($name)->whereType($type)->first()->leaves(); } } throw new GeneralException('Check location type.'); }
public static function setData(CellCollection $v) { $product = Product::whereCode($v->product_code)->first(); $location = Location::whereName($v->location)->first(); return ['product_id' => $product->id, 'product_code' => $product->code, 'mix_no' => $product->mix_no, 'product_description' => $product->description, 'location_id' => $location->id, 'location_name' => $location->name, 'qty' => $v->qty, 'remark' => $v->remark]; }