مرتضی صبیحی
5 سال پیش توسط مرتضی صبیحی مطرح شد
1 پاسخ

create نشدن و ارور Array to string conversion

سلام
هرکاری میکنم با این ارور مواجه میشم

reportcontroller:

 public function topicReport(Request $request)
    {
        $topic = $request->route('topic');
        $this->handleReport('AppTopic', $topic, $request->report);
        return redirect(route('/'));
    }

    protected function handleReport($type, $id, $cause)
    {
        Report::create([
            'user_id' =>Auth()->id(),
            'cause' => $cause,
            'reportable_id' => $id,
            'reportable_type' => $type
        ]);
    }
 public function topics()
    {
//        return $this->morphedByMany(Topic::class,'reportable');
        return $this->morphTo();
    }
  public function reports()
    {
        return $this->morphToMany(Report::class,'reportable');
    }
    Route::post('report/{topic}','ReportController@topicReport')->name('topic-report');

متغیرا هم نوعشون رو چک کردم و مشکلی ندارن


ثبت پرسش جدید
مرتضی صبیحی
تخصص : Front-end developer
@mortezasabihi 5 سال پیش مطرح شد
1

تو مدل Report اسم جدول رو تو array گذاشته بودم ک باید اینطوری میذاشتم
protected $table = 'reportables';


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام