Laravel error page when creating CRUD application

- 1 answer

Ad

Following code in create.blade.php in the view->tasks->create.blade.php

@extends('layouts.master')

@section('content')

<h1>Add a New Task</h1>
<p class="lead">Add to your task list below.</p>
<hr>
{!! Form::open(['route' => 'tasks.store']) !!}

<div class="form-group">
{!! Form::label('title', 'Title:', ['class' => 'control-label']) !!}
{!! Form::text('title', null, ['class' => 'form-control']) !!}
</div>

<div class="form-group">
{!! Form::label('description', 'Description:', ['class' => 'control-label']) !!}
{!! Form::textarea('description', null, ['class' => 'form-control']) !!}
</div>

{!! Form::submit('Create New Task', ['class' => 'btn btn-primary']) !!}

{!! Form::close() !!}
@stop

A task controller I created for the controller sections

Controller->TasksController 

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class TasksController extends Controller {

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

}

inside our config/app.php We add one service provider

'Illuminate\Html\HtmlServiceProvider',

aliases something like this

'Form'      => 'Illuminate\Html\FormFacade',
'Html'      => 'Illuminate\Html\HtmlFacade',

In a Vender->laravel->framework->src->Illuminate->Html->HtmlServiceProvider.php

Change the method name to bindingshare to the singleton.

IN The Route file Following code written.

Route::resource('tasks', 'TasksController');

Following Snapshot error display.

Laravel error

Ad

Answer

Ad

Model Task is in other namespace, so you should after:

use App\Http\Controllers\Controller;

add something like this:

use App\Models\Task;

or

use Task;

to use Task from valid namespace

Ad
source: stackoverflow.com
Ad