employeehours
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 21/12/2017
|
||||
* Time: 18:05
|
||||
*/
|
||||
|
||||
|
||||
class Employeehour extends BaseModel {
|
||||
|
||||
protected $table = "employeehours";
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo( 'User', 'employee_id' );
|
||||
}
|
||||
|
||||
public function hourtype()
|
||||
{
|
||||
return $this->belongsTo( 'Hourtype' );
|
||||
}
|
||||
|
||||
public static function getEmployeehours( $month, $year )
|
||||
{
|
||||
$employeehours = Employeehour::whereRaw( "MONTH(hourdate) ={$month} AND YEAR(hourdate) = {$year}" )
|
||||
->with( [
|
||||
'user' => function ( $q ) {
|
||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||
}] )
|
||||
->with( 'hourtype' )
|
||||
->get();
|
||||
|
||||
return $employeehours;
|
||||
}
|
||||
|
||||
public static function saveEmployeehour( $employeehourID, $data )
|
||||
{
|
||||
if ( $employeehourID == 0 )
|
||||
{
|
||||
$employeehour = Employeehour::create( $data );
|
||||
|
||||
$employeehourID = $employeehour->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
Employeehour::whereId( $employeehourID )->update( $data );
|
||||
}
|
||||
|
||||
return $employeehourID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 21/12/2017
|
||||
* Time: 18:05
|
||||
*/
|
||||
|
||||
|
||||
class Hourtype extends BaseModel {
|
||||
|
||||
protected $table = "hourtypes";
|
||||
|
||||
public function employeehours()
|
||||
{
|
||||
return $this->hasMany( 'Employeehour' );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user