allw

allw

Member Since 2 Years Ago

Experience Points 6,170
Experience
Level
Lessons Completed 41
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

13 Jan
1 week ago

allw started a new conversation How To Add Different Variant Shades To Bootstrap Vue Without Having To Manually Type Out Every Single One?

I am looking for a way to add variants and shades of these variants Bootstrap Vue without having to explicitly type out every single one...

Currently I am just using _variables.scss that is provided and adding new entries (like below), but the bootstrap documentation mentions being able to use loops to for a limited number of elements and only then on "theme-colors".

$chemistry: #DB3A34 !default;
$biology: #306B34 !default;
$physics: #1B4965 !default;

Is there a way to just provide the colours then for all of these colours it would provide an option for using [variant]-light or [variant]-dark etc?

06 Jan
2 weeks ago

allw left a reply on Why This Report Take Too Long?

Have you tried returning something at different points to see how long it takes up to that point?

I would probably say the nested foreach loops are probably what is killing you. Though I can't really follow every part of your variable names surely there is a way to construct a payroll query without looping through every single employee and every single month?

Looking at your own code if you have say 1000 employees thats at least 39000 loops iterations (1000 employees * 3 concepts [not sure what a concept is] * 13 months).

Where it says you have a model of FechasCalendarios why are you pulling every record from that table on the database but then only using one field (nominas)?

allw left a reply on How To Determine If Multiple Records' Are More Than A Value Then Count?

For anyone that is interested here is my not so elegant solution

    $boundaries = $this->getBoundaries($test_id);

    $count = [];

    $test = Test::where('id', $test_id)->with('papers')->first();
    $paper_ids = $test->papers->pluck('id');
    $results = Result::whereIn('paper_id', $paper_ids)->get();
    $student_ids = $results->pluck('student_id')->unique();
    $externals = External::where('test_id', $test_id)->get();

    
    $student_results = collect([]);
    for ($i = 0; $i < count($student_ids); $i++) {
      $temp = collect();
      $temp->put('mark', $results->where('student_id', $student_ids[$i])->sum('mark'));
      $student_results->push($temp);
    }

    for ($i = 0; $i < count($boundaries); $i++) {
      $temp_count = 0;

      if ($i === 0 && $i < count($boundaries)) {
        $temp_count = $student_results->where('mark', '<', $boundaries[$i + 1]->mark)->count();
      } elseif ($i === (count($boundaries)-1)) {
        $temp_count = $student_results->where('mark', '>=', $boundaries[$i]->mark)->count();
      } else {
        $temp_count = $student_results->where('mark', '>=', $boundaries[$i]->mark)->where('mark', '<', $boundaries[$i + 1]->mark)->count();
      }
      //return $externals->where('grade_id', $boundaries[$i]->grade_id)->pluck('count');
      $count[$i] = [
        'grade' => $boundaries[$i]->name,
        'count' => $temp_count,
        'external' => $externals->where('grade_id', $boundaries[$i]->grade_id)->pluck('numbers')->first(),
        ];
    }
    return $count;
05 Jan
2 weeks ago

allw left a reply on How To Determine If Multiple Records' Are More Than A Value Then Count?

@NOLROS - Yeah, but there can be multiple papers so that would give grades for a single paper so the boundaries would appear to be double what they should be with 2 papers triple with 3 etc

allw left a reply on How To Determine If Multiple Records' Are More Than A Value Then Count?

| Grade | Number of students Who achieved Grade |
|-------|---------------------------------------|
| U     | 20                                    |
| 6     | 300                                   |
| 7     | 40                                    |

allw left a reply on How To Determine If Multiple Records' Are More Than A Value Then Count?

@PATRICKSJ - no because the grade boundaries are for the sum of the results of both papers, not just one paper.

allw left a reply on How To Determine If Multiple Records' Are More Than A Value Then Count?

@PATRICKSJ - I knew I wouldn't be clear enough;

I am looking for the count of any student result's which has a mark over the grade boundaries, but sometimes there are multiple papers so I would have to add the multiple papers then compare.

I could probably figure out a really ugly and slow version but ideally there is some way of doing this in a nice reasonably rapid way...

Hope this is clearer?

allw started a new conversation How To Determine If Multiple Records' Are More Than A Value Then Count?

I have a results table containing:

            $table->increments('id');
            $table->integer('mark')->nullable();
            $table->integer('paper_id')->unsigned();
            $table->string('student_id',14);

Students can have multiple results for a test (provided they are from different papers).

