11.08.2017 Views

codebright

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Eloquent ORM 274<br />

1 mysql> select * from games;<br />

2 +----+-------------------+----------------------------+---------------------+----\<br />

3 -----------------+<br />

4 | id | name | description | created_at | upd\<br />

5 ated_at |<br />

6 +----+-------------------+----------------------------+---------------------+----\<br />

7 -----------------+<br />

8 | 1 | Assassins Creed 4 | Shiver me timbers, Edward. | 2013-07-14 17:38:50 | 201\<br />

9 3-07-14 17:49:28 |<br />

10 +----+-------------------+----------------------------+---------------------+----\<br />

11 -----------------+<br />

12 1 row in set (0.00 sec)<br />

As you can see, our existing row has been updated accordingly. Once again, we did not write a<br />

single line of SQL. Only beautiful, eloquent PHP. You will also notice that the updated_at column<br />

has been populated with update time automatically. Very useful!<br />

Deleting Existing Models<br />

Deleting Eloquent models is a simple process. First we need to get our hands on the instance of the<br />

model that we wish to delete. For example, we could use the find() method that we discovered in<br />

a previous sub chapter.<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!