Skip to content

Commit 2c0526f

Browse files
author
Chris Cho
committed
code linter fixes
1 parent b8b54dd commit 2c0526f

File tree

12 files changed

+73
-81
lines changed

12 files changed

+73
-81
lines changed

docs/eloquent-models/relationships.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ One to One Example
7676
The following example class shows how to define a ``HasOne`` one to one
7777
relationship between a ``Planet`` and ``Orbit`` model.
7878

79-
.. literalinclude:: /includes/eloquent-models/relationships/PlanetOneToOne.php
79+
.. literalinclude:: /includes/eloquent-models/relationships/one-to-one/Planet.php
8080
:language: php
8181
:dedent:
8282

8383
The following example class shows how to define the inverse relationship with
8484
``Orbit`` by using the ``belongsTo()`` method:
8585

86-
.. literalinclude:: /includes/eloquent-models/relationships/OrbitOneToOne.php
86+
.. literalinclude:: /includes/eloquent-models/relationships/one-to-one/Orbit.php
8787
:language: php
8888
:dedent:
8989

@@ -159,15 +159,15 @@ One to Many Example
159159
The following example class shows how to define a ``HasMany`` one to many
160160
relationship between a ``Planet`` parent model and ``Moon`` child model.
161161

162-
.. literalinclude:: /includes/eloquent-models/relationships/PlanetOneToMany.php
162+
.. literalinclude:: /includes/eloquent-models/relationships/one-to-many/Planet.php
163163
:language: php
164164
:dedent:
165165

166166
To define the inverse of the relationship on ``Moon``, add the dynamic
167167
property and call the ``belongsTo()`` method on it, as shown in the following
168168
example class:
169169

170-
.. literalinclude:: /includes/eloquent-models/relationships/MoonOneToMany.php
170+
.. literalinclude:: /includes/eloquent-models/relationships/one-to-many/Moon.php
171171
:language: php
172172
:dedent:
173173

@@ -258,14 +258,14 @@ Many to Many Example
258258
The following ``Planet`` class shows how to define a ``BelongsToMany`` many to
259259
many relationship with and a ``SpaceExplorer`` model.
260260

261-
.. literalinclude:: /includes/eloquent-models/relationships/PlanetManyToMany.php
261+
.. literalinclude:: /includes/eloquent-models/relationships/many-to-many/Planet.php
262262
:language: php
263263
:dedent:
264264

265265
The ``SpaceExplorer`` model defines a ``BelongsToMany`` many to many
266266
relationship with ``Planet`` as shown in the following example class:
267267

268-
.. literalinclude:: /includes/eloquent-models/relationships/SpaceExplorerManyToMany.php
268+
.. literalinclude:: /includes/eloquent-models/relationships/many-to-many/SpaceExplorer.php
269269
:language: php
270270
:dedent:
271271

@@ -387,14 +387,14 @@ Embedded Document Example
387387
The following example class shows how to define an ``embedsMany`` one to many
388388
relationship between a ``SpaceShip`` and ``Cargo`` model:
389389

390-
.. literalinclude:: /includes/eloquent-models/relationships/SpaceShipEmbedsMany.php
390+
.. literalinclude:: /includes/eloquent-models/relationships/embeds/SpaceShip.php
391391
:language: php
392392
:dedent:
393393

394394
The embedded model class omits the relationship definition as shown in the
395395
following example class:
396396

397-
.. literalinclude:: /includes/eloquent-models/relationships/CargoEmbedsMany.php
397+
.. literalinclude:: /includes/eloquent-models/relationships/embeds/Cargo.php
398398
:language: php
399399
:dedent:
400400

@@ -444,8 +444,8 @@ Cross-Database Relationships
444444
A cross-database relationship in {+odm-short+} is a relationship between models
445445
stored in a SQL relational database and models stored in a MongoDB database.
446446

447-
When you add a cross-database relationship, Eloquent lets you access a
448-
related model by using a dynamic property.
447+
When you add a cross-database relationship, Eloquent lets you access the
448+
related models by using a dynamic property.
449449

450450
{+odm-short+} supports the following cross-database relationship methods:
451451

@@ -467,14 +467,14 @@ The following example class creates a ``hasMany`` relationship between a
467467
``SpaceShip`` model stored in a relational database and a ``Passenger`` model
468468
stored in a MongoDB database:
469469