What I essentially need to do is, get any results where paper_id is one of test->paper->id where matching student ID (<|>|=) grade boundary but I do not want to have to do this for every student one by one.

Hope this makes sense?

Thanks!

allw left a reply on Vue Component Seems To Not Be Running Any Functions

Duh, thanks. There was an issue with bbraces at the start, I must have solved it incorrectly...

allw started a new conversation Vue Component Seems To Not Be Running Any Functions

I have a nested vue component that renders a highchart. The chart itself renders fine and any default data renders with it.

However, any methods just aren't running, irrespective of whether the things they are doing is correct they aren't even running console.log if it's the only thing in the function. Additionally it would seem that the props aren't being used either.

Interestingly no errors are being reported either at compile or run time. I can verify that the event is being emitted but that is where it ends, it does not seem to be caught.

<template>
<b-container>
    <highcharts :options="boundariesChartOptions"></highcharts>
</b-container>
</template>

<script>
export default {
    computed: {},
    watch: {},
    data: function() {
        return {
            boundaries: [],
            boundariesChartOptions: {
                ...
            },
            props: {
                students: Object,
                test: Object,
            },
            created() {
                Event.$on('toggled_boundaries', (show_grade_boundaries) => {
                    console.log('caught any');
                    if (show_grade_boundaries) {
                        this.getBoundaries()
                        console.log('caught true');
                    }
                });
            },
            methods: {
                getBoundaries() {
                     console.log('anything');
                    axios.get('teacher/boundaries/' + this.test.id)
                        .then(response => {
                            this.boundaries = response.data;
                        })
                        .catch(function(error) {
                            console.log(error);
                        });
                },
            },
        }
    }
}
</script>
19 Dec
1 month ago

allw started a new conversation Bootstrap Overflow-x:scroll In Bootstrap Modal

As title suggests I'm looking at how to realistically handle overflowing tabular content in a modal.

Trying to follow the vue/v-b instructions but obviously something is not perfect.

Have a modal something like below:

<b-modal v-bind:style="{ max-width: maxWidth }">
<b-container-fluid class="overflow-scroll-x">
{{ maxWidth }} //shows correct (90% of window) pixel count
<b-container-fluid>
</b-modal>

...

    created() {
  window.addEventListener('resize', this.handleResize)
  this.handleResize();
},
destroyed() {
  window.removeEventListener('resize', this.handleResize)
},

...

handleResize() {
   this.maxWidth = window.innerWidth * 0.9;
},

Anyone any ideas why the table is not scrolling but just overflowing?

17 Dec
1 month ago

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

@LOSTDREAMER_NL - So what I have done for now is remove the setter, and it seems to be working perfectly if I allow null values which I might just leave?

Problem is that we have 10 sets Superset (S) being the highest and 9 being the lowest, the reason why I mapped S to zero is that way if I return them in order they actually are in the correct order - should I instead be mapping null to 0 (Superset)?

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

namespace App;

use Illuminate\Database\Eloquent\Model;

class Group extends Model
{
  protected $with = [
    'academicyear',
    'stream'
  ];

  protected $fillable = [
    'academicyear_id',
    'stream_id',
    'faculty_id',
    'set_number',
    'calendaryear_id',
  ];

  protected $appends = [
    'name',
    'safe_name'
  ];

  public function getNameAttribute()
  {
      return "{$this->academicyear->year}{$this->stream->short_name}/{$this->faculty->short_name}{$this->set_number}";
  }
  public function getSafeNameAttribute()
  {
      return "{$this->academicyear->year}{$this->stream->short_name}{$this->faculty->short_name}{$this->set_number}";
  }
  public function getSetNumberAttribute($value)
  {
      if($value == 0){
        return "S";
      } else {
        return $value;
      }
  }
  public function setSetNumberAttribute($value)
  {
      if($value == 'S'){
        $this->attributes['set_number'] = 0;
      } elseif($value == null) {
        $this->attributes['set_number'] = 1;
      } else {
        $this->attributes['set_number'] = $value;
      }
  }
  public function teachers()
  {
      return $this->belongsToMany(Teacher::class);
  }
  public function faculty()
  {
      return $this->belongsTo(Faculty::class);
  }
  public function students()
  {
      return $this->belongsToMany(Student::class);
  }
  public function academicyear()
  {
    return $this->belongsTo(AcademicYear::class);
  }
  public function tests()
  {
      return $this->belongsToMany(Test::class);
  }
  public function managers()
  {
      return $this->belongsToMany(Teacher::class);
  }
  public function stream()
  {
      return $this->belongsTo(Stream::class);
  }
}

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

