PaulCatalin97
4 months ago

No Message error

Posted 4 months ago by PaulCatalin97

I really dont understand why, my route is post, method for form is post, why im getting this error ?

this is my route

Route::post('/adaugajob', 'Auth\[email protected]')->name('adaugajob');

This is my form

 <form action="{{route('adaugajob')}}" method="POST" enctype="multipart/form-data">
                            @csrf
                            <div class="box-body">
                                <div class="form-group">
                                    <label >Titlu Job:</label>
                                    <input type="text" class="form-control" id="titlu" name="titlu"/>
                                </div>
                                <div class="form-group">
                                    <label >Descriere:</label>
                                    <input type="text" class="form-control" id="descriere" name="descriere"/>
                                </div>
                                <div class="form-group">
                                    <label >Salariu Estimativ:</label>
                                    <input type="text" class="form-control" id="salariu_estimativ" name="salariu_estimativ" />
                                </div>
                                <div class="form-group">
                                    <label >Oras:</label>
                                    <input type="text" class="form-control" id="oras" name="oras" />
                                </div>
                                <div class="form-group">
                                    <label >Activ:</label>
                                    <input type="hidden" class="form-control" id="activ" name="activ" value="0">
                                </div>
                                <div class="dropdown-field">
                                    <select data-placeholder="Selecteaza Specializare" class="chosen" id="multiselect" name="skills[]" multiple="multiple">
                                        @foreach($skills as $skill)
                                            <option value="{{$skill->id}}" >{{strtoupper($skill->name)}}</option>
                                        @endforeach
                                    </select>
                                    <div class="box-footer">
                                        <button type="submit" class="btn btn-primary">Adauga</button>
                                    </div>
                                </div>
                            </div>
                        </form>

And This is my Controller for this form

class AdaugaJobController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index()
    {
        $skills = SkillsEmployee::all();
        return view('adaugajob', compact('skills'));
    }

    protected function validator(array $data)
    {

        if ($data) {
            return Validator::make($data, [
                'titlu' => ['required', 'string', 'max:255'],
                'descriere' => ['required', 'string', 'max:255'],
                'salariu_estimativ' => ['required', 'string', 'max:255'],
                'oras' => ['required', ''],
            ]);
        }
    }

    protected function create( \Illuminate\Http\Request $request)
    {
        $data = $request->all();
        if ($data) {
            Joburi::create([
                'titlu' => $data['titlu'],
                'descriere' => $data['descriere'],
                'salariu_estimativ' => $data['salariu_estimativ'],
                'oras' => $data['oras'],
            ]);
            foreach ($data['skills'] as $skill) {
                Joburi::create([
                    'id_skill' => $skill,
                ]);
            }
        }

    }
}

I want to insert the data from the form in a model. the model has the names of the fields in the form. nothing seems wrong. when it used to work it didn`t insert nothing, but now i get this NO MESSAGE error

Please sign in or create an account to participate in this conversation.