You should do what's right for your code, even if it inconveniences you within your editor. Perhaps try a new editor.
Exposing public properties of your model is not a good idea and should be avoided at all cost. Using public properties basically make guarded and fillable properties useless.
If you feel like you're repeating a lot that you need a help of your editor..you might have code smell. How do you use your models?
Don't misunderstand me. It's very convenient if your IDE/editor can do the job for you, but I usually find myself using the models a few places.
By "makes your coding easier" I believe you are referring to autocomplete.
This can work perfectly fine by using docblocks.
/**
* @property int $id
* @property Carbon/Carbon $date
* @property string $title
* @property string $description
*/
class Property extends Eloquent
{
public $id;
public $date;
public $title;
public $description;
.
.
.
}
And your IDE will pick up on that (assuming you have a decent IDE). Ofcourse maintaining the docblocks can be quite cumbersome but it doesn't have to be. There is an automated package that can do this for you.
@hailwood's solution is the right one, thanks!
Using the public properties on Eloquent, as I already mentioned, is not the solution, as it makes NULL all the values. And it's not an IDE problem. Using DocBlocks is what I was looking for.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community