select * from `groups` where (`academicyear_id` = 5 and `stream_id` = 4 and `set_number` is null and `faculty_id` = 7 and `calendaryear_id` = 4) limit 1
800μs
/app/Imports/GroupsStudentsImport.php:57
project1894
insert into `groups` (`academicyear_id`, `stream_id`, `set_number`, `faculty_id`, `calendaryear_id`, `updated_at`, `created_at`) values (5, 4, 1, 7, 4, '2018-12-17 20:21:39', '2018-12-17 20:21:39')

Got all excited then cause i thought it was something to do with the set_number having a deault value so I removed it (and made that column nullable) and still same issue...

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

Different error this time...

Illuminate\Database\QueryException thrown with message "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '5-4-7-1-4' for key 'group_index' (SQL: insert into `groups` (`academicyear_id`, `stream_id`, `set_number`, `faculty_id`, `calendaryear_id`, `updated_at`, `created_at`) values (5, 4, 1, 7, 4, 2018-12-17 19:59:47, 2018-12-17 19:59:47))"

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

An excel import using maatwebsite\Excel

it's being called as above inside the foreach loop recommended by the package

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

100% sure the table is empty as it fails when I try to seed it too, and I'm using eloquent though? If I use raw SQL like you it works using tinker and correctly identifies if I try to duplicate this, does this mean there is an issue with the eloquent methods?

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

@STAUDENMEIR - Still fails when the db is empty.

Fails on firstOrCreate or updateOrCreate and even tried firstOrNew just to make sure...

allw left a reply on How To Access And Delete Polymorphic Relations?

  1. I presume when you delete a game you want to delete all the child relationships, you can use a cascade delete to do that if you include that in your migration. https://laravel.com/docs/5.7/migrations#foreign-key-constraints

  2. How i would create is something like

$video = new Video
$video->stuff = 'foo';
$video->save();

$game->media()->save($video);
  1. $game->media()->info ??

Based on what you've asked I'd imagine this is what you are after, honestly the laravel docs are amazing for this sort of stuff...

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

Code runs perfectly in tinker...

error message is:

Illuminate\Database\QueryException thrown with message "SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: groups.academicyear_id, groups.stream_id, groups.faculty_id, groups.set_number, groups.calendaryear_id (SQL: insert into "groups" ("academicyear_id", "stream_id", "set_number", "faculty_id", "calendaryear_id", "updated_at", "created_at") values (5, 4, 1, 7, 4, 2018-12-17 17:58:21, 2018-12-17 17:58:21))"

