Merge pull request #254 from nakazawakan/backend

updated_at順等
このコミットが含まれているのは:
chankan77 2022-01-08 17:08:55 +09:00 committed by GitHub
コミット bd6e9aee78
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 4AEE18F83AFDEB23
6個のファイルの変更17行の追加17行の削除

ファイルの表示

@ -274,7 +274,7 @@ class ChildrenController extends Controller {
return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']];
}
if (null === ($result = Child::where('first_name', 'LIKE', '%'.$r->keyword.'%')->orWhere('last_name', 'LIKE', '%'.$r->keyword.'%')->orderBy('created_at', 'desc')->get())) {
if (null === ($result = Child::where('first_name', 'LIKE', '%'.$r->keyword.'%')->orWhere('last_name', 'LIKE', '%'.$r->keyword.'%')->orderBy('updated_at', 'desc')->get())) {
// 親一覧の取得に失敗
return ['status_code' => 400];
}
@ -286,7 +286,7 @@ class ChildrenController extends Controller {
public function list () {
$child_select = ['id', 'first_name', 'last_name', 'tel', 'image'];
if (null === ($result = Child::select($child_select)->orderBy('created_at', 'desc')->get())) {
if (null === ($result = Child::select($child_select)->orderBy('updated_at', 'desc')->get())) {
// 親一覧の取得に失敗
return ['status_code' => 400];
}
@ -302,7 +302,7 @@ class ChildrenController extends Controller {
$result = [];
$child_select = ['id', 'image', 'first_name', 'last_name', 'company', 'tel', 'email'];
if (null === ($list = FatherRelation::select('child_id')->where('father_id', (int)$r->father_id)->orderBy('created_at', 'desc')->get())) {
if (null === ($list = FatherRelation::select('child_id')->where('father_id', (int)$r->father_id)->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
@ -319,7 +319,7 @@ class ChildrenController extends Controller {
$result = [];
$child_select = ['id', 'image', 'last_name', 'first_name'];
if (null === ($list = MeetingApprovals::select('child_id')->where('meeting_id', (int)$r->meeting_id)->orderBy('created_at', 'desc')->get())) {
if (null === ($list = MeetingApprovals::select('child_id')->where('meeting_id', (int)$r->meeting_id)->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
@ -341,7 +341,7 @@ class ChildrenController extends Controller {
$child_select = ['id', 'image', 'last_name', 'first_name', 'tel'];
$meeting_approvals_select = ['approval_at'];
if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$r->meeting_id)->whereNull('approval_at')->orderBy('created_at', 'desc')->get())) {
if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$r->meeting_id)->whereNull('approval_at')->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
@ -364,7 +364,7 @@ class ChildrenController extends Controller {
$child_select = ['id', 'image', 'last_name', 'first_name', 'tel'];
$meeting_approvals_select = ['approval_at'];
if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->orderBy('created_at', 'desc')->get())) {
if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}

ファイルの表示

@ -15,17 +15,18 @@ use App\Models\Meeting;
use App\Models\MeetingApprovals;
class FatherRelationsController extends Controller {
public function check (Request $r) {
$father_id = (int)$r->father_id;
if (FatherRelation::select('id')->where('father_id', $father_id)->count() == 0) {
public function checkNull () {
if (FatherRelation::select('id')->where('father_id', (int)session()->get('fathers')['id'])->count() == 0) {
return ['status_code' => 401, 'error_messages' => ['契約上限数に達した為、メンバー追加できません。']];
}
$father = Father::select('relation_limit')->where('id', $father_id)->first();
return ['status_code' => 200];
}
if ($father->relation_limit <= FatherRelation::select('id')->where('father_id', $father_id)->count()) {
public function check () {
$father = Father::select('relation_limit')->where('id', (int)session()->get('fathers')['id'])->first();
if ($father->relation_limit <= FatherRelation::select('id')->where('father_id', (int)session()->get('fathers')['id'])->count()) {
return ['status_code' => 401, 'error_messages' => ['契約上限数に達した為、メンバー追加できません。']];
}

ファイルの表示

@ -447,7 +447,7 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)session()->get('fathers')['id'])->where('is_favorite', 0)->orderBy('created_at', 'desc')->get())) {
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)session()->get('fathers')['id'])->where('is_favorite', 0)->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}

ファイルの表示

@ -8,5 +8,5 @@ use Illuminate\Database\Eloquent\Model;
class TelActivation extends Model
{
use HasFactory;
protected $fillable = ['type', 'child_id', 'father_id', 'tel', 'token', 'ttl'];
protected $fillable = ['type', 'child_id', 'tel', 'token', 'ttl'];
}

ファイルの表示

@ -18,8 +18,6 @@ class CreateTelActivationsTable extends Migration
$table->unsignedTinyInteger('type');
$table->unsignedBigInteger('child_id')->nullable();
$table->foreign('child_id')->references('id')->on('children')->onDelete('cascade');
$table->unsignedBigInteger('father_id')->nullable();
$table->foreign('father_id')->references('id')->on('fathers')->onDelete('cascade');
$table->string('tel', 11)->unique();
$table->string('token', 100)->unique();
$table->dateTime('ttl');

ファイルの表示

@ -143,6 +143,7 @@ Route::group(['prefix' => 'fathers'], function () {
// FatherRelationsController
Route::group(['prefix' => 'relations'], function () {
Route::get('/checkNull', '\App\Http\Controllers\Api\FatherRelationsController@checkNull');
Route::get('/check', '\App\Http\Controllers\Api\FatherRelationsController@check');
Route::post('/register', '\App\Http\Controllers\Api\FatherRelationsController@register');
Route::put('/updateHireDate/{child_id}', '\App\Http\Controllers\Api\FatherRelationsController@updateHireDate');