Skip to content

Commit

Permalink
Create stub model & factory for gmb accounts #8
Browse files Browse the repository at this point in the history
  • Loading branch information
drewroberts committed Feb 27, 2021
1 parent ac34cab commit a3bc2df
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 10 deletions.
23 changes: 23 additions & 0 deletions database/factories/GmbAccountFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Tipoff\GoogleApi\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Tipoff\GoogleApi\Models\GmbAccount;

class GmbAccountFactory extends Factory
{
protected $model = GmbAccount::class;

public function definition()
{
return [
'account_number' => $this->faker->unique()->slug,
'key_id' => randomOrCreate(app('key')),
'creator_id' => randomOrCreate(app('user')),
'updater_id' => randomOrCreate(app('user')),
];
}
}
10 changes: 0 additions & 10 deletions database/factories/KeyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,8 @@

class KeyFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Key::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
Expand Down
24 changes: 24 additions & 0 deletions src/Models/GmbAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Tipoff\GoogleApi\Models;

use Tipoff\Support\Models\BaseModel;
use Tipoff\Support\Traits\HasCreator;
use Tipoff\Support\Traits\HasPackageFactory;
use Tipoff\Support\Traits\HasUpdater;

class GmbAccount extends BaseModel
{
use HasCreator;
use HasUpdater;
use HasPackageFactory;

protected $casts = [];

public function key()
{
return $this->belongsTo(app('key'));
}
}
5 changes: 5 additions & 0 deletions src/Models/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ class Key extends BaseModel
use HasPackageFactory;

protected $casts = [];

public function gmb_accounts()
{
return $this->hasMany(app('gmb_account'));
}
}

0 comments on commit a3bc2df

Please sign in to comment.