Added short name to location
Change-Id: Ie0e92de646df1274d0d2c30717af79a9ee00c3ce Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
6c311dbb2d
commit
6cb29f05fd
app
Http/Controllers/Apis/Protected/Summit/Factories
ModelSerializers/Locations
Models/Foundation/Summit
database/migrations/model
@ -28,6 +28,7 @@ final class SummitAbstractLocationValidationRulesFactory
|
||||
if($update){
|
||||
return [
|
||||
'name' => 'sometimes|string|max:255',
|
||||
'short_name' => 'sometimes|string|max:255',
|
||||
'description' => 'sometimes|string',
|
||||
'order' => 'sometimes|integer|min:1'
|
||||
];
|
||||
@ -35,6 +36,7 @@ final class SummitAbstractLocationValidationRulesFactory
|
||||
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'short_name' => 'sometimes|string|max:255',
|
||||
'description' => 'sometimes|string',
|
||||
];
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ class SummitAbstractLocationSerializer extends SilverStripeSerializer
|
||||
protected static $array_mappings = array
|
||||
(
|
||||
'Name' => 'name:json_string',
|
||||
'ShortName' => 'short_name:json_string',
|
||||
'Description' => 'description:json_string',
|
||||
'LocationType' => 'location_type',
|
||||
'Order' => 'order:json_int',
|
||||
|
@ -72,6 +72,9 @@ final class SummitLocationFactory
|
||||
if(isset($data['name']))
|
||||
$location->setName(trim($data['name']));
|
||||
|
||||
if(isset($data['short_name']))
|
||||
$location->setShortName(trim($data['short_name']));
|
||||
|
||||
if(isset($data['description']))
|
||||
$location->setDescription(trim($data['description']));
|
||||
|
||||
|
@ -65,6 +65,12 @@ class SummitAbstractLocation extends SilverstripeBaseModel implements IOrderable
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ShortName", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $short_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Description", type="string")
|
||||
* @var string
|
||||
@ -286,4 +292,22 @@ class SummitAbstractLocation extends SilverstripeBaseModel implements IOrderable
|
||||
public function getBannerByClass($class_name){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getShortName(): ?string
|
||||
{
|
||||
return $this->short_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $short_name
|
||||
*/
|
||||
public function setShortName(string $short_name): void
|
||||
{
|
||||
$this->short_name = $short_name;
|
||||
}
|
||||
|
||||
|
||||
}
|
47
database/migrations/model/Version20210416191958.php
Normal file
47
database/migrations/model/Version20210416191958.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php namespace Database\Migrations\Model;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||
use LaravelDoctrine\Migrations\Schema\Builder;
|
||||
use LaravelDoctrine\Migrations\Schema\Table;
|
||||
|
||||
/**
|
||||
* Class Version20210416191958
|
||||
* @package Database\Migrations\Model
|
||||
*/
|
||||
class Version20210416191958 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema):void
|
||||
{
|
||||
$builder = new Builder($schema);
|
||||
|
||||
if($schema->hasTable("SummitAbstractLocation")) {
|
||||
$builder->table('SummitAbstractLocation', function (Table $table) {
|
||||
$table->string("ShortName", 255)->setDefault(null)->setNotnull(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema):void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user