- ??? ??? ?? ??? ???? ? ???? ?? ??
- ??? ?? ??? ??? ??? ?????. Laravel?
- ???? ? ??? ??? ?? ?? ??? ?? ??? ????? Eloquent?? ???? ? ??? ? ????. ?? ?? ???? ?? ?? ?? ? ?? ????? ?? ??????.
morphTo
Laravel? ??? ??? ??? ???? ??? ??? ?? ??? ?? ??????. ??? ??? ?? ???? ?? ?????.morphMany
morphOne
? ??? Younes Rafie? ?? ??????. Sitepoint? ??? ???? ??? ?? Sitepoint? ?? ?? ?? ??? ?????!
-
??? ???? ?????? ??? ??? ?? ??? ??? ???? ? ????. ??? ? ???? ??? ???? : ??? ???. ???? ??? ??? ??????
MorphMap
?? ???? ?? ??? ??? ????? ??? ??? ??? ???. ???? ??? ???? ??? ?? ? ????. ??? ??? ???? ? ?? ?? ?? ?? ???? ??? ? ????. ???? ????? ??? ???? ?? Post_comments ???? Topic_comments ???? ?????? ??? ??? ?? ?????? ????. ??? ??? ???? ? ?? ???? ???? ????. ???? ?? ?? ??? ??? ?????.
.
??
???? ??????. ???? ???? ??? ???? ??? ??? ? ????. ?? ??? ????.
??? ?? ??? ??? ??? ?????. ?? ?? ??? ??? ?? ??? ?? ? ????. ?? ?????.
<code>albums
id - integer
name - string
songs
id - integer
title - string
album_id - integer
upvotes
id - integer
upvoteable_id - integer
upvoteable_type - string
</code>
-m
up
{some_timestamp}_create_albums_table.php
<code>php artisan make:model Album -m
php artisan make:model Song -m
php artisan make:model Upvote -m
</code>
{some_timestamp}_create_songs_table.php
public function up()
{
Schema::create('albums', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}
<<> {some_timestamp}_create_upvotes_table.php
public function up()
{
Schema::create('songs', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->integer('album_id')->unsigned()->index();
$table->timestamps();
$table->foreign('album_id')->references('id')->on('albums')->onDelete('cascade');
});
}
public function up()
{
Schema::create('upvotes', function (Blueprint $table) {
$table->increments('id');
$table->morphs('upvoteable'); // 添加無符號整數(shù) upvoteable_id 和字符串 upvoteable_type
$table->timestamps();
});
}
???? ??? ??? Upvote ?? ??? ??? ??? ??? ???? ?? ?? ????? ?? ?? ?? ? ??????. app/Upvote.php
<code>php artisan migrate</code>
<<> app/Album.php
?? ??? ??? ? ????.
[...]
class Upvote extends Model
{
/**
* 獲取所有擁有模型。
*/
public function upvoteable()
{
return $this->morphTo();
}
}
??????. ???? ???? ??? ?? ???? ??? ? ???? : app/Song.php
Upvote ??? ?? ? ??> ??? ?? ????? ????? ?? ?? ????? ?????. <code>albums
id - integer
name - string
songs
id - integer
title - string
album_id - integer
upvotes
id - integer
upvoteable_id - integer
upvoteable_type - string
</code>
)? ??? ??? ??? ?? ? ?? ??? ??????? ?? ?????. ??? <<> ???? ??? ?? ??? ????.
upvoteable_type
App\Album
App\Song
App\Models\Data\Topics\Something\SomethingElse
Eloquent? ??? ?? ? MorphMap
? ?? FAQ
?? morphTo
morphMany
?? morphOne
<code>albums
id - integer
name - string
songs
id - integer
title - string
album_id - integer
upvotes
id - integer
upvoteable_id - integer
upvoteable_type - string
</code>
??? ??? ?? ???? ????? ?? ?? ???? ? ???? ???? ????? ? ??? ? ????. ?? ?? ???????? ??? ?? ?? ??? ?? ??? ?????. <code>php artisan make:model Album -m
php artisan make:model Song -m
php artisan make:model Upvote -m
</code>
???? ???? ??? ???? ?? ???? ??? ? ????. ?? ??, ????? ?? ??? ????? ??? ?? ? ? ????.
associate
public function up()
{
Schema::create('albums', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}
???? ?????.
??? ????
?
? ??? ???? ??? ??? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











TOSECURELYHANDLEAUSTENCENDACTIONANDACTERIZINGINPHP, FORCUCTSESTEPS : 1. ALWAYSHASHPASSWORTHPASSWORD_HASH () ? VERVERIFYUSINGPANSWORD_VERIFY (), usePREPAREDSTATEMENTSTOPREVENTSQLINGERGED, andSTOREUSERSESSEATAIN $ _SESSIONSAFTERLOGIN.2.impleplempletrole ?? ACCESSC

PHP?? ?? ???? ???? ????? ??? ?? ??? ???? ?? ??? ??? ??? ???? ????. 1. finfo_file ()? ???? ?? ?? ??? ???? ???/jpeg? ?? ?? ?? ? ?????. 2. uniqid ()? ???? ??? ?? ??? ???? ? Web ?? ????? ??????. 3. php.ini ? html ??? ?? ?? ??? ???? ???? ??? 0755? ?????. 4. Clamav? ???? ???? ???? ??? ??????. ??? ??? ?? ???? ????? ???? ?? ??? ????? ???? ??? ? ??? ?????.

PHP?? ==? ==? ?? ???? ?? ??? ??????. == ?? ??? ?? ?? ?????. ?? ??, 5 == "5"? true? ????, ?? ??? ???? ?? ?? ??? ????? ????? (? : 5 === "5"? false? ?????. ?? ?????? ===? ? ???? ?? ?????? == ?? ??? ??? ???? ?????.

PHP?? ?? ??? ??? ???? ??? ??? ????. 1. ?? ??? ?? ? ?? ??? ??? ???? ???? ??? ? ????. ??? ??? ???? ????? ????? ???? ????. 2. ?? ?? ?? - ??, ??? ???? ?? ??? ?????. 3. ?? ???? ??? ??? ???? ??? ??? ?????. 4. Division? / ??? ???? 0?? ??? ?? ????? ??? ?? ??? ?? ? ? ????. 5. ???? ??? ???? ?? ?? ? ?? ??? ???? ? ??? ? ???, ??? ?? ? ? ??? ??? ???? ?????. ? ???? ???? ???? ??? ??? ??? ???? ?? ??? ? ??????? ????.

?, PHP? ?? ?? ?? ?????? ?? MongoDB ? Redis? ?? NOSQL ??????? ?? ??? ? ????. ?? MongoDBPHP ???? (PECL ?? Composer? ?? ??)? ???? ????? ????? ??? ?????? ? ???? ????? ??, ??, ?? ? ?? ??? ?????. ??, Predis ????? ?? Phpredis ??? ???? Redis? ???? ?? ? ?? ? ??? ???? ??? ????? Phpredis? ???? ?? Predis? ?? ??? ?????. ? ? ?? ??? ???? ? ????? ????.

tostaycurrentwithphpdevelopments ? bestpractices, followkeynewssources lifephp.netandphpweekly, adgytwithcommunitiesonforumsandconferences, readlingupdated andgrad indewfeatures, andreadorcontributetoopensourceproceprosts.first

phpbecamepupularforwebdevelopmentduetoiteofleneflening, whithhtml, wididepreadhostingsupport, andalargeecosystemincludingframeworkslikelaravelandcmsplatformsformslikewordpress.itexcelsinhandlingformsubmissions, managingussess, interptisussivers, ?? ???

TOSETTHERIGHTTIMEZONEINPHP, usedate_default_timezone_set () functionattStartOfyourscriptwitHavalidInlifiersuchas'America/new_york'.1.edate_default_timezone_set () beforeanydate/timeFunctions.2
