Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

raffelustig's avatar

Problems to get values from database

In my pistol-competition system we have something called patrols. There can be a number of shooters in each patrol. The patrol is build from a number of shooters. My problem is that when the competition is finished the results must be registered into the system for printouts. When I choose ”Results” no patrol shows up. Instead an error shows.

The system is upgraded from Laravel 5.3 to 7.29 and most of the functions is doing well but here it’s not working.

The error show this:

[2022-01-31 22:00:09] local.ERROR: Undefined variable: patrols {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined variable: patrols at /Users/ralph/laravelnew/webshooter_web_upgrade/app/Repositories/ResultsRepository.php:155)
[stacktrace]
#0 /Users/ralph/laravelnew/webshooter_web_upgrade/app/Repositories/ResultsRepository.php(155): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined varia...', '/Users/ralph/la...', 155, Array)
#1 /Users/ralph/laravelnew/webshooter_web_upgrade/app/Http/Controllers/Api/CompetitionsAdminResultsController.php(21): App\Repositories\ResultsRepository->getPatrols('2')
#2 /Users/ralph/laravelnew/webshooter_web_upgrade/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\Api\CompetitionsAdminResultsController->getResultsForRegistration(Object(Illuminate\Http\Request), '2')
#3 /Users/ralph/laravelnew/webshooter_web_upgrade/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('getResultsForRe...', Array)
#4 /Users/ralph/laravelnew/webshooter_web_upgrade/vendor/laravel/framework/src/Illuminate/Routing/Route.php(239): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\Api\CompetitionsAdminResultsController), 'getResultsForRe...')
#5 /Users/ralph/laravelnew/webshooter_web_upgrade/vendor/laravel/framework/src/Illuminate/Routing/Route.php(196): Illuminate\Routing\Route->runController()
#6 /Users/ralph/laravelnew/webshooter_web_upgrade/vendor/laravel/framework/src/Illuminate/Routing/Router.php(685): Illuminate\Routing\Route->run()

The ResultsRepository.php (part):


        return $signups;
    }

    public function getPatrols($competitionsId)
    {
        if(!$this->request->has('patrol_type')):
            $patrols = Patrol::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
        elseif($this->request->get('patrol_type') == 'finals'):
            $patrols = PatrolFinals::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
        elseif($this->request->get('patrol_type') == 'distinguish'):
            $patrols = PatrolDistinguish::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
        endif;
// 155:
        return $patrols;
    }

    public function storeResults($competitionsId)
    {
        if($this->request->has('results')):

This is CompetitionsAdminResultsController.php:

<?php

namespace App\Http\Controllers\Api;

use App\Repositories\ResultsRepository;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CompetitionsAdminResultsController extends Controller
{
    public function __construct(ResultsRepository $results)
    {
        $this->middleware('checkUserCompetitionRole:results');
        $this->results = $results;
    }

    public function getResultsForRegistration(Request $request, $competitionsId)
    {
        $signups  = $this->results->getResultsForRegistration($competitionsId);
        $stations = \App\Models\Station::where('competitions_id', $competitionsId)->whereBetween('sortorder', [$request->get('station_start'), $request->get('station_end')])->orderBy('sortorder')->get();
        $patrols  = $this->results->getPatrols($competitionsId);

        return response()->json(['signups'=>$signups, 'stations'=>$stations, 'patrols'=>$patrols]);
    }

    public function storeResults(Request $request, $competitionsId)
    {
        $results = $this->results->storeResults($competitionsId);

        return response()->json(_('Resultatet sparades'));
    }

    public function export(Request $request, $competitionsId)
    {
        if ($request->has('format') && $request->get('format') === 'xlsx') {
            $filter = [
                'std_medals' => $request->get('std_medals'),
                'prices' => $request->get('prices'),
            ];
            $this->results->generateXlsx($competitionsId, $filter);
        } else {
            $this->results->calculateResults($competitionsId);
            $this->results->generatePdf($competitionsId);
        }
    }

    public function exportTeamsResults(Request $request, $competitionsId)
    {
        $this->results->generateTeamsResultsPdf($competitionsId);
    }

    public function shootingcards(Request $request, $competitionsId)
    {
        $this->results->generatePdf($competitionsId);
    }
}

It should read from the database where the patrols are stored. Wonder what could be wrong.

0 likes
50 replies
tykus's avatar

I suppose the first question is what is the value of $this->request->get(‘patrol_type’)? There is a gap in your logic where there is a patrol_type but it is not one of the strings finals or distinguish.

raffelustig's avatar

@tykus It's not finals or distinguish, its an ordinary patrol. So it should just be fetched

tykus's avatar
tykus
Best Answer
Level 104

@raffelustig maybe the method should be like this:

public function getPatrols($competitionsId)
{
    if ($this->request->get('patrol_type') == 'finals'):
        return PatrolFinals::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
    endif;
    
    if ($this->request->get('patrol_type') == 'distinguish'):
        return PatrolDistinguish::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
    endif;

    return Patrol::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
}

Now the method will always return something.

You could be more dynamic using match on PHP 8

public function getPatrols($competitionsId)
{
   $patrol = match ($this->request->get('patrol_type')) {
        'finals' => PatrolFinals::query(),
        'distinguish' => PatrolDistinguish::query()
        default => Patrol::query(),
    };

    return $patrol->where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
}
1 like
raffelustig's avatar

@tykus The patrol_type are three, null, final and distinguish. Null is the ordinary competition that is not one of the other. Final is a separate patrol made up for just for that purpose, mastership, and there comes the distinguish also when two or more shooters hav the same result.

raffelustig's avatar

@tykus Got it. The first of those two functions works just fine after changing has with filled in another function: getResultsForRegistration($competitionsId) After that everything seems to work. Thank you very much, that was helpful even if it took some time. ;-)

