2021-09-30 13:26:29 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Http\Request;
|
2021-10-15 10:37:47 +09:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2021-09-30 13:26:29 +09:00
|
|
|
|
2021-10-01 12:44:45 +09:00
|
|
|
use App\Models\FatherRelation;
|
|
|
|
|
2021-09-30 13:26:29 +09:00
|
|
|
class FatherRelationsController extends Controller {
|
2021-10-01 14:18:52 +09:00
|
|
|
public function updateHireDate (Request $r, $child_id) {
|
|
|
|
if (!isset($child_id) || !isset($r->father_id) || !isset($r->hire_at)) {
|
2021-10-06 14:50:13 +09:00
|
|
|
return ['status_code' => 400, 'success_messages' => ['子の入社日の更新に失敗しました。']];
|
2021-10-01 14:18:52 +09:00
|
|
|
}
|
2021-10-01 12:44:45 +09:00
|
|
|
|
2021-10-01 14:18:52 +09:00
|
|
|
$update = ['hire_at' => date('Y-m-d H:i:s', strtotime($r->hire_at))];
|
2021-10-01 12:44:45 +09:00
|
|
|
|
2021-10-06 14:50:13 +09:00
|
|
|
try {
|
|
|
|
FatherRelation::where('father_id', $r->father_id)->where('child_id', $child_id)->update($update);
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
// 失敗
|
|
|
|
Log::critical($e->getMessage());
|
|
|
|
return ['status_code' => 400, 'success_messages' => ['子の入社日の更新に失敗しました。']];
|
2021-10-01 14:18:52 +09:00
|
|
|
}
|
2021-09-30 13:26:29 +09:00
|
|
|
|
2021-10-06 14:50:13 +09:00
|
|
|
return ['status_code' => 200, 'success_messages' => ['子の入社日の更新に成功しました。']];
|
2021-09-30 13:26:29 +09:00
|
|
|
}
|
|
|
|
}
|