You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
671 B
30 lines
671 B
<?php
|
|
|
|
namespace App\Http\Forms\SchoolForms;
|
|
|
|
use App\StudentParent;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class AddParentForm extends FormRequest
|
|
{
|
|
public function rules()
|
|
{
|
|
return [
|
|
'mobile' => 'required|regex:/^(\+\d{1,3}[- ]?)?\d{10}$/',
|
|
//student
|
|
];
|
|
}
|
|
|
|
public function run()
|
|
{
|
|
$parent = StudentParent::where(['mobile' => $this->mobile])->first();
|
|
if ($parent) {
|
|
return $parent;
|
|
} else {
|
|
$parent = StudentParent::create(['mobile' => $this->mobile]);
|
|
$parent->save();
|
|
//sync student
|
|
return $parent;
|
|
}
|
|
}
|
|
}
|
|
|