Stacktrace:
#116 Illuminate\Database\QueryException in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
#115 PDOException in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
#114 PDOStatement:execute in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
#113 Illuminate\Database\Connection:Illuminate\Database\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
#112 Illuminate\Database\Connection:runQueryCallback in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
#111 Illuminate\Database\Connection:run in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Connection.php:459
#110 Illuminate\Database\Connection:statement in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Connection.php:411
#109 Illuminate\Database\Connection:insert in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32
#108 Illuminate\Database\Query\Processors\Processor:processInsertGetId in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2494
#107 Illuminate\Database\Query\Builder:insertGetId in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1283
#106 Illuminate\Database\Eloquent\Builder:__call in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:787
#105 Illuminate\Database\Eloquent\Model:insertAndSetId in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:752
#104 Illuminate\Database\Eloquent\Model:performInsert in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:615
#103 Illuminate\Database\Eloquent\Model:save in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:382
#102 Illuminate\Database\Eloquent\Builder:Illuminate\Database\Eloquent\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Support/helpers.php:1041
#101 tap in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:383
#100 Illuminate\Database\Eloquent\Builder:firstOrCreate in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1570
#99 Illuminate\Database\Eloquent\Model:__call in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1582
#98 Illuminate\Database\Eloquent\Model:__callStatic in /mnt/c/git/tracking/app/Imports/GroupsStudentsImport.php:57
#97 App\Imports\GroupsStudentsImport:collection in /mnt/c/git/tracking/vendor/maatwebsite/excel/src/Sheet.php:221
#96 Maatwebsite\Excel\Sheet:import in /mnt/c/git/tracking/vendor/maatwebsite/excel/src/Jobs/ReadChunk.php:99
#95 Maatwebsite\Excel\Jobs\ReadChunk:Maatwebsite\Excel\Jobs\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:29
#94 Illuminate\Database\Connection:transaction in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:327
#93 Illuminate\Database\DatabaseManager:__call in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:223
#92 Illuminate\Support\Facades\Facade:__callStatic in /mnt/c/git/tracking/vendor/maatwebsite/excel/src/Jobs/ReadChunk.php:103
#91 Maatwebsite\Excel\Jobs\ReadChunk:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
#90 call_user_func_array in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
#89 Illuminate\Container\BoundMethod:Illuminate\Container\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
#88 Illuminate\Container\BoundMethod:callBoundMethod in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
#87 Illuminate\Container\BoundMethod:call in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Container/Container.php:564
#86 Illuminate\Container\Container:call in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:94
#85 Illuminate\Bus\Dispatcher:Illuminate\Bus\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:116
#84 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#83 Illuminate\Pipeline\Pipeline:then in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:98
#82 Illuminate\Bus\Dispatcher:dispatchNow in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:49
#81 Illuminate\Queue\CallQueuedHandler:call in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:83
#80 Illuminate\Queue\Jobs\Job:fire in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php:42
#79 Illuminate\Queue\SyncQueue:push in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:184
#78 Illuminate\Bus\Dispatcher:pushCommandToQueue in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:160
#77 Illuminate\Bus\Dispatcher:dispatchToQueue in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:73
#76 Illuminate\Bus\Dispatcher:dispatch in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php:112
#75 Illuminate\Foundation\Bus\PendingDispatch:__destruct in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:393
#74 dispatch in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Bus/Queueable.php:147
#73 Maatwebsite\Excel\Jobs\QueueImport:dispatchNextJobInChain in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:104
#72 Illuminate\Queue\CallQueuedHandler:ensureNextJobInChainIsDispatched in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:53
#71 Illuminate\Queue\CallQueuedHandler:call in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:83
#70 Illuminate\Queue\Jobs\Job:fire in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php:42
#69 Illuminate\Queue\SyncQueue:push in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:184
#68 Illuminate\Bus\Dispatcher:pushCommandToQueue in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:160
#67 Illuminate\Bus\Dispatcher:dispatchToQueue in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:73
#66 Illuminate\Bus\Dispatcher:dispatch in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php:112
#65 Illuminate\Foundation\Bus\PendingDispatch:__destruct in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:223
#64 Illuminate\Support\Facades\Facade:__callStatic in /mnt/c/git/tracking/app/Http/Controllers/ImportController.php:43
#63 App\Http\Controllers\ImportController:groupStudentImport in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
#62 call_user_func_array in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
#61 Illuminate\Routing\Controller:callAction in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45
#60 Illuminate\Routing\ControllerDispatcher:dispatch in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Route.php:212
#59 Illuminate\Routing\Route:runController in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Route.php:169
#58 Illuminate\Routing\Route:run in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:665
#57 Illuminate\Routing\Router:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#56 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/app/Http/Middleware/CheckRole.php:26
#55 App\Http\Middleware\CheckRole:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#54 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#53 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
#52 Illuminate\Routing\Middleware\SubstituteBindings:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#51 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#50 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php:43
#49 Illuminate\Auth\Middleware\Authenticate:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#48 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#47 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:68
#46 Illuminate\Foundation\Http\Middleware\VerifyCsrfToken:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#45 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#44 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49
#43 Illuminate\View\Middleware\ShareErrorsFromSession:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#42 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#41 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:63
#40 Illuminate\Session\Middleware\StartSession:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#39 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#38 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
#37 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#36 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#35 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
#34 Illuminate\Cookie\Middleware\EncryptCookies:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#33 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#32 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#31 Illuminate\Pipeline\Pipeline:then in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:667
#30 Illuminate\Routing\Router:runRouteWithinStack in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:642
#29 Illuminate\Routing\Router:runRoute in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:608
#28 Illuminate\Routing\Router:dispatchToRoute in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:597
#27 Illuminate\Routing\Router:dispatch in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176
#26 Illuminate\Foundation\Http\Kernel:Illuminate\Foundation\Http\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#25 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/beyondcode/laravel-view-xray/src/XrayMiddleware.php:34
#24 BeyondCode\ViewXray\XrayMiddleware:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#23 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#22 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php:65
#21 Barryvdh\Debugbar\Middleware\InjectDebugbar:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#20 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#19 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/fideloper/proxy/src/TrustProxies.php:57
#18 Fideloper\Proxy\TrustProxies:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#17 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#16 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
#15 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#14 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#13 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
#12 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#11 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#10 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
#9 Illuminate\Foundation\Http\Middleware\ValidatePostSize:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#8 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#7 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62
#6 Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode:handle in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#5 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#4 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#3 Illuminate\Pipeline\Pipeline:then in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151
#2 Illuminate\Foundation\Http\Kernel:sendRequestThroughRouter in /mnt/c/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
#1 Illuminate\Foundation\Http\Kernel:handle in /mnt/c/git/tracking/public/index.php:55
#0 require_once in /mnt/c/git/tracking/server.php:21

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

