relation_limitの追加
このコミットが含まれているのは:
コミット
fddcab100f
|
@ -9,6 +9,7 @@ use Illuminate\Support\Facades\DB;
|
|||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Models\Child;
|
||||
use App\Models\Father;
|
||||
use App\Models\FatherRelation;
|
||||
use App\Models\Meeting;
|
||||
use App\Models\MeetingApprovals;
|
||||
|
@ -31,6 +32,14 @@ class FatherRelationsController extends Controller {
|
|||
return ['status_code' => 400, 'error_messages' => ['子の追加に失敗しました。']];
|
||||
}
|
||||
|
||||
if (null === ($father = Father::select('relation_limit')->where('id', (int)$r->father_id)->first())) {
|
||||
return ['status_code' => 400, 'error_messages' => ['子の追加に失敗しました。']];
|
||||
}
|
||||
|
||||
if ($father->relation_limit <= FatherRelation::select('id')->where('father_id', (int)$r->father_id)->count()) {
|
||||
return ['status_code' => 401, 'error_messages' => ['契約上限数に達した為(改行)メンバー追加できません。']];
|
||||
}
|
||||
|
||||
$create = [
|
||||
'father_id' => $r->father_id,
|
||||
'child_id' => $child->id,
|
||||
|
@ -63,7 +72,7 @@ class FatherRelationsController extends Controller {
|
|||
return ['status_code' => 400, 'error_messages' => ['子の追加に失敗しました。']];
|
||||
}
|
||||
|
||||
return ['status_code' => 200, 'success_messages' => ['子の追加に成功しました。'], 'params' => ['child_id' => $child->id]];
|
||||
return ['status_code' => 200, 'success_messages' => ['子の追加に成功しました。'], 'params' => ['child_id' => $child->id, 'limit' => $father->relation_limit]];
|
||||
}
|
||||
|
||||
public function updateHireDate (Request $r, $child_id) {
|
||||
|
|
|
@ -85,7 +85,8 @@ class FathersController extends Controller {
|
|||
|
||||
public function registerTemporary (Request $r) {
|
||||
$validate = Validator::make($r->all(), [
|
||||
'email' => 'required|unique:fathers|unique:email_activations|max:255|email'
|
||||
'email' => 'required|unique:fathers|unique:email_activations|max:255|email',
|
||||
'relation_limit' => 'required|numeric',
|
||||
]);
|
||||
|
||||
if ($validate->fails()) {
|
||||
|
@ -110,6 +111,7 @@ class FathersController extends Controller {
|
|||
|
||||
$create = [
|
||||
'email' => $r->email,
|
||||
'relation_limit' => (int)$r->relation_limit,
|
||||
'token' => $token,
|
||||
'ttl' => date('Y-m-d H:i:s', strtotime("8 hour")),
|
||||
];
|
||||
|
@ -289,6 +291,9 @@ class FathersController extends Controller {
|
|||
|
||||
public function detail ($father_id) {
|
||||
$father_select = ['image', 'email', 'tel', 'profile', 'company'];
|
||||
if (request()->route()->action['as'] == 'pda') {
|
||||
$father_select[] = 'relation_limit as limit';
|
||||
}
|
||||
|
||||
// 親画面から他の親としてアクセスすれば、404となります。
|
||||
$err = 'アクセスできません。';
|
||||
|
|
|
@ -8,6 +8,6 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
|||
class Father extends Authenticatable
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = ['email', 'password', 'company', 'image', 'profile', 'tel'];
|
||||
protected $fillable = ['email', 'password', 'company', 'image', 'profile', 'tel', 'relation_limit'];
|
||||
protected $hidden = ['password'];
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ class FatherFactory extends Factory
|
|||
'image' => '/assets/default/avatar.jpg',
|
||||
'profile' => $this->faker->realText(49),
|
||||
'tel' => $tel[rand(0, 2)],
|
||||
'relation_limit' => rand(1,10),
|
||||
'created_at' => $this->faker->dateTime,
|
||||
'updated_at' => $this->faker->dateTime,
|
||||
];
|
||||
|
|
|
@ -21,6 +21,7 @@ class CreateFathersTable extends Migration
|
|||
$table->string('image', 100)->nullable();
|
||||
$table->string('profile', 1000)->nullable();
|
||||
$table->string('tel', 11)->unique();
|
||||
$table->unsignedInteger('relation_limit');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -173,6 +173,7 @@ return [
|
|||
'message' => 'お問合せ内容',
|
||||
'last_name' => '姓',
|
||||
'first_name' => '名',
|
||||
'relation_limit' => '子とのリレーション制限',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
新しいイシューから参照