Laravel commands
HELP
EXTENSIONS
Installing NPM….
If you get errors, e.g. can’t find vcbuild.exe then maybe need to do the following…. (to get vcbuild.exe, python, etc)
npm install --global --production windows-build-tools
https://github.com/laracasts/Laravel-5-Generators-Extended
https://github.com/laracasts/Laravel-5-Generators-Extended
NESTED SETS….
kalnoy vs baum….a close call. Baum has more downloads (and more forks!?) BUT went with kalnoy because that was used in the Rinvex Categories package. Also, kalnoy was updated 16 days ago (as opposed to 3 years) and explicitly states compatibility with Laravel 5.5.
composer require kalnoy/nestedset
COMPOSER
composer dump-autoload
ARTISAN
php artisan make:model -cfm Events (controller / factory / migration)
php artisan make:migration create_series_table
php artisan make:migration:pivot tags posts (Laravel extended generators)
php artisan migrate:fresh –seed
SOME ERRORS
$event->entrants()
[BadMethodCallException] Method entrants does not exist.
Could be that you’re using a collection (e.g. something returned from an all() or get())
Instead of returning a collection of models, methods like find() and first() return a single model instance
* * *
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'EntrantEvent' not found
In model Event.php, use App\EntrantEvent didn’t seem to help. Needed to change ->using('EntrantEvent') to ->using('App\EntrantEvent');
* * *
[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function getCreatedAtColumn() on null
Probably trying to access a method (maybe attach) on a Pivot instance that wasn’t instantiated with it’s parent model. e.g. $entries = EntrantEvent::first();
* * *
[BadMethodCallException] Call to undefined method Illuminate\Database\Query\Builder::bikes()
[Symfony\Component\Debug\Exception\FatalThrowableError] Call to undefined method Illuminate\Events\Dispatcher::where()
Added use App\Event to seeder file and it worked….
* * *
[BadMethodCallException] Call to undefined method Illuminate\Database\Query\Builder::fromRawAttributes()
The model referenced in a using clause is a Model, but it needs to be descended from a Pivot.
class EntryBike extends Pivot / Model
EntrantEvent
public function bikes()
{
return $this->belongsToMany('App\BikeModel','entry_bike', 'event_entry_id')
->withPivot('id','bike_number')
->using('App\EntryBike');
}
[BadMethodCallException]
Call to undefined method Illuminate\Database\Query\Builder::attach()
[BadMethodCallException]
Call to undefined method Illuminate\Database\Query\Builder::fromRawAttributes()
Maybe trying to use a Model as a pivot? e.g. models –>bike_entry<–entries where bike_entry is class Model and method bikes contains
return $this->belongsToMany(‘App\BikeModel’,’entry_bike’, ‘event_entry_id’)->withPivot(‘id’,’bike_number’)->using(‘App\EntryBike’);
Then $entry->bikes()->attach(…) will generate this message….
NB: Getting ride of the ->using(..) clause (or was it the ->withPivot(…) clause?) makes this error go away….
