Support the ongoing development of Laravel.io →
Input Eloquent Validation
Last updated 2 years ago.
0

If you have rules setup on each models it should work ok.

Alternatively, you could ditch ardent and use a Validation Service Class instead, to validate your input in one place.

Last updated 2 years ago.
0

I have rules set up for each model but it is not saving the form data. How should my form be set up for the additional models to pass through correctly?

For example, here is my admin notes form field:

{{ Form::textarea('adminNotes[notes]', $user->adminNotes->notes, array('class' => 'form-control', 'id' => 'notes', 'rows' => 3)) }}

My user model:

public function adminNotes()
{
    return $this->hasOne('AdminNote');
}

My admin notes model:

use LaravelBook\Ardent\Ardent;

class AdminNote extends Ardent {

	protected $fillable = array('user_id', 'notes');

	public static $rules = array(
		'notes' => 'required'
	);

    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id');
    }
}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

robdiablo robdiablo Joined 4 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.