1 like
raffelustig's avatar

The thing is that in Laravel 5.3 this is fully functional så I believe it has something to do with Laravel 7 thats running here. We have several different shooting branches like precision, field, military fast, etc. and the problem is the same in all when comes to the result part. I'll try your code.

tykus's avatar

@raffelustig we can only make suggestions based on the information we receive... the Undefined variable: patrols in the ResultsRepository suggests that $patrols is undefined. How can that be; let's step through the existing code:

public function getPatrols($competitionsId)
{
    if(!$this->request->has('patrol_type')):
        // if there is a `patrol_type` in the Request we do not get to here, so $patrols is not initialized
        $patrols = Patrol::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
    elseif($this->request->get('patrol_type') == 'finals'):
        // if there is a `patrol_type` and it is not "finals", we do not get to here, so patrols is not initialised
        $patrols = PatrolFinals::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
    elseif($this->request->get('patrol_type') == 'distinguish'):
        // if there is a `patrol_type` and it is not "distinguish", we do not get to here, so patrols is not initialised
        $patrols = PatrolDistinguish::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
    endif;
    // If none of the three conditions above are satisfied, then you have never initialized $patrols, but you return it here:
    return $patrols;
}
raffelustig's avatar

@tykus I agree it's strange, but the code works well in Laravel 5.3

If I remove the exclamation mark in the first if in 5.3 I'm getting the same error as in Laravel 7 with the exclamation mark in.

tykus's avatar

@raffelustig what is the actual contents of the Request?

public function getPatrols($competitionsId)
{
    dd($this->request->all());
    if(!$this->request->has('patrol_type')):
raffelustig's avatar

@tykus I have installed that ok. But how can I see the output from dd, I am starting the project with php artisan serve.

raffelustig's avatar

@tykus I found out. Here is the output:

 // Quit the server with CONTROL-C.                                                                              


POST http://localhost:8000/api/v4.1.9/competitions/1/admin/results/registration
-------------------------------------------------------------------------------

 ------------ ---------------------------------------- 
  date         Wed, 02 Feb 2022 11:27:16 +0100         
  controller   "CompetitionsAdminResultsController"    
  source       ResultsRepository.php on line 148       
  file         app/Repositories/ResultsRepository.php  
 ------------ ---------------------------------------- 

array:8 [
  "patrol" => "1"
  "patrol_type" => ""
  "station_start" => "1"
  "station_end" => "1"
  "lane_start" => "1"
  "lane_end" => "10"
  "show_empty_lanes" => "0"
  "per_shot" => "0"
]


tykus's avatar

@raffelustig open another terminal session (new tab or window) and run php artisan dump-server in there - make the request (in the browser) and any dump or dd output will appear in that terminal

EDIT So, you have patrol_type but it is empty.

tykus's avatar

@raffelustig so, you have patrol_type but it is empty; this is the reason you were not getting any patrols (originally); now why is it empty?

raffelustig's avatar

@tykus yes, I will try to test this on 5.3 and see what comes out. Gonna take a while.

raffelustig's avatar

@tykus @tykus Problem to install, maybe because the system is within a docker environment.

Ralphs-MacBook:webshooter_web ralph$ composer require --dev beyondcode/laravel-dump-server:*
./composer.json has been updated
Running composer update beyondcode/laravel-dump-server
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - beyondcode/laravel-dump-server[0.1.0, 1.0.0, ..., 1.1.3] require illuminate/console 5.6.* -> found illuminate/console[v5.6.0, ..., v5.6.39] but these were not loaded, likely because it conflicts with another require.
    - beyondcode/laravel-dump-server[1.2.0, ..., 1.2.1] require illuminate/console 5.6.*|5.7.* -> found illuminate/console[v5.6.0, ..., v5.7.28] but these were not loaded, likely because it conflicts with another require.
    - beyondcode/laravel-dump-server 1.2.2 requires illuminate/console 5.6.*|5.7.*|5.8.* -> found illuminate/console[v5.6.0, ..., v5.8.36] but these were not loaded, likely because it conflicts with another require.
    - beyondcode/laravel-dump-server 1.3.0 requires illuminate/console 5.6.*|5.7.*|5.8.*|^6.0 -> found illuminate/console[v5.6.0, ..., v5.8.36, v6.0.0, ..., v6.20.44] but these were not loaded, likely because it conflicts with another require.
    - beyondcode/laravel-dump-server 1.4.0 requires illuminate/console 5.6.*|5.7.*|5.8.*|^6.0|^7.0 -> found illuminate/console[v5.6.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6] but these were not loaded, likely because it conflicts with another require.
    - beyondcode/laravel-dump-server[1.5.0, ..., 1.7.0] require illuminate/console 5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0 -> found illuminate/console[v5.6.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.82.0] but these were not loaded, likely because it conflicts with another require.
    - Root composer.json requires beyondcode/laravel-dump-server * -> satisfiable by beyondcode/laravel-dump-server[0.1.0, 1.0.0, ..., 1.7.0].


Installation failed, reverting ./composer.json and ./composer.lock to their original content.
Ralphs-MacBook:webshooter_web ralph$ 
Ralphs-MacBook:webshooter_web ralph$ 
raffelustig's avatar

I cannot setup a 5.3 in a single folder as the 7 I have.

raffelustig's avatar

@tykus @tykus About patrol_type, there are three types of patrols, basic, final shooting and distinguish where distinguish contains shooters with exact the same result and they have to shoot again to differ. The basic patrol is "", final "final" and distinguish "distinguish"

raffelustig's avatar

Your code did return the note that patrol 1 was found but there is nothing to record the results, all blank.

tykus's avatar

@raffelustig well, I don't know your application or anything more than you have posted here!?!?!

My code does not return a "note"; it returns a Collection of Models. _What is "results"; and what is calling the getPatrols method???

raffelustig's avatar

There are three different patrol types, patrols, patrol_distinguish and patrol_final. Each have a table in DB. The one I've presented here is patrols, none of the others. But as I said earlier, it's Laravel 7 and works in 5.3

tykus's avatar

@raffelustig the original error message says that $patrols is undefined - we have solved that. I don't see where patrol_type was being set in the Request (i.e. what UI element is determining the value of patrol_type).

But as I said earlier, it's Laravel 7 and works in 5.3

Things change between major releases - you have gone through the upgrade guides???

tykus's avatar

@raffelustig 🤷‍♂️

Ok, is there an asynchronous request being made whenever the user (admin) selects from the Patrull/Skjutlag? Where does that Request go, and what is the response whenever you try it on the Laravel 7 app?

tykus's avatar

@raffelustig yes I understood that; my question was - do the boxes to fill in values change whenever you select a different patrol - is there an XHR/Ajax request being made whenever the Patrull/Skjutlag selection is changed? Open the Network tab in your browser's dev tools, and see if there is a Request whenever you change that select value

tykus's avatar

@raffelustig which of those requests is supposed to have the boxes to fill in values???

raffelustig's avatar

@tykus all. It's in the 5.3 functioning version. If you want you can test yourself: https://test.webshooter.se login as [email protected] with password 1111111 seven 1-s Choose Tävlingar and click on the top one. Then Administrera denna tävling - resultat - Registrera grundomgång. There you have it

raffelustig's avatar

If you choose another patrol you have to click Visa. ---- In the patrull 2 I have put in some results

raffelustig's avatar

@tykus I found some more information, "Possible patrol_type: null, finals, distinguish", in the ResultsRepositary.php: (in the beginning)

<?php
namespace App\Repositories;

use App\Models\Competition;
use App\Models\ResultPlacement;
use Illuminate\Support\Facades\App;
use Illuminate\Http\Request;
use App\Models\Patrol;
use App\Models\PatrolDistinguish;
use App\Models\PatrolFinals;
use App\Models\Result;
use App\Models\Signup;
use Illuminate\Support\Facades\Storage;
use App\Contracts\ExcelInterface;

class ResultsRepository
{
    public function __construct(Request $request, StandardMedalRepository $medals, ExcelInterface $excel)
    {
        $this->request = $request;
        $this->medals = $medals;
        $this->excel = $excel;
    }

    /**
     * Fetch all results for the requested patrols and lanes.
     * Seperate the query depending on patrol_type.
     * Possible patrol_type: null, finals, distinguish.
     *
     * Create a result if a signup does not have the requested results.
     *
     * Return an array containing the signups for requested patrol including results.
     */
    public function getResultsForRegistration($competitionsId)
    {
        $signups = [];

        if(!$this->request->has('patrol_type')):
            $patrol = Patrol::where('competitions_id', $competitionsId)->where('sortorder', $this->request->patrol)->first();
            if($patrol):
                for($lane=$this->request->lane_start; $lane<=$this->request->lane_end; $lane++):

                    $query = Signup::where('lane', $lane);
                    $query->where('patrols_id', $patrol->id);
                    $query->with(['User', 'Club', 'Weaponclass']);
                    $signup = $query->first();

                    if($signup):
                        for($station=$this->request->station_start;$station<=$this->request->station_end; $station++):
                            $result = Result::where('signups_id', $signup->id)->where('finals', 0)->where('distinguish', 0)->where('stations_id', $station)->first();
                            if(!$result):
                                $result = new Result();
                                $result->figure_hits = "0";
                                $result->hits = "0";
                                $result->points = "0";
                                $result->stations_id = $station;
                                $result->signups_id = $signup->id;
                                $result->station_figure_hits = [0,0,0,0,0,0];
                                $result->save();
                            endif;
                        endfor;
                        $signup->load(['Results'=>function($query){
                            $query->where('finals', 0);
                            $query->where('distinguish', 0);
                        }]);
                        $signups[$lane] = $signup->toArray();
                    else:
                        $signups[$lane] = [];
                    endif;
                endfor;
            endif;
        elseif($this->request->get('patrol_type') == 'finals'):
            $patrol = PatrolFinals::where('competitions_id', $competitionsId)->where('sortorder', $this->request->patrol)->first();
            if($patrol):
                for($lane=$this->request->lane_start; $lane<=$this->request->lane_end; $lane++):

                    $query = Signup::where('lane_finals', $lane);
                    $query->where('patrols_finals_id', $patrol->id);
                    $query->with(['User', 'Club', 'Weaponclass']);
                    $signup = $query->first();

                    if($signup):
                        for($station=$this->request->station_start;$station<=$this->request->station_end; $station++):
                            $result = Result::where('signups_id', $signup->id)->where('finals', 1)->where('distinguish', 0)->where('stations_id', $station)->first();
                            if(!$result):
                                $result = new Result();
                                $result->figure_hits = "0";
                                $result->hits = "0";
                                $result->points = "0";
                                $result->stations_id = $station;
                                $result->signups_id = $signup->id;
                                $result->finals = 1;
                                $result->station_figure_hits = [0,0,0,0,0,0];
                                $result->save();
                            endif;
                        endfor;
                        $signup->load(['Results'=>function($query){
                            $query->where('finals', 1);
                        }]);
                        $signups[$lane] = $signup->toArray();
                    else:
                        $signups[$lane] = [];
                    endif;
                endfor;
            endif;
        elseif($this->request->get('patrol_type') == 'distinguish'):
            $patrol = PatrolDistinguish::where('competitions_id', $competitionsId)->where('sortorder', $this->request->patrol)->first();
            if($patrol):
                for($lane=$this->request->lane_start; $lane<=$this->request->lane_end; $lane++):

                    $query = Signup::where('lane_distinguish', $lane);
                    $query->where('patrols_distinguish_id', $patrol->id);
                    $query->with(['User', 'Club', 'Weaponclass']);
                    $signup = $query->first();

                    if($signup):
                        for($station=$this->request->station_start;$station<=$this->request->station_end; $station++):
                            $result = Result::where('signups_id', $signup->id)->where('finals', 0)->where('distinguish', 1)->where('stations_id', $station)->first();
                            if(!$result):
                                $result = new Result();
                                $result->figure_hits = "0";
                                $result->hits = "0";
                                $result->points = "0";
                                $result->stations_id = $station;
                                $result->signups_id = $signup->id;
                                $result->distinguish = 1;
                                $result->station_figure_hits = [0,0,0,0,0,0];
                                $result->save();
                            endif;
                        endfor;
                        $signup->load(['Results'=>function($query){
                            $query->where('distinguish', 1);
                        }]);
                        $signups[$lane] = $signup->toArray();
                    else:
                        $signups[$lane] = [];
                    endif;
                endfor;
            endif;
        endif;

        return $signups;
    }

    public function getPatrols($competitionsId)
    {
        dd($this->request->all());
        if(!$this->request->has('patrol_type')):
            $patrols = Patrol::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
        elseif($this->request->get('patrol_type') == 'finals'):
            $patrols = PatrolFinals::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
        elseif($this->request->get('patrol_type') == 'distinguish'):
            $patrols = PatrolDistinguish::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
        endif;

        return $patrols;
    }
    
    /*
    public function getPatrols($competitionsId)
    {
        if ($this->request->get('patrol_type') == 'finals'):
            return PatrolFinals::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
        endif;
    
        if ($this->request->get('patrol_type') == 'distinguish'):
            return PatrolDistinguish::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
        endif;

        return Patrol::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
    }*/

    public function storeResults($competitionsId)
    {
        if($this->request->has('results')):
            foreach($this->request->get('results') as $input):
                if($input):
                    $result = Result::find($input['id']);
                    // Cast all station hits to integers before sending to the database.
                    if($input['station_figure_hits']):
                        $station_figure_hits = [];

raffelustig's avatar

@tykus We have the wrong focus on things. The patrol_type is suppose to be NULL. This means that this statement should be executed:

$patrols = Patrol::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();

From the ->get() the $patrols should have information to do the following: One: Create database post in patrols table, two: create posts in database results table and three: open up the blade showing the form where to put results in. But there comes no info from the get(). That is the problem. This works in Laravel 5.3 but not here in 8. So the results that comes out is not defined for some reason. Furthermore, I can not use Laravel Dump Server in laravel 5.3, it was introduced first in laravel 5.7.

Snapey's avatar

@raffelustig but you are not getting null, you are getting an empty string, so just change the logic

raffelustig's avatar

@Snapey Well, ok but what I should get is the result of the string I mentioned. So after return $patrols; I am getting: nothing so undefined of course. So I wonder how and what this:

$patrols = Patrol::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();

is going to get. And how to change the logic you say?

Snapey's avatar

@raffelustig @tykus already showed you how to check the logic.

Your code tests for no patrol_type, and patrol_type of 'finals' and 'distinguish'

It does not handle any other case, including empty string.

instead;

        if(!$this->request->filled('patrol_type')):
            $patrols = Patrol::where('competitions_id', $competitionsId)->orderBy('sortorder')->get();
raffelustig's avatar

@Snapey OK, that was a change, from dump($patrols); I'm now getting this:

Illuminate\Database\Eloquent\Collection^ {#1550
  #items: array:1 [
    0 => App\Models\Patrol^ {#1551
      #table: "patrols"
      #fillable: array:4 [
        0 => "patrol_size"
        1 => "start_time"
        2 => "end_time"
        3 => "sortorder"
      ]
      #appends: array:2 [
        0 => "start_time_human"
        1 => "end_time_human"
      ]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      +preventsLazyLoading: false
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #escapeWhenCastingToString: false
      #attributes: array:10 [
        "id" => 4
        "competitions_id" => 5
        "sortorder" => 1
        "start_time" => "2022-03-13 09:00:00"
        "end_time" => "2022-03-13 10:10:00"
        "patrol_size" => 10
        "weaponclasses_id" => null
        "created_at" => "2022-03-01 17:09:24"
        "updated_at" => "2022-03-01 17:09:24"
        "deleted_at" => null
      ]
      #original: array:10 [
        "id" => 4
        "competitions_id" => 5
        "sortorder" => 1
        "start_time" => "2022-03-13 09:00:00"
        "end_time" => "2022-03-13 10:10:00"
        "patrol_size" => 10
        "weaponclasses_id" => null
        "created_at" => "2022-03-01 17:09:24"
        "updated_at" => "2022-03-01 17:09:24"
        "deleted_at" => null
      ]
      #changes: []
      #casts: array:1 [
        "deleted_at" => "datetime"
      ]
      #classCastCache: []
      #attributeCastCache: []
      #dates: []
      #dateFormat: null
      #dispatchesEvents: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [
        0 => "*"
      ]
      #forceDeleting: false
    }
  ]
  #escapeWhenCastingToString: false
}

