Fix database seedings with new model namespace

This commit is contained in:
Jonny Barnes 2017-12-22 14:28:41 +00:00
parent 4623c13c79
commit a329b05d53
11 changed files with 40 additions and 32 deletions

View file

@ -1,8 +1,9 @@
<?php <?php
use App\Models\Bookmark;
use Faker\Generator as Faker; use Faker\Generator as Faker;
$factory->define(App\Bookmark::class, function (Faker $faker) { $factory->define(Bookmark::class, function (Faker $faker) {
return [ return [
'url' => $faker->url, 'url' => $faker->url,
'name' => $faker->sentence, 'name' => $faker->sentence,

View file

@ -1,8 +1,9 @@
<?php <?php
use App\Models\Like;
use Faker\Generator as Faker; use Faker\Generator as Faker;
$factory->define(App\Like::class, function (Faker $faker) { $factory->define(Like::class, function (Faker $faker) {
return [ return [
'url' => $faker->url, 'url' => $faker->url,
'author_name' => $faker->name, 'author_name' => $faker->name,

View file

@ -1,8 +1,9 @@
<?php <?php
use App\Models\Note;
use Faker\Generator as Faker; use Faker\Generator as Faker;
$factory->define(App\Note::class, function (Faker $faker) { $factory->define(Note::class, function (Faker $faker) {
return [ return [
'note' => $faker->paragraph, 'note' => $faker->paragraph,
]; ];

View file

@ -1,8 +1,9 @@
<?php <?php
use App\Models\Tag;
use Faker\Generator as Faker; use Faker\Generator as Faker;
$factory->define(App\Tag::class, function (Faker $faker) { $factory->define(Tag::class, function (Faker $faker) {
return [ return [
'tag' => $faker->word, 'tag' => $faker->word,
]; ];

View file

@ -1,6 +1,6 @@
<?php <?php
use App\Article; use App\Models\Article;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class ArticlesTableSeeder extends Seeder class ArticlesTableSeeder extends Seeder

View file

@ -1,5 +1,6 @@
<?php <?php
use App\Models\{Bookmark, Tag};
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class BookmarksTableSeeder extends Seeder class BookmarksTableSeeder extends Seeder
@ -11,8 +12,8 @@ class BookmarksTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
factory(App\Bookmark::class, 10)->create()->each(function ($bookmark) { factory(Bookmark::class, 10)->create()->each(function ($bookmark) {
$bookmark->tags()->save(factory(App\Tag::class)->make()); $bookmark->tags()->save(factory(Tag::class)->make());
}); });
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
use App\Contact; use App\Models\Contact;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class ContactsTableSeeder extends Seeder class ContactsTableSeeder extends Seeder

View file

@ -1,5 +1,7 @@
<?php <?php
use App\Models\Like;
use Faker\Generator;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class LikesTableSeeder extends Seeder class LikesTableSeeder extends Seeder
@ -11,13 +13,13 @@ class LikesTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
factory(App\Like::class, 10)->create(); factory(Like::class, 10)->create();
$faker = new \Faker\Generator(); $faker = new Generator();
$faker->addProvider(new \Faker\Provider\en_US\Person($faker)); $faker->addProvider(new \Faker\Provider\en_US\Person($faker));
$faker->addProvider(new \Faker\Provider\Lorem($faker)); $faker->addProvider(new \Faker\Provider\Lorem($faker));
$faker->addProvider(new \Faker\Provider\Internet($faker)); $faker->addProvider(new \Faker\Provider\Internet($faker));
App\Like::create([ Like::create([
'url' => $faker->url, 'url' => $faker->url,
'author_url' => $faker->url, 'author_url' => $faker->url,
'author_name' => $faker->name, 'author_name' => $faker->name,

View file

@ -1,6 +1,7 @@
<?php <?php
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use App\Models\{Media, Note, Place};
class NotesTableSeeder extends Seeder class NotesTableSeeder extends Seeder
{ {
@ -11,31 +12,31 @@ class NotesTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
factory(App\Note::class, 10)->create(); factory(Note::class, 10)->create();
sleep(1); sleep(1);
$noteTwitterReply = App\Note::create([ $noteTwitterReply = Note::create([
'note' => 'What does this even mean?', 'note' => 'What does this even mean?',
'in_reply_to' => 'https://twitter.com/realDonaldTrump/status/933662564587855877', 'in_reply_to' => 'https://twitter.com/realDonaldTrump/status/933662564587855877',
]); ]);
sleep(1); sleep(1);
$noteWithPlace = App\Note::create([ $noteWithPlace = Note::create([
'note' => 'Having a #beer at the local. 🍺', 'note' => 'Having a #beer at the local. 🍺',
]); ]);
$noteWithPlace->tweet_id = '123456789'; $noteWithPlace->tweet_id = '123456789';
$place = App\Place::find(1); $place = Place::find(1);
$noteWithPlace->place()->associate($place); $noteWithPlace->place()->associate($place);
$noteWithPlace->save(); $noteWithPlace->save();
sleep(1); sleep(1);
$noteWithContact = App\Note::create([ $noteWithContact = Note::create([
'note' => 'Hi @tantek' 'note' => 'Hi @tantek'
]); ]);
sleep(1); sleep(1);
$noteWithContactPlusPic = App\Note::create([ $noteWithContactPlusPic = Note::create([
'note' => 'Hi @aaron', 'note' => 'Hi @aaron',
'client_id' => 'https://jbl5.dev/notes/new' 'client_id' => 'https://jbl5.dev/notes/new'
]); ]);
sleep(1); sleep(1);
$noteWithoutContact = App\Note::create([ $noteWithoutContact = Note::create([
'note' => 'Hi @bob', 'note' => 'Hi @bob',
'client_id' => 'https://quill.p3k.io' 'client_id' => 'https://quill.p3k.io'
]); ]);
@ -46,31 +47,31 @@ class NotesTableSeeder extends Seeder
mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755); mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755);
copy(base_path() . '/tests/aaron.png', public_path() . '/assets/profile-images/aaronparecki.com/image'); copy(base_path() . '/tests/aaron.png', public_path() . '/assets/profile-images/aaronparecki.com/image');
} }
$noteWithCoords = App\Note::create([ $noteWithCoords = Note::create([
'note' => 'Note from a town', 'note' => 'Note from a town',
]); ]);
$noteWithCoords->location = '53.499,-2.379'; $noteWithCoords->location = '53.499,-2.379';
$noteWithCoords->save(); $noteWithCoords->save();
sleep(1); sleep(1);
$noteWithCoords2 = App\Note::create([ $noteWithCoords2 = Note::create([
'note' => 'Note from a city', 'note' => 'Note from a city',
]); ]);
$noteWithCoords2->location = '53.9026894,-2.42250444118781'; $noteWithCoords2->location = '53.9026894,-2.42250444118781';
$noteWithCoords2->save(); $noteWithCoords2->save();
sleep(1); sleep(1);
$noteWithCoords3 = App\Note::create([ $noteWithCoords3 = Note::create([
'note' => 'Note from a county', 'note' => 'Note from a county',
]); ]);
$noteWithCoords3->location = '57.5066357,-5.0038367'; $noteWithCoords3->location = '57.5066357,-5.0038367';
$noteWithCoords3->save(); $noteWithCoords3->save();
sleep(1); sleep(1);
$noteWithCoords4 = App\Note::create([ $noteWithCoords4 = Note::create([
'note' => 'Note from a country', 'note' => 'Note from a country',
]); ]);
$noteWithCoords4->location = '63.000147,-136.002502'; $noteWithCoords4->location = '63.000147,-136.002502';
$noteWithCoords4->save(); $noteWithCoords4->save();
sleep(1); sleep(1);
$noteSyndicated = App\Note::create([ $noteSyndicated = Note::create([
'note' => 'This note has all the syndication targets', 'note' => 'This note has all the syndication targets',
]); ]);
$noteSyndicated->tweet_id = '123456'; $noteSyndicated->tweet_id = '123456';
@ -79,26 +80,26 @@ class NotesTableSeeder extends Seeder
$noteSyndicated->instagram_url = 'https://www.instagram.com/p/aWsEd123Jh'; $noteSyndicated->instagram_url = 'https://www.instagram.com/p/aWsEd123Jh';
$noteSyndicated->save(); $noteSyndicated->save();
sleep(1); sleep(1);
$noteWithTextLinkandEmoji = App\Note::create([ $noteWithTextLinkandEmoji = Note::create([
'note' => 'I love https://duckduckgo.com 💕' // theres a two-heart emoji at the end of this 'note' => 'I love https://duckduckgo.com 💕' // theres a two-heart emoji at the end of this
]); ]);
sleep(1); sleep(1);
$media = new App\Media(); $media = new Media();
$media->path = 'media/f1bc8faa-1a8f-45b8-a9b1-57282fa73f87.jpg'; $media->path = 'media/f1bc8faa-1a8f-45b8-a9b1-57282fa73f87.jpg';
$media->type = 'image'; $media->type = 'image';
$media->image_widths = '3648'; $media->image_widths = '3648';
$media->save(); $media->save();
$noteWithImage = App\Note::create([ $noteWithImage = Note::create([
'note' => 'A lovely waterfall', 'note' => 'A lovely waterfall',
]); ]);
$noteWithImage->media()->save($media); $noteWithImage->media()->save($media);
sleep(1); sleep(1);
$noteFromInstagram = App\Note::create([ $noteFromInstagram = Note::create([
'note' => 'Lovely #wedding #weddingfavour', 'note' => 'Lovely #wedding #weddingfavour',
]); ]);
$noteFromInstagram->instagram_url = 'https://www.instagram.com/p/Bbo22MHhE_0'; $noteFromInstagram->instagram_url = 'https://www.instagram.com/p/Bbo22MHhE_0';
$noteFromInstagram->save(); $noteFromInstagram->save();
$mediaInstagram = new App\Media(); $mediaInstagram = new Media();
$mediaInstagram->path = 'https://scontent-lhr3-1.cdninstagram.com/t51.2885-15/e35/23734479_149605352435937_400133507076063232_n.jpg'; $mediaInstagram->path = 'https://scontent-lhr3-1.cdninstagram.com/t51.2885-15/e35/23734479_149605352435937_400133507076063232_n.jpg';
$mediaInstagram->type = 'image'; $mediaInstagram->type = 'image';
$mediaInstagram->save(); $mediaInstagram->save();

View file

@ -1,6 +1,6 @@
<?php <?php
use App\Place; use App\Models\Place;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Phaza\LaravelPostgis\Geometries\Point; use Phaza\LaravelPostgis\Geometries\Point;

View file

@ -1,6 +1,6 @@
<?php <?php
use App\WebMention; use App\Models\WebMention;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class WebMentionsTableSeeder extends Seeder class WebMentionsTableSeeder extends Seeder
@ -16,7 +16,7 @@ class WebMentionsTableSeeder extends Seeder
'source' => 'https://aaronpk.localhost/reply/1', 'source' => 'https://aaronpk.localhost/reply/1',
'target' => config('app.url') . '/notes/E', 'target' => config('app.url') . '/notes/E',
'commentable_id' => '14', 'commentable_id' => '14',
'commentable_type' => 'App\Note', 'commentable_type' => 'App\Models\Note',
'type' => 'in-reply-to', 'type' => 'in-reply-to',
'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"url": ["https://aaronpk.localhost/reply/1"], "name": ["Hi too"], "author": [{"type": ["h-card"], "value": "Aaron Parecki", "properties": {"url": ["https://aaronpk.localhost"], "name": ["Aaron Parecki"], "photo": ["https://aaronparecki.com/images/profile.jpg"]}}], "content": [{"html": "Hi too", "value": "Hi too"}], "published": ["' . date(DATE_W3C) . '"], "in-reply-to": ["https://aaronpk.loclahost/reply/1", "' . config('app.url') .'/notes/E"]}}]}' 'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"url": ["https://aaronpk.localhost/reply/1"], "name": ["Hi too"], "author": [{"type": ["h-card"], "value": "Aaron Parecki", "properties": {"url": ["https://aaronpk.localhost"], "name": ["Aaron Parecki"], "photo": ["https://aaronparecki.com/images/profile.jpg"]}}], "content": [{"html": "Hi too", "value": "Hi too"}], "published": ["' . date(DATE_W3C) . '"], "in-reply-to": ["https://aaronpk.loclahost/reply/1", "' . config('app.url') .'/notes/E"]}}]}'
]); ]);
@ -24,7 +24,7 @@ class WebMentionsTableSeeder extends Seeder
'source' => 'http://tantek.com/', 'source' => 'http://tantek.com/',
'target' => config('app.url') . '/notes/D', 'target' => config('app.url') . '/notes/D',
'commentable_id' => '13', 'commentable_id' => '13',
'commentable_type' => 'App\Note', 'commentable_type' => 'App\Models\Note',
'type' => 'in-reply-to', 'type' => 'in-reply-to',
'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"url": ["http://tantek.com/"], "name": ["KUTGW"], "author": [{"type": ["h-card"], "value": "Tantek Celik", "properties": {"url": ["http://tantek.com/"], "name": ["Tantek Celik"]}}], "content": [{"html": "kutgw", "value": "kutgw"}], "published": ["' . date(DATE_W3C) . '"], "in-reply-to": ["' . config('app.url') . '/notes/D"]}}]}' 'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"url": ["http://tantek.com/"], "name": ["KUTGW"], "author": [{"type": ["h-card"], "value": "Tantek Celik", "properties": {"url": ["http://tantek.com/"], "name": ["Tantek Celik"]}}], "content": [{"html": "kutgw", "value": "kutgw"}], "published": ["' . date(DATE_W3C) . '"], "in-reply-to": ["' . config('app.url') . '/notes/D"]}}]}'
]); ]);