Styling fix to the welcome widget
Add unit test for constraining by pivot data
This commit is contained in:
parent
ee2dd78b3d
commit
359461d93e
|
|
@ -22,3 +22,12 @@
|
|||
.widget-welcome .welcome-logo .oc-logo {
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
@media (max-width: 468px) {
|
||||
.widget-welcome .welcome-logo {
|
||||
float: none;
|
||||
}
|
||||
.widget-welcome .welcome-message {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,15 @@ class Author extends Model
|
|||
];
|
||||
|
||||
public $belongsToMany = [
|
||||
'roles' => ['Database\Tester\Models\Role', 'table' => 'database_tester_authors_roles']
|
||||
'roles' => [
|
||||
'Database\Tester\Models\Role',
|
||||
'table' => 'database_tester_authors_roles'
|
||||
],
|
||||
'executive_authors' => [
|
||||
'Database\Tester\Models\Role',
|
||||
'table' => 'database_tester_authors_roles',
|
||||
'conditions' => 'is_executive = 1'
|
||||
],
|
||||
];
|
||||
|
||||
public $morphMany = [
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ class Role extends Model
|
|||
* @var array Relations
|
||||
*/
|
||||
public $belongsToMany = [
|
||||
'authors' => ['Database\Tester\Models\User', 'table' => 'database_tester_authors_roles']
|
||||
'authors' => [
|
||||
'Database\Tester\Models\User',
|
||||
'table' => 'database_tester_authors_roles'
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,4 +147,20 @@ class BelongsToManyModelTest extends PluginTestCase
|
|||
$author->delete();
|
||||
$this->assertEquals(0, Db::table('database_tester_authors_roles')->where('author_id', $author->id)->count());
|
||||
}
|
||||
|
||||
public function testConditionsWithPivotAttributes()
|
||||
{
|
||||
Model::unguard();
|
||||
$author = Author::create(['name' => 'Stevie', 'email' => 'stevie@email.tld']);
|
||||
$role1 = Role::create(['name' => "Designer", 'description' => "Quality"]);
|
||||
$role2 = Role::create(['name' => "Programmer", 'description' => "Speed"]);
|
||||
$role3 = Role::create(['name' => "Manager", 'description' => "Budget"]);
|
||||
Model::reguard();
|
||||
|
||||
$author->roles()->add($role1, null, ['is_executive' => 1]);
|
||||
$author->roles()->add($role2, null, ['is_executive' => 1]);
|
||||
$author->roles()->add($role3, null, ['is_executive' => 0]);
|
||||
|
||||
$this->assertEquals([1, 2], $author->executive_authors->lists('id'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue