add geolocation for datacite metadata anf for backend
This commit is contained in:
parent
e7d8dc21a0
commit
ba38fc1ed1
16 changed files with 3833 additions and 6047 deletions
|
@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Response;
|
|||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\DatasetReference;
|
||||
use App\Models\GeolocationBox;
|
||||
|
||||
class IndexController extends Controller
|
||||
{
|
||||
|
@ -236,6 +237,22 @@ class IndexController extends Controller
|
|||
'title_main.language' => 'required',
|
||||
'abstract_main.value' => 'required|min:4',
|
||||
'abstract_main.language' => 'required',
|
||||
'geolocation.xmin' => [
|
||||
'nullable',
|
||||
'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/'
|
||||
],
|
||||
'geolocation.ymin' => [
|
||||
'nullable',
|
||||
'regex:/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?)$/'
|
||||
],
|
||||
'geolocation.xmax' => [
|
||||
'nullable',
|
||||
'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/'
|
||||
],
|
||||
'geolocation.ymax' => [
|
||||
'nullable',
|
||||
'regex:/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?)$/'
|
||||
],
|
||||
];
|
||||
if (null != $request->file('files')) {
|
||||
$files = count($request->file('files')) - 1;
|
||||
|
@ -344,6 +361,15 @@ class IndexController extends Controller
|
|||
$dataset->references()->save($dataReference);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['geolocation'])) {
|
||||
$formGeolocation = $request->input('geolocation');
|
||||
if ($formGeolocation['xmin'] !== '' && $formGeolocation['ymin'] !== '' &&
|
||||
$formGeolocation['xmax'] !== '' && $formGeolocation['ymax'] !== '') {
|
||||
$geolocation = new GeolocationBox($formGeolocation);
|
||||
$dataset->geolocation()->save($geolocation);
|
||||
}
|
||||
}
|
||||
|
||||
// $error = 'Always throw this error';
|
||||
// throw new \Exception($error);
|
||||
|
|
|
@ -53,11 +53,11 @@ class Dataset extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the user that owns the phone.
|
||||
* Get the geolocation that owns the dataset.
|
||||
*/
|
||||
public function geolocation()
|
||||
{
|
||||
return $this->belongsTo(GeolocationBox::class, 'dataset_id', 'id');
|
||||
return $this->hasOne(GeolocationBox::class, 'dataset_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,7 @@ class GeolocationBox extends Model
|
|||
'xmin' => 'float',
|
||||
'xmax' => 'float',
|
||||
'ymin' => 'float',
|
||||
'ymax' => 'float'
|
||||
'ymax' => 'float',
|
||||
];
|
||||
|
||||
public function dataset()
|
||||
|
|
|
@ -39,7 +39,7 @@ class Person extends Model
|
|||
*/
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return $this->first_name . " " . $this->last_name;
|
||||
return $this->first_name . " " . $this->last_name . " " . $this->date_of_birth;
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue