Array to string conversion on one to one relation ship ERROR!

Posted 1 year ago by Stank0V01

Hello guys, i have a problem with one to one relationship! When i make it it give that error

 Array to string conversion in D:/laragon/www/ishop-bg/vendor/laravel/framework /src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on line 63

Here is my model

Product.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = [];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function sms() {
        return $this->hasOne(Sms::class,'sms_id');
    }
}
Sms.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Sms extends Model
{
    protected $table = ['sms'];
    public $timestamps = false;


    /**
     * @param $servID
     * @param $code
     * @return bool|\Illuminate\Http\RedirectResponse
     */
    public function mobio_check($servID, $code) {
        $api_uri = file("http://www.mobio.bg/code/checkcode.php?servID=$servID&code=$code");

        $reader = $api_uri;

        if($api_uri) {
            if(strstr("PAYBG=OK",$reader[0])) {
                return true;
            } else {
                return false;
            }
        } else {
            return redirect()->to('/');
        }

        return false;
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function product() {
        return $this->belongsTo(Product::class);
    }

}

Please sign in or create an account to participate in this conversation.