66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\BBProjectIndicators;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
use Hekmatinasser\Verta\Verta;
|
|
|
|
class BB_Project_Indicator extends Controller
|
|
{
|
|
public function index(){
|
|
// $allrecords = BBProjectIndicators::groupBy('project_unique_id')->select('*')->get();
|
|
// $allrecords = \DB::table('b_b_project_indicators')
|
|
// ->select('*')
|
|
// ->groupBy('project_unique_id')
|
|
// ->get();
|
|
$allrecords = \DB::select('SELECT
|
|
*,CAST(ROUND(AVG(project_progress),2) AS DEC(10,2))
|
|
avg_project_progress
|
|
FROM
|
|
b_b_project_indicators
|
|
GROUP BY project_unique_id');
|
|
return response()->json([
|
|
'status' => 'succeed',
|
|
'message' => '',
|
|
'data' => $allrecords
|
|
], 200);
|
|
}
|
|
public function index_by_unique_id(Request $request){
|
|
$datas = BBProjectIndicators::where('project_unique_id', $request->project_unique_id)->get();
|
|
return response()->json([
|
|
'status' => 'succeed',
|
|
'message' => '',
|
|
'data' => $datas
|
|
], 200);
|
|
}
|
|
// public function update(Request $request)
|
|
// {
|
|
// //rz::::maxter
|
|
// $request->validate([
|
|
// 'id' => 'required|integer|exists:b_b_jaheshes,id'
|
|
// ]);
|
|
// $id = $request->id;
|
|
// $validrecs = array_filter($request->all());
|
|
// // $id = $request->id;
|
|
// $uprecords = BBJahesh::find($id);
|
|
|
|
// // $uprecords->fill($validrecs);
|
|
// $uprecords->project_count_done = $request->project_count_done;
|
|
// $uprecords->last_updated_at_fa = verta(Carbon::now())->format('Y/n/j');
|
|
// $uprecords->project_progress = ($uprecords->project_count_done/(float)$uprecords->project_count_all)*100;
|
|
// $uprecords->save();
|
|
|
|
|
|
// return response()->json([
|
|
// 'status' => 'succeed',
|
|
// 'message' => '',
|
|
// 'data' => 1
|
|
// ], 200);
|
|
|
|
// }
|
|
|
|
}
|