Laravel Argument 1传递给了

I'm trying to do my coding, but I ran into this issue. Thing is, I did it exactly the same like my first code, but it's working there.

ErrorException in CoinflipController.php line 115: Argument 1 passed to App\Http\Controllers\CoinflipController::CoinflipToJson() must be an instance of App\Models\Game\Coinflip\Coinflip, instance of Illuminate\Database\Eloquent\Collection given, called in C:\xampp\htdocs\site\app\Http\Controllers\CoinflipController.php on line 104 and defined

Coinflip File

<?php

namespace App\Models\Game\Coinflip;

use Illuminate\Database\Eloquent\Model;

class Coinflip extends Model {
    const STATUS_ACTIVE     = 0;
    const STATUS_ROLLING    = 1;
    const STATUS_ENDED      = 2;

    protected $table = 'coinflip';    
    protected $fillable = [
        'status',
        'winner_steam_id',
        'winner_probability',
        'winner_value',
        'hash',
        'ticket',
        'seed',
        'player1',
        'player1_side',
    ];
    protected $dates = [ 'draw_at' ];
    protected $casts = [
        'winner_steam_id' => 'string',
        'winner_probability' => 'float',
        'winner_value' => 'float',
        'ticket' => 'double'
    ];

    public function entry(){
        return $this->hasMany( 'App\Models\Game\Coinflip\CoinflipEntry', 'coinflip_id' );
    }

    public function winner(){
        return $this->hasOne( 'App\User', 'steam_id', 'winner_steam_id' );
    }

    public function getCommissionValue(){
        $val = 0;
        foreach( $this->entry as $entry ){
            foreach( $entry->item as $item ){
                if ( $item->status == CoinflipEntryItem::STATUS_COMMISIONED )
                    $val += (float)$item->price;
            }
        }
        return $val;
    }
}

CoinflipToJson Function (From 1st line is the Error)

 public function CoinflipToJson( Coinflip $coinflip, $showExtra = false ){
        $canDeposit1 = $coinflip->value * 0.10 + $coinflip->value;
        $canDeposit2 = $coinflip->value - $coinflip->value * 0.10;
        $data = [
            'id' => $coinflip->id,
            'hash' => $coinflip->hash,
            'gameValue' => $coinflip->value,
            'canDeposit1' => $canDeposit1,
            'canDeposit2' => $canDeposit2,
            'skinValue' => 0,
            'skinCount' => 0,
            'timeStart' => $coinflip->created_at->getTimestamp(),
            'timeEnd' => $coinflip->draw_at ? $jackpot->draw_at->getTimestamp() : 0,
            'timeEndIn' => $coinflip->draw_at ? $jackpot->draw_at->getTimestamp() - time() : -1,
            'timeMax' => Setting::of('JackpotExtendTime', 15)->getValue(),
            'entry' => []
        ];

        if ( $showExtra ){
            $data['winningPercentage'] = $coinflip->ticket;
            $data['winnerId'] = $coinflip->winner_steam_id;
            $data['secret'] = $coinflip->seed;
        }

        foreach( $coinflip->entry as $entry ){
            $entryData = $this->entryToJson( $entry );
            $data['entry'][] = $entryData;
            $data['skinValue'] += $entryData['skinValue'];
            $data['skinCount'] += $entryData['skinCount'];
        }
        return $data;
    }

Code where I am calling it (Line 5)

public function current( Request $request ){
    $coinflip = $this->getCurrentGame();
    if($coinflip){
        $data = [
            'current' => $this->CoinflipToJson($coinflip)
        ];
        return response()->json($data);
    } else return response()->json(['error' => 'No Games']);
}

getCurrent Game Function

public function getCurrentGame(){
    $coinflip = Coinflip::where('status', Coinflip::STATUS_ACTIVE)->get();
    return $coinflip;
}

In your getCurrentGame() method, the get() method always returns a Collection, even if there was only one record. If you query will only ever return one record, you can just change get() to first(), and it will return the record instance, instead of a Collection.