g_sto/plugins/romanah/gokbakja/models/Production.php

66 lines
1.6 KiB
PHP
Raw Normal View History

2023-09-14 20:16:27 +00:00
<?php namespace Romanah\Gokbakja\Models;
use Model;
2023-09-18 20:22:50 +00:00
use Carbon\Carbon;
use DB;
2023-09-14 20:16:27 +00:00
/**
* Model
*/
class Production extends Model
{
use \October\Rain\Database\Traits\Validation;
2023-09-16 06:18:02 +00:00
2023-09-14 20:16:27 +00:00
use \October\Rain\Database\Traits\SoftDelete;
protected $dates = ['deleted_at'];
2023-09-16 13:00:30 +00:00
public $hasMany = [
2023-09-16 06:18:02 +00:00
'pivot_production' => [
'Romanah\Gokbakja\Models\PivotProduction',
2023-10-19 21:07:33 +00:00
'key' => 'production_id',
'delete' => true
],
'pivot_production_calculation' => [
'Romanah\Gokbakja\Models\ProductionCalculate',
'key' => 'production_id',
'delete' => true
2023-09-16 06:18:02 +00:00
]
];
2023-09-17 19:12:00 +00:00
2023-09-30 21:55:49 +00:00
public $belongsTo = [
'excruiter' => [
'Romanah\Gokbakja\Models\Excruiter',
'key' => 'excruiter_id'
2023-10-02 22:15:33 +00:00
],
'shift' => [
'Romanah\Gokbakja\Models\Shift',
'key' => 'shift_id'
2023-09-30 21:55:49 +00:00
]
];
2023-09-18 20:22:50 +00:00
public function scopeGetByGroup($query)
{
return $query->select('id', 'created_at', 'all_amount', 'note', DB::raw('count(id) as `data`'), DB::raw("DATE_FORMAT(created_at, '%d-%m-%Y') new_date"), DB::raw('YEAR(created_at) year, MONTH(created_at) month, DAY(created_at) day'))
->orderBy('id', 'DESC')
->groupby('year','month', 'day');
}
2023-09-17 19:12:00 +00:00
2023-09-14 20:16:27 +00:00
/**
* @var string The database table used by the model.
*/
public $table = 'romanah_gokbakja_production';
/**
* @var array Validation rules
*/
public $rules = [
2023-10-02 22:15:33 +00:00
'all_amount' => 'required',
];
public $customMessages = [
'all_amount.required' => 'Jemi diýen hökman doldurylmalydyr.',
2023-09-14 20:16:27 +00:00
];
}