/** * Create a new period * * @param array $data * An array as follows: array('month'=>$month, 'start_date'=>$startDate, 'end_date'=>$endDate, * 'is_closed'=>$isClosed, 'fiscal_year_id' => $fiscalYearId, 'organization_id'=>$organizationId * ); * * @return boolean */ public function create(array $data) { $Period = new Period(); $Period->setConnection($this->databaseConnectionName); $Period->fill($data)->save(); return $Period; }
/** * Get first period by organization and by fiscal year * * @param int $id Organization id * * @return Illuminate\Database\Eloquent\Collection */ public function firstPeriodbyOrganizationAndByFiscalYear($organizationId, $fiscalYearId) { $Period = $this->Period->selectRaw('id, end_date, min(month) as month')->where('organization_id', '=', $organizationId)->where('fiscal_year_id', '=', $fiscalYearId)->orderBy('month', 'asc')->groupBy(array('id', 'end_date'))->first(); return $Period; }