error in save data

Posted 5 months ago by mDelshad

i'm using repository pattern but in save data getting this error:

Function () does not exist

route:

        Route::post('profile/document', [DocumentController::class,'sendDoc'])->name('profile.docs');

this is Document Repository :


namespace App\Repositories\system\Document;

use App\Models\Document\Document;
use App\Repositories\BaseRepository;

class DocumentRepository extends BaseRepository
{
    /**
     * @return string
     */
    public function model()
    {
        return Document::class;
    }



        /**
     * @param array $data
     *
     * @return \Illuminate\Database\Eloquent\Model|mixed
     * @throws \Exception
     * @throws \Throwable
     */
    public function sendDoc(array $data)
    {
        foreach ($data as $key => $value) {
            $input[$key] = $value->storeAs(
                'documents/'.CurrentUser()->path  , str_random(80).'.'. $value->getClientOriginalExtension()
            );
        }


        return DB::transaction(function () use ($input) {
            $document = parent::create([
                'id_card'        => $input['National_Card'],
                'bank_card'         => $input['Bank_card'],
                'selfie'             => $input['Selfie'],
                'verify'            => '1',
                ]);
                return  $document;
        });
      
    }


}

and this in controller

<?php

namespace App\Http\Controllers\frontend\user;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Repositories\system\Document\DocumentRepository;
use App\Http\Requests\system\DocumentRequest;
class DocumentController extends Controller
{

    /**
     * @var documentRepository
     */
    protected $documentRepository;

    /**
     * DocumentController constructor.
     *
     * @param DocumentRepository $DocumentRepository
     */
    public function __construct(DocumentRepository $documentRepository)
    {
        $this->documentRepository = $documentRepository;
    }

    public function sendDoc(DocumentRequest $request)
    {

      $document =  $this->documentRepository->sendDoc(
            $request->only('National_Card','Bank_card','Selfie')
        );
        return redirect()->route('frontend.user.account')->withFlashSuccess("Message"); 
    }
}

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