470-
.. literalinclude:: /includes/eloquent-models/relationships/SpaceShipCrossHasMany.php
470+
.. literalinclude:: /includes/eloquent-models/relationships/cross-db/SpaceShip.php
471471
:language: php
472472
:dedent:
473473

474474
The ``Passenger`` model defines a ``BelongsToMany`` relationship with
475475
``SpaceShip`` as shown in the following example class:
476476

477-
.. literalinclude:: /includes/eloquent-models/relationships/PassengerCrossBelongsTo.php
477+
.. literalinclude:: /includes/eloquent-models/relationships/cross-db/Passenger.php
478478
:language: php
479479
:dedent:
480480

docs/includes/eloquent-models/relationships/RelationshipController.php

Lines changed: 61 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
use App\Models\Planet;
99
use Illuminate\Http\Request;
1010

11-
use function view;
12-
13-
class PlanetController extends Controller
11+
class RelationshipController extends Controller
1412
{
1513
private function oneToOne()
1614
{
@@ -36,75 +34,75 @@ private function oneToMany()
3634
$planet->diameter_km = 142984;
3735
$planet->save();
3836

39-
$moon_1 = new Moon();
40-
$moon_1->name = 'Ganymede';
41-
$moon_1->orbital_period = 7.15;
37+
$moon1 = new Moon();
38+
$moon1->name = 'Ganymede';
39+
$moon1->orbital_period = 7.15;
4240

43-
$moon_2 = new Moon();
44-
$moon_2->name = 'Europa';
45-
$moon_2->orbital_period = 3.55;
41+
$moon2 = new Moon();
42+
$moon2->name = 'Europa';
43+
$moon2->orbital_period = 3.55;
4644

47-
$planet->moons()->save($moon_1);
48-
$planet->moons()->save($moon_2);
45+
$planet->moons()->save($moon1);
46+
$planet->moons()->save($moon2);
4947
// end one-to-many save
5048
}
5149

5250
private function planetOrbitDynamic()
5351
{
5452
// begin planet orbit dynamic property example
5553
$planet = Planet::first();
56-
$related_orbit = $planet->orbit;
54+
$relatedOrbit = $planet->orbit;
5755

5856
$orbit = Orbit::first();
59-
$related_planet = $orbit->planet;
57+
$relatedPlanet = $orbit->planet;
6058
// end planet orbit dynamic property example
6159
}
6260

6361
private function planetMoonsDynamic()
6462
{
6563
// begin planet moons dynamic property example
6664
$planet = Planet::first();
67-
$related_moons = $planet->moons;
65+
$relatedMoons = $planet->moons;
6866

6967
$moon = Moon::first();
70-
$related_planet = $moon->planet;
68+
$relatedPlanet = $moon->planet;
7169
// end planet moons dynamic property example
7270
}
7371

7472
private function manyToMany()
7573
{
7674
// begin many-to-many save
77-
$planet_earth = new Planet();
78-
$planet_earth->name = 'Earth';
79-
$planet_earth->save();
80-
81-
$planet_mars = new Planet();
82-
$planet_mars->name = 'Mars';
83-
$planet_mars->save();
84-
85-
$planet_jupiter = new Planet();
86-
$planet_jupiter->name = 'Jupiter';
87-
$planet_jupiter->save();
88-
89-
$explorer_tanya = new SpaceExplorer();
90-
$explorer_tanya->name = 'Tanya Kirbuk';
91-
$explorer_tanya->save();
92-
93-
$explorer_mark = new SpaceExplorer();
94-
$explorer_mark->name = 'Mark Watney';
95-
$explorer_mark->save();
96-
97-
$explorer_jeanluc = new SpaceExplorer();
98-
$explorer_jeanluc->name = 'Jean-Luc Picard';
99-
$explorer_jeanluc->save();
100-
101-
$explorer_tanya->planetsVisited()->attach($planet_earth);
102-
$explorer_tanya->planetsVisited()->attach($planet_jupiter);
103-
$explorer_mark->planetsVisited()->attach($planet_earth);
104-
$explorer_mark->planetsVisited()->attach($planet_mars);
105-
$explorer_jeanluc->planetsVisited()->attach($planet_earth);
106-
$explorer_jeanluc->planetsVisited()->attach($planet_mars);
107-
$explorer_jeanluc->planetsVisited()->attach($planet_jupiter);
75+
$planetEarth = new Planet();
76+
$planetEarth->name = 'Earth';
77+
$planetEarth->save();
78+
79+
$planetMars = new Planet();
80+
$planetMars->name = 'Mars';
81+
$planetMars->save();
82+
83+
$planetJupiter = new Planet();
84+
$planetJupiter->name = 'Jupiter';
85+
$planetJupiter->save();
86+
87+
$explorerTanya = new SpaceExplorer();
88+
$explorerTanya->name = 'Tanya Kirbuk';
89+
$explorerTanya->save();
90+
91+
$explorerMark = new SpaceExplorer();
92+
$explorerMark->name = 'Mark Watney';
93+
$explorerMark->save();
94+
95+
$explorerJeanluc = new SpaceExplorer();
96+
$explorerJeanluc->name = 'Jean-Luc Picard';
97+
$explorerJeanluc->save();
98+
99+
$explorerTanya->planetsVisited()->attach($planetEarth);
100+
$explorerTanya->planetsVisited()->attach($planetJupiter);
101+
$explorerMark->planetsVisited()->attach($planetEarth);
102+
$explorerMark->planetsVisited()->attach($planetMars);
103+
$explorerJeanluc->planetsVisited()->attach($planetEarth);
104+
$explorerJeanluc->planetsVisited()->attach($planetMars);
105+
$explorerJeanluc->planetsVisited()->attach($planetJupiter);
108106
// end many-to-many save
109107
}
110108

@@ -114,8 +112,8 @@ private function manyToManyDynamic()
114112
$planet = Planet::first();
115113
$explorers = $planet->visitors;
116114

117-
$space_explorer = SpaceExplorer:first();
118-
$planets_visited = $space_explorer->planetsVisited;
115+
$spaceExplorer = SpaceExplorer:first();
116+
$explored = $spaceExplorer->planetsVisited;
119117
// end many-to-many dynamic property example
120118
}
121119

@@ -126,16 +124,16 @@ private function embedsMany()
126124
$spaceship->name = 'The Millenium Falcon';
127125
$spaceship->save();
128126

129-
$cargo_spice = new Cargo();
130-
$cargo_spice->name = 'spice';
131-
$cargo_spice->weight = 50;
127+
$cargoSpice = new Cargo();
128+
$cargoSpice->name = 'spice';
129+
$cargoSpice->weight = 50;
132130

133-
$cargo_hyperdrive = new Cargo();
134-
$cargo_hyperdrive->name = 'hyperdrive';
135-
$cargo_hyperdrive->weight = 25;
131+
$cargoHyperdrive = new Cargo();
132+
$cargoHyperdrive->name = 'hyperdrive';
133+
$cargoHyperdrive->weight = 25;
136134

137-
$spaceship->cargo()->attach($cargo_spice);
138-
$spaceship->cargo()->attach($cargo_hyperdrive);
135+
$spaceship->cargo()->attach($cargoSpice);
136+
$spaceship->cargo()->attach($cargoHyperdrive);
139137
// end embedsMany save
140138
}
141139

@@ -147,14 +145,14 @@ private function crossDatabase()
147145
$spaceship->name = 'Nostromo';
148146
$spaceship->save();
149147

150-
$passenger_ellen = new Passenger();
151-
$passenger_ellen->name = 'Ellen Ripley';
148+
$passengerEllen = new Passenger();
149+
$passengerEllen->name = 'Ellen Ripley';
152150

153-
$passenger_dwayne = new Passenger();
154-
$passenger_dwayne->name = 'Dwayne Hicks';
151+
$passengerDwayne = new Passenger();
152+
$passengerDwayne->name = 'Dwayne Hicks';
155153

156-
$spaceship->passengers()->save($passenger_ellen);
157-
$spaceship->passengers()->save($passenger_dwayne);
154+
$spaceship->passengers()->save($passengerEllen);
155+
$spaceship->passengers()->save($passengerDwayne);
158156
// end cross-database save
159157
}
160158

@@ -163,20 +161,14 @@ private function crossDatabase()
163161
*/
164162
public function store(Request $request)
165163
{
166-
oneToMany();
167-
168-
return;
169164
}
170165

171166
/**
172167
* Display the specified resource.
173168
*/
174169
public function show()
175170
{
176-
return view('browse_planets', [
177-
'planets' => Planet::take(10)
178-
->get(),
179-
]);
171+
return 'ok';
180172
}
181173

182174
/**
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)