lundi 19 juin 2017

Laravel 5.2 Error why simply trying to display a view

I created a view which allows the user to create a theme/post. The link to that view is in my navbar. But the problem is When I try to click the link (display the view) I get redirected to the home page without any errors whatsoever.

In the link of the navbar, i put <li><a href=""> which simply activates the route with the name "createtheme". This route is as followed: Route::get('/theme/create', 'ThemesController@create')->name('createtheme');. So this activated the create method in the ThemesController.php. Which is:

public function create()
{
    return view('themes.create');
}

So if I read this correctly, This is supposed to give me the right view, right? And it doesn't give me any errors so I don't know where to look.

This is the view I'm trying to display:

@extends('layouts.default')

@section('content')
<div class="container main-content">
    <div class="row first-row">
        <div class="col s12">
            <div class="card">
                <div class="card-content clearfix">
                    <span class="card-title">New theme</span>
                </div>
            </div>
            <div class="card">
                <div class="card-content">
                    <form method="POST" action="">
                        
                        <input type="hidden" name="user_id" value="">
                        <div class="row">
                            <div class="input-field col s6 has-error form-group">
                                <input id="title" class="form-control" type="text" name="title" placeholder="Title of topic">
                                <label for="title" class="active">Title of theme</label><span>Titel is mandatory!</span>
                            </div>
                            <div class="file-field input-field col s6 form-group">
                                <div class="btn cyan darken-1 disabled"><span>Attachment</span>
                                    <input id="attachement" type="file" name="attachment" class="disabled">
                                </div>
                                <div class="file-path-wrapper form-group">
                                    <input type="text" placeholder="geen" class="file-path validate form-control">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col s12 form-group">
                                <textarea id="message-body" class="form-control" name="body"></textarea>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col s6">
                                Hier komen opties om het onderwerp te sluiten of
                                aan te geven dat het opgelost is, alleen bij bewerken
                            </div>
                            <div class="col s6">
                                <a href="" class="btn right cyan darken-1" type="submit">Save</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('scripts')
<script type="text/javascript" src="">
</script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="">
</script>
@endsection

And here are the routes that are related to this problem.

Route::get('/theme/create', 'ThemesController@create')->name('createtheme');
Route::post('/theme/create', 'ThemesController@store');

And of course the Store method:

public function store(Request $request)
{
    Theme::create($request->input()); //Dit doet hetzelfde als bovenstaande

    return redirect('/');
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire