Tip tanımladığımda aşağıdaki hatayı alıyorum fakat tip tanımlamazsam ohh mübarek canıma değsin bak tip tip diye tutturursan olacağı budur diyor. Bu arada buna benzer farklı bir repostory daha var ondada tür tanımlı ama o çalışıyor. Hiç bir şey anlamadım.
exception: "TypeError"
file: "/Applications/XAMPP/xamppfiles/htdocs/PANEL/app/Http/Repositories/FileTypeRepostory.php"
line: 30
message: "Return value of App\Http\Repositories\FileTypeRepostory::filetype() must be an instance of App\Models\FileType, instance of Illuminate\Database\Eloquent\Collection returned"
FileTypeRepostoryInterface.php
<?php
namespace App\Http\Repositories;
use App\Models\FileType;
interface FileTypeRepostoryInterface
{
public function filetype() : FileType;
}
FileTypeRepostory.php
<?php
namespace App\Http\Repositories;
use App\Models\FileType;
use Illuminate\Support\Facades\Cache;
class FileTypeRepostory implements FileTypeRepostoryInterface
{
private $filetype;
public function __construct(FileType $filetype){
$this->filetype = $filetype;
}
public function filetype() : FileType{
if(!Cache::has('filetype')){
$filetype = Cache::rememberForever('filetype',function (){
return $this->filetype->with('filetypex')
->with('filetypey')
->get();
});
}else{
$filetype = Cache::get('filetype');
}
return $filetype;
}
}