Skip to content

Instantly share code, notes, and snippets.

@FunctionDJ
Created September 9, 2021 14:53
Show Gist options
  • Save FunctionDJ/b76fcd4692a9837765bffb500eeac973 to your computer and use it in GitHub Desktop.
Save FunctionDJ/b76fcd4692a9837765bffb500eeac973 to your computer and use it in GitHub Desktop.
phpstan/larastan issue
<?php
namespace Database\Seeders;
use App\Models\ItemProfile;
class Foo
{
public function run(): void
{
$profile = ItemProfile::firstOrFail();
echo $profile->warehouse; // Access to an undefined property (...)
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ItemProfile extends Model
{
use HasFactory;
protected $casts = [
"has_batch_number" => "boolean",
"is_receivable" => "boolean",
"is_hazardous" => "boolean",
"has_host_notification" => "boolean",
"is_deleted" => "boolean"
];
public function item()
{
return $this->hasOne(Item::class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment