I have a problem with inserting new record to data
There is a part of videocontroller:
$galleryName = Input::get('name'); $galleryID = Foto::create($galleryName);
here model:
class Foto extends Eloquent { public static function create($name) { return DB::table('galleries')->insert_get_id(array('name' => $name)); } }
Declaration of Foto::create()
should be compatible with
IlluminateDatabaseEloquentModel::create(array $attributes)
What I should fix?
Answer
Eloquent’s create
method takes an array. You cannot change that.
If you need this functionality, create a different method:
public static function createFromName($name) { return DB::table('galleries')->insertGetId(compact('name')); }
Then use that in your controller:
$galleryName = Input::get('name'); $galleryID = Foto::createFromName($galleryName);