i have the following code
Model
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Match extends Model
{
protected $fillable = array(['first_team',
'second_team',
'tournament_id',
'stadium_id',
'date',
'start_date',
'status',
'end_date',
'spectators',
'season',
'round',
'match_abandoned',
'match_drawn',
'start_time']);
Controller
public function store(Request $request)
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.thesportsdb.com/api/v1/json/1/searchevents.php?e=Arsenal_vs_Chelsea",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
$data = json_decode($response,1);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$match = new Match;
foreach ($data['events'] as $event){
$match->id = $event['idEvent'];
$match->first_team = $event['strHomeTeam'];
$match->second_team = $event['strAwayTeam'];
$match->tournament_id = $event['idLeague'];
$match->date = $event['dateEvent'];
$match->start_date = $event['strDate'];
$match->spectators = $event['intSpectators'];
$match->seasion = $event['strSeason'];
$match->round = $event['intRound'];
$match->start_time = $event['strTime'];
$match->save();
}
}
}
migration
public function up()
{
Schema::create('matches', function (Blueprint $table) {
$table->increments('id');
$table->string("first_team");
$table->string("second_team");
$table->unsignedInteger('tournament_id');
$table->foreign('tournament_id')->references('id')->on('tournaments');
$table->unsignedInteger('stadium_id');
$table->foreign('stadium_id')->references('id')->on('stadiums');
$table->date("date");
$table->date("start_date");
$table->string("status");
$table->date("end_date");
$table->string("spectators");
$table->string("season");
$table->integer("round");
$table->integer("match_abandoned");
$table->integer("match_drawn");
$table->time("start_time");
$table->timestamps();
});
}
i am getting error this while inserting record into db
Declaration of App\Models\Match::update(App\Models\Request $request, $id) should be compatible with Illuminate\Database\Eloquent\Model::update(array $attributes = Array, array $options = Array)