but no blade shows for the form to enter results. This is the field.blade.php that should present the form:

<div class="panel panel-default"
     ng-form name="signupForm"
     ng-repeat="(key, signup) in results.signups"
     ng-class="{'panel-danger': !signupForm.$valid, 'panel-primary': (signup.user && signupForm.$valid)}"
     ng-if="signup.user || (!signup.user && results.filter.show_empty_lanes)">
    <div class="panel-heading">
        <div class="row">
            <div class="col-sm-6">
                <% competitions.competition.translations.patrols_lane_singular | ucfirst %> <% key %>
            </div>
            <div class="col-sm-6 text-right">
                <span ng-if="signup.user"><% signup.user.fullname %>, <% signup.club.name %>, <% (competitions.competition.championships_id) ? signup.weaponclass.classname_general : signup.weaponclass.classname %></span>
                <span ng-if="!signup.user">-</span>
            </div>
        </div>
    </div>

    <table class="table-bordered table-condensed" ng-if="signup.user">
        <thead>
        <tr>
            <th width="150px">
                <% competitions.competition.translations.stations_name_singular | ucfirst %>
            </th>
            <th width="60px" class="text-center" ng-repeat="station in results.stations">
                <% station.sortorder %>
            </th>
            <th width="60px" class="text-center">Tot</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        <tr ng-if="results.filter.per_shot">
            <td>
                <% competitions.competition.translations.patrols_lane_plural | ucfirst %>
            </td>
            <td valign="top" ng-repeat="station in results.stations">
                <input
                    tabindex="<% key | padZero:3 %><% station.sortorder | padZero:3 %>"
                    class="form-control input-sm text-center"
                    ng-class="{'margin-top-5': $index>0}"
                    type="number"
                    max="50"
                    ng-model="(signup.results | where:{stations_id:station.sortorder} | first).station_figure_hits[n]"
                    ng-repeat="n in [] | range:0:station.figures"
                    ng-readonly="results.editingSignup.id !== signup.id"
                    ng-disabled="results.editingSignup.id !== signup.id"
                    ng-enter="results.save(signup);">
            </td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>
                Träffar
            </td>
            <td valign="top" ng-repeat="station in results.stations">
                <input
                    type="number"
                    max="<% station.shots %>"
                    ng-max="station.shots"
                    min="<% (signup.results | where:{stations_id:station.sortorder} | first).figure_hits %>"
                    tabindex="<% key | padZero:3 %><% station.sortorder | padZero:3 %>"
                    class="form-control input-sm text-center input-sm text-right"
                    ng-model="(signup.results | where:{stations_id:station.sortorder} | first).hits"
                    ng-if="signup.results.length"
                    ng-readonly="results.editingSignup.id !== signup.id"
                    ng-disabled="results.editingSignup.id !== signup.id"
                    ng-enter="results.save(signup);">
            </td>
            <td>
                <input type="number" class="form-control input-sm text-center" disabled ng-value="signup.results | sumByKey:'hits'">
            </td>
            <td></td>
        </tr>
        <tr>
            <td class="nowrap">
                Träffade figurer
            </td>
            <td valign="top" ng-repeat="station in results.stations">
                <input
                    type="number"
                    max="<% station.figures %>"
                    min="<% ((signup.results | where:{stations_id:station.sortorder} | first).hits) ? 1 : 0 %>"
                    tabindex="<% key | padZero:3 %><% station.sortorder | padZero:3 %>"
                    class="form-control input-sm text-center input-sm text-right"
                    ng-if="signup.results.length"
                    ng-model="(signup.results | where:{stations_id:station.sortorder} | first).figure_hits"
                    ng-readonly="results.editingSignup.id !== signup.id"
                    ng-disabled="results.editingSignup.id !== signup.id"
                    ng-enter="results.save(signup);">
            </td>
            <td>
                <input type="number" class="form-control input-sm text-center" disabled ng-value="signup.results | sumByKey:'figure_hits'">
            </td>
            <td></td>
        </tr>
        <tr>
            <td>
                Poäng
            </td>
            <td valign="top" ng-repeat="station in results.stations">
                <input
                    type="number"
                    min="0"
                    max="50"
                    tabindex="<% key | padZero:3 %><% station.sortorder | padZero:3 %>"
                    class="form-control input-sm text-center input-sm text-right"
                    ng-model="(signup.results | where:{stations_id:station.sortorder} | first).points"
                    ng-readonly="results.editingSignup.id !== signup.id"
                    ng-disabled="results.editingSignup.id !== signup.id"
                    ng-if="station.points"
                    ng-enter="results.save(signup);">
            </td>
            <td>
                <input type="number" class="form-control input-sm text-center" disabled ng-value="signup.results | sumByKey:'points'">
            </td>
            <td></td>
        </tr>
        </tbody>
    </table>

    <hr class="margin-0">

    <div class="panel-body" ng-if="results.editingSignup.id === signup.id">
        <button ng-click="results.save(signup, true);"
                class="btn btn-sm btn-primary margin-right-10"
                ng-class="{'btn-danger': !signupForm.$valid}">Spara</button>
        <button class="btn btn-sm btn-link" ng-click="results.stopEditing(signup)">Avbryt</button>
        <span uib-alert dismiss-on-timeout="250" close="results.closeAlert(signup)" ng-if="!signupForm.$valid" template-url="alert-danger.html">Formuläret innehåller fel</span>
        <span uib-alert dismiss-on-timeout="250" close="results.closeAlert(signup)" ng-if="signup.alert" template-url="alert.html"><% signup.alert %></span>
        <span close="results.closeError(signup)" ng-if="signup.error" template-url="alert.html"><% signup.error %></span>
    </div>
    <div class="panel-body" ng-if="results.editingSignup.id !== signup.id">
        <button class="btn btn-sm btn-primary margin-right-10" ng-click="results.startEditing(signup)">Redigera</button>
    </div>

    <div class="panel-body" ng-if="!signup.user">Användare saknas</div>
</div>

<script type="text/ng-template" id="alert.html">
    <span class="text-success" ng-transclude></span>
</script>
<script type="text/ng-template" id="alert-danger.html">
    <span class="text-danger" ng-transclude></span>
</script>

raffelustig's avatar

No errors also with the "filled", I just wonder what it takes to make the form blade show.

raffelustig's avatar

So, the system is very complicated, I've not written it myself, we are not getting any help from the original programmers. So we ar trying to get this to a more actual version of Laravel.

Please or to participate in this conversation.