Laravel save one to many relationship

Sure you can do this:

$status = OrderStatus::where(['name'=>'sample_status'])->firstOrFail();
$order = new Order;
$order->status()->associate($status);
$order->save();

(status() is the belongsTo relation. You might need to adjust that name)


The correct way, to save a relationship for a new related model is as follows:

$status = OrderStatus::where(['name'=>'sample_status'])->firstOrFail();
$order = new Order;
$status->order()->save($order);

Documentation link : http://laravel.com/docs/4.2/eloquent#inserting-related-models