@LOSTDREAMER_NL - Yep! This is what I mean I just don't get what is wrong!!

allw left a reply on Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

@D9705996 - I'm currently using the sync queue driver though so it shouldn't be an issue?

Good to know though!

allw started a new conversation Eloquent Unique (integrity Constraint 23000, 19 Unique Constraint Failed)

Looking at making multiple columns a unique index:

here is migration

$table->increments('id');
            $table->integer('academicyear_id')->unsigned();
            $table->integer('stream_id')->unsigned();
            $table->integer('faculty_id')->unsigned();
            $table->integer('set_number')->default(1);
            $table->integer('calendaryear_id')->unsigned();

            $table->timestamps();
            $table->softDeletes();

            $table->unique(['academicyear_id', 'stream_id', 'faculty_id', 'set_number', 'calendaryear_id'], 'group_index');

            $table->foreign('academicyear_id')->references('id')->on('academic_years');
            $table->foreign('stream_id')->references('id')->on('streams');
            $table->foreign('faculty_id')->references('id')->on('faculties');
            $table->foreign('calendaryear_id')->references('id')->on('calendar_years');

If I remove the 'unique' statement duplicates are created when I run firstOrCreate/updateOrCreate method.

If I leave the unique statement in, it fails with error unique constraint fails:

despite the fact in the statements I mention each column

$group = Group::firstOrCreate([
              'academicyear_id' => $academicyear->id,
              'stream_id' => $stream->id,
              'set_number' => $set_number,
              'faculty_id' => $faculty->id,
              'calendaryear_id' => $calendaryear->id,
            ]);

Is there some underlying part of eloquent I am not aware of that means this is not how I use the unique constraint?

Thanks!

16 Dec
1 month ago

allw started a new conversation Laravel JSON Encryption

Good Evening all,

Just wondering - because I cannot find explicit mention of yes or no - just a maybe in a few places...

Does Laravel encrypt JSON responses when just send using something like:

return $array;

If laravel does not (which I would imagine is the case) can anyone recommend any packages or tutorials that would allow encryption between a laravel backend and a vue.js frontend? (outside of the normal TLS certificates etc that you would use on a web server)

Thanks!

15 Dec
1 month ago

allw left a reply on Accessing Array Of Array

@REALRANDYALLEN - So my controller looks like:

public function getclass($group_id, $test_id)
  {
      $group = Group::select('groups.id', 'faculties.id as faculty_id')->join('faculties', 'faculties.id', '=', 'groups.faculty_id')->where('groups.id', $group_id)->first();
      $student_ids = $group->students()->pluck('students.id');
      $test = Test::select('id', 'season_id')->where('id', $test_id)->with('papers')->first();
      $paper_ids = $test->papers()->pluck('papers.id');



      $students = Student::select(
        'students.id',
        'students.first_name',
        'students.last_name',
        'students.pupil_premium',
        'reports.ar_score as ar_score',
        'g2.name as grade',
        'g2.va_weight as grade_va_weight',
        'g2.internal_weight as grade_internal_weight',
        'reports.comments as comments',
        'g1.name as target_grade',
        'g1.va_weight as target_va_weight',
        'g1.internal_weight as target_internal_weight'
        )->join('group_student', function ($join) use ($group) {
          $join->on('group_student.student_id', '=', 'students.id')
                ->where('group_id', $group->id);
        })
        ->with(['results' => function ($query) use ($paper_ids) {
          $query->whereIn('results.paper_id', $paper_ids)->orderBy('results.paper_id', 'asc')->with('grade');
        }])
        ->leftjoin('targets', function ($join) use ($group, $test) {
          $join->on('students.id', '=', 'targets.student_id')
          ->where('targets.faculty_id', $group->faculty_id)
          ->where('targets.season_id', $test->season_id);
        })
        ->join('grades as g1', function ($join) {
          $join->on('targets.grade_id', '=', 'g1.id');
        })
        ->leftjoin('reports', function ($join) use ($test) {
          $join->on('students.id', '=', 'reports.student_id')->where('reports.test_id', $test->id);
        })
        ->leftjoin('grades as g2', function ($join) {
          $join->on('reports.grade_id', '=', 'g2.id');
        })
        ->orderBy('last_name', 'asc')->get();

      return $students;
  }

with groups.tests.papers being loaded on page load and the class being loaded when the user opens a modal.

allw left a reply on Accessing Array Of Array

But then surely I'll have the same problem but in reverse with having to match the students to the results?

allw left a reply on Accessing Array Of Array

@REALRANDYALLEN - I'm confused why would I want to display this in two different fields?

I'm looking to try and get an array of marks, based on a variable amount of papers. The results object stores the marks, but some of the results may be null because they haven't been entered yet...

allw left a reply on Accessing Array Of Array

Latest: I've managed to get Vue to throw an error of 'cannot read student.results[paperkey].mark of undefined' is there a way I can get vue to ignore that there will be situations when there are multiple results being returned and some will not exist until this component enters a mark??

allw left a reply on Accessing Array Of Array

@REALRANDYALLEN - the paper_id is not the key no but can I not return results which have a paper_id of paper.id?

as there should only be one result per paper

allw left a reply on Accessing Array Of Array

@REALRANDYALLEN - mark isn't part of paper though, it's part of the student object

allw started a new conversation Accessing Array Of Array

I have return an array of student objects to Vue, inside these objects are results arrays.

How do I attach a v-model to a specific one of these items depending on which 'paper' is being looped out? I know I cannot do the following but how would I do it?

<td v-for="(paper, key) in this.papers" :key="key"><input type="text" class="text-center" :id="(key) + '_' + (index +1)" v-model="student.results['paper_id' = paper.id].mark">
</td>
14 Dec
1 month ago

allw left a reply on Looking To Retrieve Objects Then Nest The Children

$students = Student::
        join('group_student', function ($join) use ($group) {
          $join->on('group_student.student_id', '=', 'students.id')
                ->where('group_id', $group->id);
        })
        ->with(['results.grade' => function ($query) use ($paper_ids) {
          $query->whereIn('results.paper_id', $paper_ids);
        }])
        ->with('targets.grade')
        ->orderBy('last_name', 'asc')->get();

This is what I have at the moment which is not returning any "Results" unfortunately without adding another table (which I would rather not do) I cannot just attach a ->with('papers.results.grade')

any ideas?

allw started a new conversation Looking To Retrieve Objects Then Nest The Children

So I am looking at making a student management system,

I need to be able to retrieve the following models Student Result Test Paper Target Grade

Problem is that both results and targets share grades but results also a belong to multiple papers.

is there a way to return something like

$students = Student::join('group_student', function ($join) use ($group) {
          $join->on('group_student.student_id', '=', 'students.id')
                ->where('group_id', $group_id);
        })


->with('papers.results.grades')
->whereIn('papers.id', $paper_ids)


->get();

that way in the view I could call something like:


foreach($students->papers as $paper) //obviously using blade 
{
    $paper->result->grade;
}

01 Dec
1 month ago

allw left a reply on Blade @each Causing Trying To Get Property Of Non-object Error (recursion)

@SUMBRIA - What did you do that was different? just remove the if statement?

allw left a reply on Blade @each Causing Trying To Get Property Of Non-object Error (recursion)

@SUMBRIA - yes I know and I am trying both @each('partials.faculties', $faculties, 'faculty') & @each('partials.faculties', $faculty->children, 'faculty')

and the two nested foreach loop and either way is not displaying the children...

allw left a reply on Blade @each Causing Trying To Get Property Of Non-object Error (recursion)

@KAKIMO - sorry but still makes no difference...most frustrating part of this is I don't know why it is throwing this error, at least if I knew that I could work on a solution.

allw left a reply on Blade @each Causing Trying To Get Property Of Non-object Error (recursion)

So if I use what you posted there is no error it simply does not loop out the children,

if I use the last version I had the error is:

ErrorException thrown with message "Trying to get property of non-object (View: /tmp/partials.facultiesAyN0yk) (View: /tmp/partials.facultiesAyN0yk)"

Stacktrace:
#75 ErrorException in /mnt/a/git/tracking/storage/framework/views/8e26579695f0838317ebb0d406f8b09914ba69dc.php:3
#74 ErrorException in /mnt/a/git/tracking/storage/framework/views/8e26579695f0838317ebb0d406f8b09914ba69dc.php:3
#73 ErrorException in /mnt/a/git/tracking/storage/framework/views/8e26579695f0838317ebb0d406f8b09914ba69dc.php:3
#72 Illuminate\Foundation\Bootstrap\HandleExceptions:handleError in /mnt/a/git/tracking/storage/framework/views/8e26579695f0838317ebb0d406f8b09914ba69dc.php:3
#71 include in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:43
#70 Illuminate\View\Engines\PhpEngine:evaluatePath in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php:59
#69 Illuminate\View\Engines\CompilerEngine:get in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/View.php:142
#68 Illuminate\View\View:getContents in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/View.php:125
#67 Illuminate\View\View:renderContents in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/View.php:90
#66 Illuminate\View\View:render in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/Factory.php:202
#65 Illuminate\View\Factory:renderEach in /mnt/a/git/tracking/storage/framework/views/5d178f2a62b4e33365c1095c15eedac9529688a7.php:53
#64 include in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:43
#63 Illuminate\View\Engines\PhpEngine:evaluatePath in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php:59
#62 Illuminate\View\Engines\CompilerEngine:get in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/View.php:142
#61 Illuminate\View\View:getContents in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/View.php:125
#60 Illuminate\View\View:renderContents in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/View.php:90
#59 Illuminate\View\View:render in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Http/Response.php:42
#58 Illuminate\Http\Response:setContent in /mnt/a/git/tracking/vendor/symfony/http-foundation/Response.php:202
#57 Symfony\Component\HttpFoundation\Response:__construct in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:733
#56 Illuminate\Routing\Router:toResponse in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:705
#55 Illuminate\Routing\Router:prepareResponse in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:665
#54 Illuminate\Routing\Router:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#53 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
#52 Illuminate\Routing\Middleware\SubstituteBindings:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#51 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#50 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php:43
#49 Illuminate\Auth\Middleware\Authenticate:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#48 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#47 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:68
#46 Illuminate\Foundation\Http\Middleware\VerifyCsrfToken:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#45 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#44 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49
#43 Illuminate\View\Middleware\ShareErrorsFromSession:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#42 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#41 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:63
#40 Illuminate\Session\Middleware\StartSession:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#39 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#38 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
#37 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#36 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#35 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
#34 Illuminate\Cookie\Middleware\EncryptCookies:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#33 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#32 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#31 Illuminate\Pipeline\Pipeline:then in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:667
#30 Illuminate\Routing\Router:runRouteWithinStack in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:642
#29 Illuminate\Routing\Router:runRoute in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:608
#28 Illuminate\Routing\Router:dispatchToRoute in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:597
#27 Illuminate\Routing\Router:dispatch in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176
#26 Illuminate\Foundation\Http\Kernel:Illuminate\Foundation\Http\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#25 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php:65
#24 Barryvdh\Debugbar\Middleware\InjectDebugbar:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#23 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#22 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/beyondcode/laravel-view-xray/src/XrayMiddleware.php:34
#21 BeyondCode\ViewXray\XrayMiddleware:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#20 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#19 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/fideloper/proxy/src/TrustProxies.php:57
#18 Fideloper\Proxy\TrustProxies:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#17 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#16 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
#15 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#14 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#13 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
#12 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#11 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#10 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
#9 Illuminate\Foundation\Http\Middleware\ValidatePostSize:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#8 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#7 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62
#6 Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode:handle in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#5 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#4 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#3 Illuminate\Pipeline\Pipeline:then in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151
#2 Illuminate\Foundation\Http\Kernel:sendRequestThroughRouter in /mnt/a/git/tracking/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
#1 Illuminate\Foundation\Http\Kernel:handle in /mnt/a/git/tracking/public/index.php:55
#0 require_once in /mnt/a/git/tracking/server.php:21

allw left a reply on Blade @each Causing Trying To Get Property Of Non-object Error (recursion)

@KAKIMO - How Would I check if it is the last loop that is failing?

$faculties is an eloquent model yes and the nested set is lazychaser/laravel-nestedset but surely if the children are present in the JSON response the nested set is not the issue?

allw left a reply on Blade @each Causing Trying To Get Property Of Non-object Error (recursion)

@SUMBRIA - I have done and I'm back to my original problem (before I posted here) of it is not looping out the child faculties...

allw left a reply on Blade @each Causing Trying To Get Property Of Non-object Error (recursion)

@SUMBRIA - [{"id":2,"name":"Science","is_subject":false,"short_name":null,"_lft":"2","_rgt":"21","parent_id":"1","safe_name":"science","children":[{"id":3,"name":"Chemistry","is_subject":true,"short_name":"Ch","_lft":"3","_rgt":"4","parent_id":"2","safe_name":"chemistry","children":[]},{"id":4,"name":"Physics","is_subject":true,"short_name":"Ph","_lft":"5","_rgt":"6","parent_id":"2","safe_name":"physics","children":[]},{"id":5,"name":"Biology","is_subject":true,"short_name":"Bi","_lft":"7","_rgt":"8","parent_id":"2","safe_name":"biology","children":[]},{"id":6,"name":"Dual Award Science","is_subject":true,"short_name":"Du","_lft":"9","_rgt":"16","parent_id":"2","safe_name":"dual-award-science","children":[{"id":7,"name":"Dual Award Biology","is_subject":false,"short_name":"DuB","_lft":"10","_rgt":"11","parent_id":"6","safe_name":"dual-award-biology","children":[]},{"id":8,"name":"Dual Award Chemistry","is_subject":false,"short_name":"DuC","_lft":"12","_rgt":"13","parent_id":"6","safe_name":"dual-award-chemistry","children":[]},{"id":9,"name":"Dual Award Physics","is_subject":false,"short_name":"DuP","_lft":"14","_rgt":"15","parent_id":"6","safe_name":"dual-award-physics","children":[]}]},{"id":10,"name":"KS3 Science","is_subject":true,"short_name":"Sc","_lft":"17","_rgt":"18","parent_id":"2","safe_name":"ks3-science","children":[]},{"id":11,"name":"Applied Science","is_subject":true,"short_name":"As","_lft":"19","_rgt":"20","parent_id":"2","safe_name":"applied-science","children":[]}]},{"id":15,"name":"Humanities","is_subject":false,"short_name":null,"_lft":"28","_rgt":"33","parent_id":"1","safe_name":"humanities","children":[{"id":16,"name":"Geography","is_subject":true,"short_name":"Gg","_lft":"29","_rgt":"30","parent_id":"15","safe_name":"geography","children":[]},{"id":17,"name":"History","is_subject":true,"short_name":"Hi","_lft":"31","_rgt":"32","parent_id":"15","safe_name":"history","children":[]}]}]

Here is the JSON response, as dd or Print_r would be massive.

allw left a reply on Blade @each Causing Trying To Get Property Of Non-object Error (recursion)

@D9705996 - I was using one loop before but the formatting was messed up...

also this is a recursive loop so surely I cannot just use $child when the foreach loop relies on $faculties?

allw started a new conversation Blade @each Causing Trying To Get Property Of Non-object Error

I'm trying to loop out a tree using blade, but on what I presume is the last loop it is failing with non-object error.

@each('partials.faculties', $faculties, 'faculties')

... //partials.faculties.blade.php @foreach($faculties as $faculty) <b-card title="{{ $faculty->name }}" text-variant="white" bg-variant="{{ $faculty->safe_name }}" v-b-toggle="'HoF_{{ $faculty->safe_name }}'" class="mb-3 cursor-pointer">

[Year {{ $faculty->name }}]
@endforeach @foreach($faculties as $faculty) @if (count($faculty->children)> 0) @foreach($faculty->children as $faculties) @include('partials.faculties', $faculties) @endforeach @endif @endforeach

I've tried multiple different variable names to see if they were being overridden and tried to follow a guide too but to no avail. Is there some other condition I am missing?

26 Nov
1 month ago

allw left a reply on Polymorphic Many-To-Many Only Working In One Direction

@STAUDENMEIR - $teacher = Teacher::where('id', [id])->first();

It has not problem accessing other relationships just these two...

allw left a reply on Polymorphic Many-To-Many Only Working In One Direction

@STAUDENMEIR - It’s own model as stated? What you mean?

25 Nov
1 month ago

allw started a new conversation Polymorphic Many-To-Many Only Working In One Direction

Trying to setup a relationship whereby a teacher can be a manager of both an academic year and a faculty.

As per laravel's documentation I set up a table called manageables:

        Schema::create('manageables', function (Blueprint $table) {
        $table->morphs('manageable');
        $table->string('teacher_id', 4);

        $table->foreign('teacher_id')->references('id')->on('teachers');
        });

In the Faculty and AcademicYear models I placed: public function managers() { return $this->morphToMany(Teacher::class, 'manageable'); }

Which seems to work fine as I can call $faculty->managers in laravel tinker, however, the inverse relationship does not work.

Again I tried to follow the docs this time being in teachers model but I keep getting error "Exception with message Property [faculties|academicyears] does not exist on this collection instance.' when calling either $teacher->faculties or $teacher->academicyears

public function academicyears()
  {
      return $this->morphedByMany(AcademicYear::class, 'manageable');
  }
public function faculties()
 {
     return $this->morphedByMany(Faculty::class, 'manageable');
 }

What am I doing wrong? Thanks!