I am trying to pass the ids of the sectors in the create form to view it as a dropdown but got this error
in OrganisationsController.php line 52
at HandleExceptions->handleError('8', 'Trying to get property of non-object', 'C:\wamp\www\laravel\scoring-system\app\Http\Controllers\OrganisationsController.php', '52', array('request' => object(Request), 'organisations' => array('_token' => '110iXWQynwOotkUvHvNidphjzrnIcjNOsQCxr6eb', 'organisation' => 'fff', 'sector' => array('1'), 'isin' => 'fffffffffff'), 'sectorId' => array(array('1')))) in OrganisationsController.php line 52
The code :
namespace App\Http\Controllers;
use App\Organisation;
use App\Sector;
use Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class OrganisationsController extends Controller {
public function store(Request $request)
{
//
$organisations = Request::all();
Organisation::create($organisations );
$sectorId = array(Request::get('sector'));
$organisations->sectors->attach($sectorId);
flash()->success('New sector has been added.');
return redirect('organisations');
} }
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire