• 24-07-2022, 16:41:12
    #1
    Merhabalar, PHP tarafında yardıma ihtiyacımız var. Bilgi sahibi kişiler konuya dahil olurlar ise seviniriz.

    Kod;

    Alıntı
    <?php

    namespace AppServices;

    use AppGame;
    use AppLocation;
    use AppNode;
    use AppProcessorsProcessor;

    class ConfigurerService
    {
    public function periods()
    {
    $periods = config('ghp.billing-periods');

    return collect($periods)
    ->filter(fn($enabled) => $enabled)
    ->map(fn($enabled, $key) => $key)
    ->map(fn($key) => trans("words.$key"));
    }

    public function games()
    {
    return Game::all()->keyBy('id');
    }

    public function locations()
    {
    return Location::all()->map(function (Location $location) {
    return $location->attributesToArray() + [
    'available' => true,
    ];
    })->keyBy('id');
    }

    public function gameLocations(Game $game)
    {
    $locations = Location::with(['nodes', 'nodes.games'])->get();

    // Serialize Location and add 'available' field, if ANY node has $game
    return $locations->map(function (Location $location) use ($game) {
    $arr = $location->attributesToArray();
    // Check if we have a Node, that has $game
    $arr['available'] = $location->nodes->filter(function (Node $node) use ($game) {
    return $node->games->filter(fn(Game $g) => $g->id === $game->id)->count() > 0;
    })->count() > 0;

    return $arr;
    })->keyBy('id');
    }

    public function formToCost(Game $game, Node $node, array $form): array
    {
    /** @var GameService $service */
    $service = app(GameService::class);

    /** @var Processor $processor */
    $processor = $service->getProcessor($game);

    $processor->setNode($node);

    return $processor->resourceCost($form);
    }

    public function parameterSelection(Game $game, Node $node, array $form): array
    {
    /** @var GameService $service */
    $service = app(GameService::class);

    /** @var Processor $processor */
    $processor = $service->getProcessor($game);

    $processor->setNode($node);

    return $processor->calculate($form);
    }
    }
    Call to a member function setNode() on null



    hatası alıyoruz.

    PM'den kontrol etmek adına site adresini, açık kaynak kodlarını ve sunucu bilgilerini talep edebilirsiniz.

    Yardım edecek kişilere şimdiden teşekkürler.
  • 24-07-2022, 18:08:47
    #2
    PHP sürümünü kontrol ettiniz mi hocam?