Support the ongoing development of Laravel.io →
Input Eloquent Forms

Hi,

i am new to php and laravel, but I really love the laravel framework.

Maybe my problem is really easy to solve, but I can't find a solution.

I have a two tables one for my users and one for my tickets. The relationship between these two tables/model is working correctly. I have create tickets with tinker and could associate it to different users without any problem.

I have a form to create a new ticket and associate it to a user with the help of a dropdwon list.

Here is my form (sorry for the different syntax but i want it to work and then i have to cleanup the code)

@extends('layout')

@section('content') <div class="page-header"> <h1>Create Ticket <small>and someday finish it!</small></h1> </div>

<form action="{{ action('TicketsController@handleCreate') }}" method="post" role="form">
    <div class="form-group">
        <label for="title">Title</label>
        <input type="text" class="form-control" name="title" />
    </div>
    <div class="form-group">
        <label for="description">Description</label>
        <input type="text" class="form-control" name="description" />
    </div>
    {{ Form::select('username', $user_select, Input::old('username')) }}

    <input type="submit" value="Create" class="btn btn-primary" />
    <a href="{{ action('TicketsController@index') }}" class="btn btn-danger">Cancel</a>
</form>

@stop

The dropdown list is working correctly and it shows my users.

Here is the part of my TicketsController where my problem is or at least i think so :-)

public function handleCreate()
{
    // Handle create form submission.
    $ticket = new Ticket;
    $ticket->title = Input::get('title');
    $ticket->description = Input::get('description');
    // Associate the ticket with the selected user.
    $ticket->user->associate($user) = Input::get('user');
    $ticket->save();

    return Redirect::action('TicketsController@index');
}

When I try to create a new ticket with this form a get the following error.

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_COMPILE_ERROR) Can't use method return value in write context

Can you help me?

Last updated 3 years ago.
0

No idea?

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

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.

© 2025 Laravel.io - All rights reserved.