allow specific fields to be null
This commit is contained in:
parent
fa32498fda
commit
ab6f702569
|
@ -16,8 +16,8 @@ use Illuminate\Support\Carbon;
|
|||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @method static BrandFactory factory($count = null, $state = [])
|
||||
* @property string|null $description
|
||||
* @method static \Database\Factories\BrandFactory factory($count = null, $state = [])
|
||||
* @method static Builder|Brand newModelQuery()
|
||||
* @method static Builder|Brand newQuery()
|
||||
* @method static Builder|Brand query()
|
||||
|
@ -73,19 +73,19 @@ class Brand extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription(): string
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @param string|null $description
|
||||
*
|
||||
* @return Brand
|
||||
*/
|
||||
public function setDescription(string $description): Brand
|
||||
public function setDescription(?string $description): Brand
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ use Illuminate\Support\Carbon;
|
|||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property float $price
|
||||
* @method static FuelTypeFactory factory($count = null, $state = [])
|
||||
* @property string|null $description
|
||||
* @property float|null $price
|
||||
* @method static \Database\Factories\FuelTypeFactory factory($count = null, $state = [])
|
||||
* @method static Builder|FuelType newModelQuery()
|
||||
* @method static Builder|FuelType newQuery()
|
||||
* @method static Builder|FuelType query()
|
||||
|
@ -75,19 +75,19 @@ class FuelType extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription(): string
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @param string|null $description
|
||||
*
|
||||
* @return FuelType
|
||||
*/
|
||||
public function setDescription(string $description): FuelType
|
||||
public function setDescription(?string $description): FuelType
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
|
@ -95,19 +95,19 @@ class FuelType extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return float|null
|
||||
*/
|
||||
public function getPrice(): float
|
||||
public function getPrice(): ?float
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $price
|
||||
* @param float|null $price
|
||||
*
|
||||
* @return FuelType
|
||||
*/
|
||||
public function setPrice(float $price): FuelType
|
||||
public function setPrice(?float $price): FuelType
|
||||
{
|
||||
$this->price = $price;
|
||||
|
||||
|
|
|
@ -17,17 +17,18 @@ use Schema;
|
|||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string $name
|
||||
* @property string $image_path
|
||||
* @property string|null $image_path
|
||||
* @property int $storage
|
||||
* @property int $fuel_volume
|
||||
* @property int $seats
|
||||
* @property float $price
|
||||
* @property float $top_speed
|
||||
* @property float|null $price
|
||||
* @property float|null $top_speed
|
||||
* @property int $vehicle_class_id
|
||||
* @property int $fuel_type_id
|
||||
* @property int $brand_id
|
||||
* @property int $vendor_id
|
||||
* @method static VehicleFactory factory($count = null, $state = [])
|
||||
* @method static \Database\Factories\VehicleFactory factory($count = null, $state = [])
|
||||
* @method static Builder|Vehicle filter(array $filters)
|
||||
* @method static Builder|Vehicle newModelQuery()
|
||||
* @method static Builder|Vehicle newQuery()
|
||||
* @method static Builder|Vehicle query()
|
||||
|
@ -36,6 +37,7 @@ use Schema;
|
|||
* @method static Builder|Vehicle whereFuelTypeId($value)
|
||||
* @method static Builder|Vehicle whereFuelVolume($value)
|
||||
* @method static Builder|Vehicle whereId($value)
|
||||
* @method static Builder|Vehicle whereImagePath($value)
|
||||
* @method static Builder|Vehicle whereName($value)
|
||||
* @method static Builder|Vehicle wherePrice($value)
|
||||
* @method static Builder|Vehicle whereSeats($value)
|
||||
|
@ -90,6 +92,26 @@ class Vehicle extends Model
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getImagePath(): ?string
|
||||
{
|
||||
return $this->image_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $image_path
|
||||
*
|
||||
* @return Vehicle
|
||||
*/
|
||||
public function setImagePath(?string $image_path): Vehicle
|
||||
{
|
||||
$this->image_path = $image_path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
@ -151,19 +173,19 @@ class Vehicle extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return float|null
|
||||
*/
|
||||
public function getPrice(): float
|
||||
public function getPrice(): ?float
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $price
|
||||
* @param float|null $price
|
||||
*
|
||||
* @return Vehicle
|
||||
*/
|
||||
public function setPrice(float $price): Vehicle
|
||||
public function setPrice(?float $price): Vehicle
|
||||
{
|
||||
$this->price = $price;
|
||||
|
||||
|
@ -171,19 +193,19 @@ class Vehicle extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return float|null
|
||||
*/
|
||||
public function getTopSpeed(): float
|
||||
public function getTopSpeed(): ?float
|
||||
{
|
||||
return $this->top_speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $top_speed
|
||||
* @param float|null $top_speed
|
||||
*
|
||||
* @return Vehicle
|
||||
*/
|
||||
public function setTopSpeed(float $top_speed): Vehicle
|
||||
public function setTopSpeed(?float $top_speed): Vehicle
|
||||
{
|
||||
$this->top_speed = $top_speed;
|
||||
|
||||
|
@ -270,26 +292,6 @@ class Vehicle extends Model
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getImagePath(): string
|
||||
{
|
||||
return $this->image_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $image_path
|
||||
*
|
||||
* @return Vehicle
|
||||
*/
|
||||
public function setImagePath(string $image_path): Vehicle
|
||||
{
|
||||
$this->image_path = $image_path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function scopeFilter(
|
||||
$query,
|
||||
array $filters
|
||||
|
|
|
@ -16,8 +16,8 @@ use Illuminate\Support\Carbon;
|
|||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @method static VehicleClassFactory factory($count = null, $state = [])
|
||||
* @property string|null $description
|
||||
* @method static \Database\Factories\VehicleClassFactory factory($count = null, $state = [])
|
||||
* @method static Builder|VehicleClass newModelQuery()
|
||||
* @method static Builder|VehicleClass newQuery()
|
||||
* @method static Builder|VehicleClass query()
|
||||
|
@ -73,19 +73,19 @@ class VehicleClass extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription(): string
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @param string|null $description
|
||||
*
|
||||
* @return VehicleClass
|
||||
*/
|
||||
public function setDescription(string $description): VehicleClass
|
||||
public function setDescription(?string $description): VehicleClass
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ use Illuminate\Support\Carbon;
|
|||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property string $position
|
||||
* @property float $x
|
||||
* @property float $y
|
||||
* @method static VendorFactory factory($count = null, $state = [])
|
||||
* @property string|null $description
|
||||
* @property string|null $position
|
||||
* @property float|null $x
|
||||
* @property float|null $y
|
||||
* @method static \Database\Factories\VendorFactory factory($count = null, $state = [])
|
||||
* @method static Builder|Vendor newModelQuery()
|
||||
* @method static Builder|Vendor newQuery()
|
||||
* @method static Builder|Vendor query()
|
||||
|
@ -79,19 +79,19 @@ class Vendor extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription(): string
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @param string|null $description
|
||||
*
|
||||
* @return Vendor
|
||||
*/
|
||||
public function setDescription(string $description): Vendor
|
||||
public function setDescription(?string $description): Vendor
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
|
@ -99,19 +99,19 @@ class Vendor extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPosition(): string
|
||||
public function getPosition(): ?string
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $position
|
||||
* @param string|null $position
|
||||
*
|
||||
* @return Vendor
|
||||
*/
|
||||
public function setPosition(string $position): Vendor
|
||||
public function setPosition(?string $position): Vendor
|
||||
{
|
||||
$this->position = $position;
|
||||
|
||||
|
@ -119,19 +119,19 @@ class Vendor extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return float|null
|
||||
*/
|
||||
public function getX(): float
|
||||
public function getX(): ?float
|
||||
{
|
||||
return $this->x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $x
|
||||
* @param float|null $x
|
||||
*
|
||||
* @return Vendor
|
||||
*/
|
||||
public function setX(float $x): Vendor
|
||||
public function setX(?float $x): Vendor
|
||||
{
|
||||
$this->x = $x;
|
||||
|
||||
|
@ -139,19 +139,19 @@ class Vendor extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return float|null
|
||||
*/
|
||||
public function getY(): float
|
||||
public function getY(): ?float
|
||||
{
|
||||
return $this->y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $y
|
||||
* @param float|null $y
|
||||
*
|
||||
* @return Vendor
|
||||
*/
|
||||
public function setY(float $y): Vendor
|
||||
public function setY(?float $y): Vendor
|
||||
{
|
||||
$this->y = $y;
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('brands', function (Blueprint $table) {
|
||||
$table->string('name')->unique()->change();
|
||||
$table->text('description')->nullable(true)->change();
|
||||
});
|
||||
|
||||
Schema::table('fuel_types', function (Blueprint $table) {
|
||||
$table->string('name')->unique()->change();
|
||||
$table->text('description')->nullable(true)->change();
|
||||
$table->double('price')->nullable(true)->change();
|
||||
});
|
||||
|
||||
Schema::table('vehicle_classes', function (Blueprint $table) {
|
||||
$table->string('name')->unique()->change();
|
||||
$table->text('description')->nullable(true)->change();
|
||||
});
|
||||
|
||||
Schema::table('vendors', function (Blueprint $table) {
|
||||
$table->string('name')->unique()->change();
|
||||
$table->text('description')->nullable(true)->change();
|
||||
$table->string('position')->nullable(true)->change();
|
||||
$table->double('x')->nullable(true)->change();
|
||||
$table->double('y')->nullable(true)->change();
|
||||
});
|
||||
|
||||
Schema::table('vehicles', function (Blueprint $table) {
|
||||
$table->string('name')->unique()->change();
|
||||
$table->string('image_path')->nullable(true)->change();
|
||||
$table->double('price')->nullable(true)->change();
|
||||
$table->double('top_speed')->nullable(true)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue