Phill93

Experience

120

0 Best Reply Awards

  • Member Since 5 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

19th July, 2018

Phill93 left a reply on Make A Migration One Way • 2 months ago

@Sergiu17 my up function is finished.

I want a hard error if someone runs the rollback command.

Phill93 started a new conversation Make A Migration One Way • 2 months ago

Hi,

how can I create a migration that works only in one direction. I have on that modifys a relation from a one to many to a many to many, this way is possible without losing data. On the way back you are losing data if there are more than one relations.

Phill93

30th April, 2018

Phill93 left a reply on Nested Where With Resource • 5 months ago

I get the same error:

Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function load() on null in file /home/vagrant/repos/app/Http/Resources/FencerResource.php on line 19
Stack trace:
  1. Symfony\Component\Debug\Exception\FatalThrowableError->() /home/vagrant/repos/app/Http/Resources/FencerResource.php:19
  2. {main}() /home/vagrant/repos/public/index.php:0

Phill93 started a new conversation Nested Where With Resource • 5 months ago

Hi, i try to implement a filter functionality for an api endpoint. But when i try to filter my data my resource explodes with this error:

Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function load() on null in file /home/vagrant/repos/app/Http/Resources/FencerResource.php on line 19
Stack trace:
  1. Symfony\Component\Debug\Exception\FatalThrowableError->() /home/vagrant/repos/app/Http/Resources/FencerResource.php:19
  2. {main}() /home/vagrant/repos/public/index.php:0
´´´

api.php
```php
Route::get('fencers', function () {

    if (Input::get('filter')) {
        $collection = App\Http\Resources\FencerResource::collection(App\fencer::with(['person' => function($query) {
            $query->where('forename', Input::get('filter'));
        }])->paginate(Input::get('per_page')));
    } else {
        $collection = App\Http\Resources\FencerResource::collection(App\fencer::paginate(Input::get('per_page')));
    }

    return $collection;
});
´´´

FencerResource.php
```php
class FencerResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'person' => $this->person->load('sex')
        ];
    }
}
´´´
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.