Upgrade to Laravel 8

This commit is contained in:
Jonny Barnes 2020-10-17 17:15:06 +01:00
parent 1ad58f10c5
commit 57186c3e2e
27 changed files with 945 additions and 1003 deletions

View file

@ -1,12 +1,35 @@
<?php
use App\Models\Bookmark;
use Faker\Generator as Faker;
namespace Database\Factories;
$factory->define(Bookmark::class, function (Faker $faker) {
return [
'url' => $faker->url,
'name' => $faker->sentence,
'content' => $faker->text,
];
});
use App\Models\Bookmark;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
class BookmarkFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Bookmark::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$now = Carbon::now()->subDays(rand(5, 15));
return [
'url' => $this->faker->url,
'name' => $this->faker->sentence,
'content' => $this->faker->text,
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
];
}
}

View file

@ -1,13 +1,36 @@
<?php
use App\Models\Like;
use Faker\Generator as Faker;
namespace Database\Factories;
$factory->define(Like::class, function (Faker $faker) {
return [
'url' => $faker->url,
'author_name' => $faker->name,
'author_url' => $faker->url,
'content' => '<html><body><div class="h-entry"><div class="e-content">' . $faker->realtext() . '</div></div></body></html>',
];
});
use App\Models\Like;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
class LikeFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Like::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$now = Carbon::now()->subDays(rand(5, 15));
return [
'url' => $this->faker->url,
'author_name' => $this->faker->name,
'author_url' => $this->faker->url,
'content' => '<html><body><div class="h-entry"><div class="e-content">' . $this->faker->realtext() . '</div></div></body></html>',
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
];
}
}

View file

@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use App\Models\MicropubClient;
use Illuminate\Database\Eloquent\Factories\Factory;
class MicropubClientFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = MicropubClient::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'client_url' => $this->faker->url,
'client_name' => $this->faker->company,
];
}
}

View file

@ -1,14 +1,33 @@
<?php
namespace Database\Factories;
use App\Models\Note;
use Faker\Generator as Faker;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
$factory->define(Note::class, function (Faker $faker) {
$now = Carbon::now()->subDays(rand(5, 15));
return [
'note' => $faker->paragraph,
'created_at' => $now,
'updated_at' => $now,
];
});
class NoteFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Note::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$now = Carbon::now()->subDays(rand(5, 15));
return [
'note' => $this->faker->paragraph,
'created_at' => $now,
'updated_at' => $now,
];
}
}

View file

@ -0,0 +1,32 @@
<?php
namespace Database\Factories;
use App\Models\Place;
use Illuminate\Database\Eloquent\Factories\Factory;
class PlaceFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Place::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->company,
'description' => $this->faker->sentence,
'latitude' => $this->faker->latitude,
'longitude' => $this->faker->longitude,
'external_urls' => $this->faker->url,
];
}
}

View file

@ -1,10 +1,28 @@
<?php
use App\Models\Tag;
use Faker\Generator as Faker;
namespace Database\Factories;
$factory->define(Tag::class, function (Faker $faker) {
return [
'tag' => $faker->word,
];
});
use App\Models\Tag;
use Illuminate\Database\Eloquent\Factories\Factory;
class TagFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Tag::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'tag' => $this->faker->word,
];
}
}

View file

@ -1,24 +1,31 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Faker\Generator as Faker;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
$factory->define(App\Models\User::class, function (Faker $faker) {
static $password;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
return [
'name' => mb_strtolower($faker->firstName),
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => Str::random(10),
];
});
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'password' => bcrypt('password'),
'remember_token' => Str::random(10),
];
}
}

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use App\Models\Article;
use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder;

View file

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

View file

@ -1,7 +1,11 @@
<?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
{
@ -25,5 +29,7 @@ class ClientsTableSeeder extends Seeder
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString(),
]);
MicropubClient::factory(5)->create();
}
}

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use App\Models\Contact;
use Illuminate\Database\Seeder;
use Illuminate\FileSystem\FileSystem;

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use App\Models\Like;
use Faker\Generator;
use Illuminate\Support\Carbon;
@ -15,15 +17,7 @@ class LikesTableSeeder extends Seeder
*/
public function run()
{
factory(Like::class, 10)->create()->each(function ($like) {
$now = Carbon::now()->subDays(rand(5, 15));
DB::table('likes')
->where('id', $like->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
});
Like::factory(10)->create();
$now = Carbon::now()->subDays(rand(3, 6));
$faker = new Generator();

View file

@ -1,9 +1,12 @@
<?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
{
@ -205,5 +208,7 @@ EOF;
DB::table('notes')
->where('id', $noteWithLongUrl->id)
->update(['updated_at' => $now->toDateTimeString()]);
Note::factory(10)->create();
}
}

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use App\Models\Place;
use Illuminate\Database\Seeder;
@ -20,5 +22,7 @@ class PlacesTableSeeder extends Seeder
$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();
}
}

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use App\Models\WebMention;
use Illuminate\Database\Seeder;
@ -12,7 +14,8 @@ class WebMentionsTableSeeder extends Seeder
*/
public function run()
{
$webmentionAaron = WebMention::create([
// WebMention Aaron
WebMention::create([
'source' => 'https://aaronpk.localhost/reply/1',
'target' => config('app.url') . '/notes/E',
'commentable_id' => '14',
@ -20,7 +23,8 @@ class WebMentionsTableSeeder extends Seeder
'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"]}}]}'
]);
$webmentionTantek = WebMention::create([
// WebMention Tantek
WebMention::create([
'source' => 'http://tantek.com/',
'target' => config('app.url') . '/notes/D',
'commentable_id' => '13',