Added short name to location

Change-Id: Ie0e92de646df1274d0d2c30717af79a9ee00c3ce
Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
smarcet 2021-04-16 16:25:54 -03:00
parent 6c311dbb2d
commit 6cb29f05fd
5 changed files with 77 additions and 0 deletions

View File

@ -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',
];
}

View File

@ -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',

View File

@ -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']));

View File

@ -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;
}
}

View 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
{
}
}