Upgrade to Laravel 8
This commit is contained in:
parent
1ad58f10c5
commit
57186c3e2e
27 changed files with 945 additions and 1003 deletions
60
database/seeders/ArticlesTableSeeder.php
Normal file
60
database/seeders/ArticlesTableSeeder.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Article;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ArticlesTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$now = Carbon::now()->subMonth();
|
||||
$articleFirst = Article::create([
|
||||
'title' => 'My New Blog',
|
||||
'main' => 'This is *my* new blog. It uses `Markdown`.',
|
||||
'published' => 1,
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('articles')
|
||||
->where('id', $articleFirst->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subHours(2)->subMinutes(25);
|
||||
$articleWithCode = <<<EOF
|
||||
I wrote some code.
|
||||
|
||||
I liked writing this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
echo 'Foo class constructed';
|
||||
}
|
||||
}
|
||||
```
|
||||
EOF;
|
||||
$articleSecond = Article::create([
|
||||
'title' => 'Some code I did',
|
||||
'main' => $articleWithCode,
|
||||
'published' => 1,
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('articles')
|
||||
->where('id', $articleSecond->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
}
|
||||
}
|
32
database/seeders/BookmarksTableSeeder.php
Normal file
32
database/seeders/BookmarksTableSeeder.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Models\{Bookmark, Tag};
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BookmarksTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Bookmark::factory(10)->create();
|
||||
factory(Bookmark::class, 10)->create()->each(function ($bookmark) {
|
||||
$bookmark->tags()->save(factory(Tag::class)->make());
|
||||
|
||||
$now = Carbon::now()->subDays(rand(2, 12));
|
||||
DB::table('bookmarks')
|
||||
->where('id', $bookmark->id)
|
||||
->update([
|
||||
'created_at' => $now->toDateTimeString(),
|
||||
'updated_at' => $now->toDateTimeString(),
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
35
database/seeders/ClientsTableSeeder.php
Normal file
35
database/seeders/ClientsTableSeeder.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\MicropubClient;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ClientsTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('clients')->insert([
|
||||
'client_url' => 'https://jbl5.dev/notes/new',
|
||||
'client_name' => 'JBL5',
|
||||
'created_at' => '2016-01-12 16:03:00',
|
||||
'updated_at' => '2016-01-12 16:03:00',
|
||||
]);
|
||||
|
||||
DB::table('clients')->insert([
|
||||
'client_url' => 'https://beta.indigenous.abode.pub/ios/',
|
||||
'client_name' => 'https://beta.indigenous.abode.pub/ios/',
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
|
||||
MicropubClient::factory(5)->create();
|
||||
}
|
||||
}
|
39
database/seeders/ContactsTableSeeder.php
Normal file
39
database/seeders/ContactsTableSeeder.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Contact;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\FileSystem\FileSystem;
|
||||
|
||||
class ContactsTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Contact::create([
|
||||
'nick' => 'tantek',
|
||||
'name' => 'Tantek Çelik',
|
||||
'homepage' => 'http://tantek.com',
|
||||
'twitter' => 't',
|
||||
]);
|
||||
Contact::create([
|
||||
'nick' => 'aaron',
|
||||
'name' => 'Aaron Parecki',
|
||||
'homepage' => 'https://aaronparecki.com',
|
||||
'facebook' => '123456',
|
||||
]);
|
||||
$fs = new FileSystem();
|
||||
if (!$fs->exists(public_path('assets/profile-images/aaronparecki.com'))) {
|
||||
$fs->makeDirectory(public_path('assets/profile-images/aaronparecki.com'));
|
||||
}
|
||||
$fs->copy(
|
||||
base_path('tests/aaron.png'),
|
||||
public_path('assets/profile-images/aaronparecki.com/image')
|
||||
);
|
||||
}
|
||||
}
|
26
database/seeders/DatabaseSeeder.php
Normal file
26
database/seeders/DatabaseSeeder.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->call(ArticlesTableSeeder::class);
|
||||
$this->call(ClientsTableSeeder::class);
|
||||
$this->call(ContactsTableSeeder::class);
|
||||
$this->call(PlacesTableSeeder::class);
|
||||
$this->call(NotesTableSeeder::class);
|
||||
$this->call(WebMentionsTableSeeder::class);
|
||||
$this->call(LikesTableSeeder::class);
|
||||
$this->call(BookmarksTableSeeder::class);
|
||||
$this->call(UsersTableSeeder::class);
|
||||
}
|
||||
}
|
48
database/seeders/LikesTableSeeder.php
Normal file
48
database/seeders/LikesTableSeeder.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Like;
|
||||
use Faker\Generator;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LikesTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Like::factory(10)->create();
|
||||
|
||||
$now = Carbon::now()->subDays(rand(3, 6));
|
||||
$faker = new Generator();
|
||||
$faker->addProvider(new \Faker\Provider\en_US\Person($faker));
|
||||
$faker->addProvider(new \Faker\Provider\Lorem($faker));
|
||||
$faker->addProvider(new \Faker\Provider\Internet($faker));
|
||||
$likeFromAuthor = Like::create([
|
||||
'url' => $faker->url,
|
||||
'author_url' => $faker->url,
|
||||
'author_name' => $faker->name,
|
||||
]);
|
||||
DB::table('likes')
|
||||
->where('id', $likeFromAuthor->id)
|
||||
->update([
|
||||
'created_at' => $now->toDateTimeString(),
|
||||
'updated_at' => $now->toDateTimeString(),
|
||||
]);
|
||||
|
||||
$now = Carbon::now()->subHours(rand(3, 6));
|
||||
$likeJustUrl = Like::create(['url' => 'https://example.com']);
|
||||
DB::table('likes')
|
||||
->where('id', $likeJustUrl->id)
|
||||
->update([
|
||||
'created_at' => $now->toDateTimeString(),
|
||||
'updated_at' => $now->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
}
|
214
database/seeders/NotesTableSeeder.php
Normal file
214
database/seeders/NotesTableSeeder.php
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\{Media, Note, Place};
|
||||
use SplFileInfo;
|
||||
|
||||
class NotesTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$now = Carbon::now()->subDays(rand(2, 5));
|
||||
$noteTwitterReply = Note::create([
|
||||
'note' => 'What does this even mean?',
|
||||
'in_reply_to' => 'https://twitter.com/realDonaldTrump/status/933662564587855877',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteTwitterReply->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subDays(rand(2, 5));
|
||||
$noteWithPlace = Note::create([
|
||||
'note' => 'Having a #beer at the local. 🍺',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
$noteWithPlace->tweet_id = '123456789';
|
||||
$place = Place::find(1);
|
||||
$noteWithPlace->place()->associate($place);
|
||||
$noteWithPlace->save();
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithPlace->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subDays(rand(3, 6));
|
||||
$noteWithPlaceTwo = Note::create([
|
||||
'note' => 'It’s really good',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
$place = Place::find(1);
|
||||
$noteWithPlaceTwo->place()->associate($place);
|
||||
$noteWithPlaceTwo->save();
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithPlaceTwo->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subDays(rand(4, 8));
|
||||
$noteWithContact = Note::create([
|
||||
'note' => 'Hi @tantek',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithContact->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subDays(rand(1, 10));
|
||||
$noteWithContactPlusPic = Note::create([
|
||||
'note' => 'Hi @aaron',
|
||||
'client_id' => 'https://jbl5.dev/notes/new',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithContactPlusPic->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subDays(rand(2, 5));
|
||||
$noteWithoutContact = Note::create([
|
||||
'note' => 'Hi @bob',
|
||||
'client_id' => 'https://quill.p3k.io',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithoutContact->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
//copy aaron’s profile pic in place
|
||||
$spl = new SplFileInfo(public_path() . '/assets/profile-images/aaronparecki.com');
|
||||
if ($spl->isDir() === false) {
|
||||
mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755);
|
||||
copy(base_path() . '/tests/aaron.png', public_path() . '/assets/profile-images/aaronparecki.com/image');
|
||||
}
|
||||
|
||||
$now = Carbon::now()->subDays(rand(3, 7));
|
||||
$noteWithCoords = Note::create([
|
||||
'note' => 'Note from a town',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithCoords->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
$noteWithCoords->location = '53.499,-2.379';
|
||||
$noteWithCoords->save();
|
||||
$noteWithCoords2 = Note::create([
|
||||
'note' => 'Note from a city',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
$noteWithCoords2->location = '53.9026894,-2.42250444118781';
|
||||
$noteWithCoords2->save();
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithCoords2->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
$noteWithCoords3 = Note::create([
|
||||
'note' => 'Note from a county',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
$noteWithCoords3->location = '57.5066357,-5.0038367';
|
||||
$noteWithCoords3->save();
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithCoords3->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
$noteWithCoords4 = Note::create([
|
||||
'note' => 'Note from a country',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
$noteWithCoords4->location = '63.000147,-136.002502';
|
||||
$noteWithCoords4->save();
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithCoords4->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subHours(7);
|
||||
$noteSyndicated = Note::create([
|
||||
'note' => 'This note has all the syndication targets',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
$noteSyndicated->tweet_id = '123456';
|
||||
$noteSyndicated->facebook_url = 'https://www.facebook.com/post/12345789';
|
||||
$noteSyndicated->swarm_url = 'https://www.swarmapp.com/checking/123456789';
|
||||
$noteSyndicated->instagram_url = 'https://www.instagram.com/p/aWsEd123Jh';
|
||||
$noteSyndicated->save();
|
||||
DB::table('notes')
|
||||
->where('id', $noteSyndicated->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subHours(6);
|
||||
$noteWithTextLinkandEmoji = Note::create([
|
||||
'note' => 'I love https://duckduckgo.com 💕', // there’s a two-heart emoji at the end of this
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithTextLinkandEmoji->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subHours(5);
|
||||
$noteJustCheckin = new Note();
|
||||
$noteJustCheckin->setCreatedAt($now);
|
||||
$place = Place::find(1);
|
||||
$noteJustCheckin->place()->associate($place);
|
||||
$noteJustCheckin->save();
|
||||
DB::table('notes')
|
||||
->where('id', $noteJustCheckin->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subHours(4);
|
||||
$media = new Media();
|
||||
$media->path = 'media/f1bc8faa-1a8f-45b8-a9b1-57282fa73f87.jpg';
|
||||
$media->type = 'image';
|
||||
$media->image_widths = '3648';
|
||||
$media->save();
|
||||
$noteWithOnlyImage = new Note();
|
||||
$noteWithOnlyImage->setCreatedAt($now);
|
||||
$noteWithOnlyImage->setUpdatedAt($now);
|
||||
$noteWithOnlyImage->save();
|
||||
$noteWithOnlyImage->media()->save($media);
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithOnlyImage->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subHours(3);
|
||||
$noteCapitalHashtag = Note::create([
|
||||
'note' => 'A #TwoWord hashtag',
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteCapitalHashtag->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now()->subHours(2);
|
||||
$noteWithCodeContent = <<<EOF
|
||||
A note with some code:
|
||||
```php
|
||||
<?php
|
||||
|
||||
echo 'Hello World';
|
||||
EOF;
|
||||
$noteWithCode = Note::create([
|
||||
'note' => $noteWithCodeContent,
|
||||
'created_at' => $now,
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithCode->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
$now = Carbon::now();
|
||||
$noteWithLongUrl = Note::create([
|
||||
'note' => 'Best site: https://example.org/posts/some-really-long-slug-that-is-too-wide-on-mobile',
|
||||
'created_at' => $now,
|
||||
'client_id' => 'https://beta.indigenous.abode.pub/ios/'
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithLongUrl->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
||||
Note::factory(10)->create();
|
||||
}
|
||||
}
|
28
database/seeders/PlacesTableSeeder.php
Normal file
28
database/seeders/PlacesTableSeeder.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Place;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class PlacesTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$place = new Place();
|
||||
$place->name = 'The Bridgewater Pub';
|
||||
$place->description = 'A lovely local pub with a decent selection of cask ales';
|
||||
$place->latitude = 53.4983;
|
||||
$place->longitude = -2.3805;
|
||||
$place->external_urls = 'https://foursquare.com/v/123435/the-bridgewater-pub';
|
||||
$place->external_urls = 'https://www.openstreetmap.org/way/987654';
|
||||
$place->save();
|
||||
|
||||
Place::factory(10)->create();
|
||||
}
|
||||
}
|
22
database/seeders/UsersTableSeeder.php
Normal file
22
database/seeders/UsersTableSeeder.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UsersTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('users')->insert([
|
||||
'name' => 'jonny',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
}
|
||||
}
|
36
database/seeders/WebMentionsTableSeeder.php
Normal file
36
database/seeders/WebMentionsTableSeeder.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\WebMention;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class WebMentionsTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// WebMention Aaron
|
||||
WebMention::create([
|
||||
'source' => 'https://aaronpk.localhost/reply/1',
|
||||
'target' => config('app.url') . '/notes/E',
|
||||
'commentable_id' => '14',
|
||||
'commentable_type' => 'App\Models\Note',
|
||||
'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"]}}]}'
|
||||
]);
|
||||
// WebMention Tantek
|
||||
WebMention::create([
|
||||
'source' => 'http://tantek.com/',
|
||||
'target' => config('app.url') . '/notes/D',
|
||||
'commentable_id' => '13',
|
||||
'commentable_type' => 'App\Models\Note',
|
||||
'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"]}}]}'
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue