Reputation: 272
I generate one simple insert,update and delete application. when I run my application, I get error. my application files are below....
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);
}
}
I run this code. Error will be display like this....
FatalErrorException in ContactusModel.php line 24:
syntax error, unexpected 'insertall' (T_STRING), expecting variable (T_VARIABLE)
Upvotes: 2
Views: 51
Reputation: 2731
public static insertall($data)
{
return DB::table('users')->insert($data);
}
You haven't added the word function
public static function
late night programming :P ?
Upvotes: 1