Laravel5中的FatalError

时间:2015-05-22 16:17:47

标签: php laravel-5

我生成一个简单的插入,更新和删除应用程序。当我运行我的应用程序时,我收到错误。我的申请文件在下面......

Route.php

Route::post('insertdata','ContactusController@store');

ContactusController.php

use App\ContactusModel;

use Illuminate\Support\Facades\Input;

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

use Illuminate\Http\Request;

/* namespaces */
use App\User;
use Symfony\Component\HttpKernel\Client;
use Illuminate\Support\Facades\Redirect;

class ContactusController extends Controller {

    public function __construct()
    {

    }

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

    public function store()
    {
        $input = Input::all();

        ContactusModel::insertall($input);
        return view('contact.contact');
    }    
}

ContactusModel.php

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;


class ContactusModel extends Model {

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'contactus_models';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['fullname','mobileno', 'email', 'message'];


    public static insertall($data)
    {
        return DB::table('users')->insert($data);
    }

}

我运行此代码。错误将显示如下....

FatalErrorException in ContactusModel.php line 24:
syntax error, unexpected 'insertall' (T_STRING), expecting variable (T_VARIABLE)

1 个答案:

答案 0 :(得分:1)

   public static insertall($data)
    {
        return DB::table('users')->insert($data);
    }

您尚未添加单词function

public static function

深夜编程:P?