-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Hackett
committed
Mar 1, 2021
1 parent
40c604a
commit f1a6381
Showing
6 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Locations\Database\Factories; | ||
|
||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
use Tipoff\Locations\Models\Timezone; | ||
|
||
class TimezoneFactory extends Factory | ||
{ | ||
/** | ||
* The name of the factory's corresponding model. | ||
* | ||
* @var string | ||
*/ | ||
protected $model = Timezone::class; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array | ||
*/ | ||
public function definition() | ||
{ | ||
return [ | ||
'name' => $this->faker->timezone, | ||
'title' => $this->faker->timezone, | ||
'php' => $this->faker->timezone, | ||
'is_daylight_saving' => $this->faker->boolean | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Locations\Models; | ||
|
||
use Tipoff\Support\Models\BaseModel; | ||
use Tipoff\Support\Traits\HasCreator; | ||
use Tipoff\Support\Traits\HasPackageFactory; | ||
use Tipoff\Support\Traits\HasUpdater; | ||
|
||
class Timezone extends BaseModel | ||
{ | ||
use HasPackageFactory; | ||
use HasCreator; | ||
use HasUpdater; | ||
|
||
public $timestamps = false; | ||
|
||
public function markets() | ||
{ | ||
return $this->belongsToMany(app('market')); | ||
} | ||
|
||
public function locations() | ||
{ | ||
return $this->belongsToMany(app('location')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Locations\Policies; | ||
|
||
use Illuminate\Auth\Access\HandlesAuthorization; | ||
use Tipoff\Locations\Models\Timezone; | ||
use Tipoff\Support\Contracts\Models\UserInterface; | ||
|
||
class TimezonePolicy | ||
{ | ||
use HandlesAuthorization; | ||
|
||
public function viewAny(UserInterface $user): bool | ||
{ | ||
return $user->hasPermissionTo('view timezones') ? true : false; | ||
} | ||
|
||
public function view(UserInterface $user, Timezone $timezone): bool | ||
{ | ||
return $user->hasPermissionTo('view timezones') ? true : false; | ||
} | ||
|
||
public function create(UserInterface $user): bool | ||
{ | ||
return $user->hasPermissionTo('create timezones') ? true : false; | ||
} | ||
|
||
public function update(UserInterface $user, Timezone $timezone): bool | ||
{ | ||
return $user->hasPermissionTo('update timezones') ? true : false; | ||
} | ||
|
||
public function delete(UserInterface $user, Timezone $timezone): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function restore(UserInterface $user, Timezone $timezone): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function forceDelete(UserInterface $user, Timezone $timezone): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Locations\Tests\Unit\Models; | ||
|
||
use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
use Tipoff\Locations\Models\Timezone; | ||
use Tipoff\Locations\Tests\TestCase; | ||
|
||
class TimezoneModelTest extends TestCase | ||
{ | ||
use DatabaseTransactions; | ||
|
||
/** @test */ | ||
public function create() | ||
{ | ||
$model = Timezone::factory()->create(); | ||
$this->assertNotNull($model); | ||
} | ||
} |