To resolve the issue with Larastan and the Eloquent relationship, you need to ensure that the docblock specifies both the related model and the declaring model for the BelongsTo relationship. The error you're encountering is because Larastan expects both template types to be specified.
Here's how you can correctly write the docblock for your programme method:
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use App\Models\Programme;
/**
* @return BelongsTo<Programme, DataPortal>
*/
public function programme(): BelongsTo
{
return $this->belongsTo(Programme::class);
}
This docblock specifies both the related model (Programme) and the declaring model (DataPortal), which should satisfy Larastan's requirements. Make sure that your use statements at the top of your file are correct, as shown in the example, to ensure that the classes are properly referenced.
If you continue to experience issues, double-check that your Larastan configuration is up-to-date and that there are no other conflicting settings or rules that might be causing the error.