You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.
I try to override the base controllers postNew() method in my custom Controller like assigning many to many relationship but I get error
Call to undefined method Illuminate\Database\Query\Builder::sync()
the overrided looks like
public function postNew() {
$record = $this->model->getNew(Input::all());
$record->campaign_title= Input::get('campaign_title');
$valid = $this->validateWithInput === true ? $record->isValid(Input::all()) : $record->isValid();
if (!$valid)
return Redirect::to('admin/' . $this->new_url)->with('errors', $record->getErrors())->withInput();
// Run the hydration method that populates anything else that is required / runs any other
// model interactions and save it.
$record->save();
$record->networks()->sync([3,4]);
// Redirect that shit man! You did good! Validated and saved, man mum would be proud!
return Redirect::to($this->object_url)->with('success', new MessageBag(array('Item Created')));
}
In my repositiry I have a networks method()
public function networks()
{
return $this->belongsToMany('Network', 'campaign_networks_relationhsips');
}
So how to extend the base eloquent to can hydrate tables?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I try to override the base controllers postNew() method in my custom Controller like assigning many to many relationship but I get error
Call to undefined method Illuminate\Database\Query\Builder::sync()
the overrided looks like
In my repositiry I have a networks method()
So how to extend the base eloquent to can hydrate tables?
The text was updated successfully, but these errors were encountered: