Ejemplo n.º 1
0
 public function run()
 {
     $this->truncateTable('property_types');
     $propertyTypes = config('setup.properties.types');
     foreach ($propertyTypes as $id => $propertyType) {
         PropertyType::create(['id' => $propertyType['id'], 'name' => $propertyType['name'], 'element' => $propertyType['element'], 'type' => $propertyType['type'], 'is_void' => $propertyType['is_void']]);
     }
     Factory::times(10)->create(PropertyType::class);
 }
Ejemplo n.º 2
0
 /** @test */
 public function it_updates_a_propertyType()
 {
     $data = ['name' => 'Test77', 'element' => 'text77'];
     $response = $this->call('PUT', 'api/property-types/1', [], [], [], $this->headers, json_encode($data));
     $content = json_decode($response->getContent());
     $updatedPropertyType = \SevenShores\Kraken\PropertyType::find(1);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals($data['name'], $content->name);
     $this->assertEquals($data['name'], $updatedPropertyType->name);
     $this->assertEquals($data['element'], $content->element);
     $this->assertEquals($data['element'], $updatedPropertyType->element);
     //$this->assertEquals(4, $updatedPropertyType->properties->where('id', 4)->first()->id);
     //$this->assertNull($updatedPropertyType->properties->where('id', 1)->first());
 }
Ejemplo n.º 3
0
 /**
  * @param int $propertyTypeId
  * @param string $name
  * @param null $element
  * @param null $type
  * @param null $is_void
  * @param array $relations
  * @return mixed
  */
 public function update($propertyTypeId, $name = null, $element = null, $type = null, $is_void = null, array $relations = [])
 {
     $propertyType = PropertyType::findOrFail($propertyTypeId);
     $data = [];
     if (!is_null($name)) {
         $data['name'] = $name;
     }
     if (!is_null($element)) {
         $data['element'] = $element;
     }
     if (!is_null($type)) {
         $data['type'] = $type;
     }
     if (!is_null($is_void)) {
         $data['is_void'] = $is_void;
     }
     $propertyType->update($data);
     if (!empty($relations)) {
         $propertyType = $this->handleRelations($propertyType, $relations);
     }
     $propertyType->save();
     return $propertyType;
 }
Ejemplo n.º 4
0
<?php

use SevenShores\Kraken;
$factory(Kraken\Property::class, function ($faker) {
    $name = $faker->name;
    $key = str_slug($name, '_');
    $propertyTypeIds = Kraken\PropertyType::lists('id');
    return ['name' => $name, 'key' => $key, 'label' => $faker->sentence(2), 'required' => $faker->boolean(25), 'type_id' => $faker->randomElement($propertyTypeIds)];
});