{"id":188,"date":"2022-01-06T17:49:23","date_gmt":"2022-01-06T08:49:23","guid":{"rendered":"https:\/\/software.satoshis.jp\/?p=188"},"modified":"2022-02-04T17:45:58","modified_gmt":"2022-02-04T08:45:58","slug":"laravel%e3%81%8b%e3%82%89db%e3%81%ab%e6%a0%bc%e7%b4%8d%e3%81%99%e3%82%8b%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e6%9a%97%e5%8f%b7%e5%8c%96%e3%83%bb%e5%be%a9%e5%8f%b7%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/software.satoshis.jp\/?p=188","title":{"rendered":"Laravel\u304b\u3089DB\u306b\u683c\u7d0d\u3059\u308b\u30c7\u30fc\u30bf\u3092\u6697\u53f7\u5316\u30fb\u5fa9\u53f7\u3059\u308b\u65b9\u6cd5\u3068\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306eunique\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u554f\u984c"},"content":{"rendered":"<p> Laravel\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30c7\u30fc\u30bf\u3092\u6697\u53f7\u5316\u3057\u3066\u683c\u7d0d\u3059\u308b\u65b9\u6cd5\u3068\u3001\u6697\u53f7\u5316\u3057\u305f\u30c7\u30fc\u30bf\u3092\u81ea\u52d5\u7684\u306b\u8907\u5408\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u3044\u308d\u3044\u308d\u3068\u3050\u3050\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p> \u3044\u308d\u3044\u308d\u306a\u3084\u308a\u65b9\u304c\u3042\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u65b9\u6cd5\u304c\u3088\u3055\u3052\u3060\u3063\u305f\u306e\u3067\u3001\u63a1\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n<p> \u305d\u306e\u65b9\u6cd5\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p> \u307e\u305a\u306f\u3001\u6697\u53f7\u5316\u3057\u305f\u308a\u5fa9\u53f7\u3057\u305f\u308a\u3059\u308b\u305f\u3081\u306e\u3001Encryptable\u3068\u3044\u3046\u30c8\u30ec\u30a4\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Support\\Facades\\Crypt;\r\n\r\ntrait Encryptable\r\n{\r\n    public function getAttribute($key)\r\n    {\r\n        $value = parent::getAttribute($key);\r\n        if (in_array($key, $this-&gt;encryptable)) {\r\n            $value = Crypt::decrypt($value);\r\n        }\r\n        return $value;\r\n    }\r\n\r\n    public function setAttribute($key, $value)\r\n    {\r\n        if (in_array($key, $this-&gt;encryptable)) {\r\n            $value = empty($value) ? '' : $value;\r\n            $value = Crypt::encrypt($value);\r\n        }\r\n        return parent::setAttribute($key, $value);\r\n    }\r\n}\r\n<\/pre>\n<p> \u5024\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408(empty)\u306f\u3001\u7a7a\u6587\u5b57\u5217\u3068\u3057\u3066\u53d6\u308a\u6271\u3044\u307e\u3059\u3002<br \/>\n \u500b\u4eba\u60c5\u5831\u3068\u307f\u306a\u3055\u308c\u308b\u30c7\u30fc\u30bf\u306f\u3001\u4f4f\u6240\u3001\u6c0f\u540d\u3001\u96fb\u8a71\u756a\u53f7\u306a\u3069\u3001\u3069\u308c\u3082\u6587\u5b57\u5217\u578b\u306a\u306e\u3067\u3001\u554f\u984c\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p> \u3053\u306eEncryptable\u30c8\u30ec\u30a4\u30c8\u3092\u3001\u6697\u53f7\u5316\u3057\u305f\u3044\u30e2\u30c7\u30eb\u306b\u9069\u7528\u3057\u3066\u3084\u308a\u307e\u3059\u3002<br \/>\n \u305d\u3057\u3066\u3001\u6697\u53f7\u5316\u3057\u305f\u3044\u30ab\u30e9\u30e0\u3092 $encryptable \u914d\u5217\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p> \u4ee5\u4e0b\u306f\u3001Laravel\u3067\u6a19\u6e96\u7684\u306b\u4f7f\u7528\u3055\u308c\u308b\u3001\u30ed\u30b0\u30a4\u30f3\u60c5\u5831\u3092\u4fdd\u6301\u3059\u308b\u305f\u3081\u306e User \u30af\u30e9\u30b9\u3067\u306f email \u3092\u6697\u53f7\u5316\u306e\u5bfe\u8c61\u3068\u3057\u307e\u3059\u3002<\/p>\n<p> \u30ed\u30b0\u30a4\u30f3\u3059\u308b\u3068\u304d\u306b\u306f\u3001name \u3068 password \u3067\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u30b7\u30b9\u30c6\u30e0\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u3001name \u3092\u6697\u53f7\u5316\u3057\u3066\u3057\u307e\u3046\u3068\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n<p> \u306a\u306e\u3067\u3001\u3082\u3057\u304b\u3059\u308b\u3068\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3067\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u65b9\u5f0f\u3092\u63a1\u7528\u3057\u3066\u3044\u308b\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u6697\u53f7\u5316\u3059\u308b\u3068\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u306a\u304f\u306a\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u3053\u3053\u306f\u78ba\u8a8d\u3057\u3066\u307e\u305b\u3093\u306e\u3067\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3067\u30ed\u30b0\u30a4\u30f3\u3055\u305b\u308b\u4eba\u306f\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u6697\u53f7\u5316\u3057\u3066\u3082\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u308b\u304b\u3069\u3046\u304b\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\uff08\u3067\u304d\u306a\u3055\u305d\u3046\u306a\uff09\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Contracts\\Auth\\MustVerifyEmail;\r\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\r\nuse Illuminate\\Notifications\\Notifiable;\r\nuse Spatie\\Permission\\Traits\\HasRoles;\r\n\r\nuse App\\Notifications\\PasswordReset;\r\nuse App\\Encryptable;\r\n\r\nclass User extends Authenticatable implements MustVerifyEmail\r\n{\r\n    use Notifiable;\r\n    use HasRoles;\r\n    use Encryptable;\r\n\r\n    protected $fillable = &#x5B;\r\n        'name', 'email', 'password',\r\n    ];\r\n\r\n    protected $hidden = &#x5B;\r\n        'password', 'remember_token',\r\n    ];\r\n\r\n    public $encryptable = &#x5B; \r\n        'email'\r\n    ];\r\n\r\n    protected $casts = &#x5B;\r\n        'email_verified_at' =&gt; 'datetime',\r\n    ];\r\n\r\n    public function sendPasswordResetNotification($token)\r\n    {\r\n        $this-&gt;notify(new PasswordReset($token));\r\n    }\r\n}\r\n<\/pre>\n<p> \u4ee5\u4e0b\u306f Member \u30af\u30e9\u30b9\u3067\u3059\u3002Member\u30af\u30e9\u30b9\u306f\u3001User\u3068\u7d10\u4ed8\u3051\u3066\u4f1a\u54e1\u60c5\u5831\u3092\u7ba1\u7406\u3059\u308b\u305f\u3081\u306e\u30af\u30e9\u30b9\u3067\u3001\u4f1a\u54e1\u306e\u6c0f\u540d\u3084\u90f5\u4fbf\u756a\u53f7\u3001\u4f4f\u6240\u3001\u96fb\u8a71\u756a\u53f7\u3092\u4fdd\u6301\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001id\u4ee5\u5916\u306e\u3059\u3079\u3066\u3092\u6697\u53f7\u5316\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nuse Carbon\\Carbon;\r\nuse App\\Encryptable;\r\n\r\nclass Member extends Model\r\n{\r\n    use HasFactory;\r\n    use Encryptable;\r\n\r\n    protected $guarded = &#x5B; 'id' ];\r\n    public $encryptable = &#x5B;\r\n        'name', 'zip', 'address1', 'address2', 'phone',\r\n    ];\r\n}\r\n<\/pre>\n<p> \u3061\u306a\u307f\u306b\u3001User \u30af\u30e9\u30b9\u306f\u5b89\u5b9a\u3057\u3066\u3044\u308b\u306e\u3067 fillable \u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u30b7\u30b9\u30c6\u30e0\u306b\u3088\u3063\u3066\u4fdd\u6301\u3059\u308b\u60c5\u5831\u304c\u7570\u306a\u308b\u3053\u3068\u304c\u591a\u3044\u4f1a\u54e1\u60c5\u5831\u306b\u5bfe\u5fdc\u3059\u308b Member \u30af\u30e9\u30b9\u306b\u3064\u3044\u3066\u306f fillable \u3067\u306f\u306a\u304f guarded \u3067 id \u3060\u3051\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002fillable \u3092\u4f7f\u3063\u3066\u3044\u308b\u3068\u3001\u30ab\u30e9\u30e0\u3092\u8ffd\u52a0\u3057\u305f\u306e\u306b fillable \u306b\u30ab\u30e9\u30e0\u540d\u3092\u8ffd\u52a0\u3057\u5fd8\u308c\u3066\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3067\u304d\u306a\u3044\u3068\u3044\u3046 Laravel\u3042\u308b\u3042\u308b\u554f\u984c\u3092\u56de\u907f\u3067\u304d\u307e\u3059\u3002<\/p>\n<p> \u3053\u308c\u3067\u3001\u500b\u4eba\u60c5\u5831\u3092\u6697\u53f7\u5316\u3057\u3066\u683c\u7d0d\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p> \u3053\u3053\u3067\u6ce8\u610f\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p> \u6697\u53f7\u5316\u3057\u305f\u30c7\u30fc\u30bf\u306f\u3001\u5143\u306e\u6587\u5b57\u5217\u306e\u4f55\u500d\u3082\u306e\u9577\u3055\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p> \u4e00\u65b9\u3001Laravel\u3067\u4f5c\u6210\u3057\u305fmigration\u5185\u3067\u6697\u53f7\u5316\u5bfe\u8c61\u306e\u30ab\u30e9\u30e0\u3092string\u578b\u3067\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u3068\u3001\u9577\u3055\u304c\u4e0d\u8db3\u3057\u3066\u5fa9\u53f7\u3067\u304d\u305a\u306bDecryptException\u304c\u767a\u751f\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p> \u6700\u521d\u304b\u3089text\u578b\u3067\u4f5c\u3063\u3066\u3044\u308c\u3070\u3044\u3044\u306e\u3067\u3059\u304c\u3001string\u578b\u3067\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u6697\u53f7\u5316\u5bfe\u8c61\u306e\u30ab\u30e9\u30e0\u304c\u3042\u308b\u306e\u306a\u3089\u3070\u3001text\u578b\u306b\u5909\u66f4\u3059\u308bmigration\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nuse Illuminate\\Database\\Migrations\\Migration;\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Support\\Facades\\Schema;\r\n\r\nclass AlterMembersTable extends Migration\r\n{\r\n    \/**\r\n     * Run the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function up()\r\n    {\r\n        Schema::table('members', function (Blueprint $table) {\r\n            $table-&gt;text('name')-&gt;change();\r\n            $table-&gt;text('address1')-&gt;change();\r\n            $table-&gt;text('address2')-&gt;change();\r\n            $table-&gt;text('phone')-&gt;change();\r\n        });\r\n    }\r\n\r\n    \/**\r\n     * Reverse the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function down()\r\n    {\r\n        Schema::table('members', function (Blueprint $table) {\r\n            $table-&gt;string('name', 255)-&gt;change();\r\n            $table-&gt;string('address1', 255)-&gt;change();\r\n            $table-&gt;string('address2', 255)-&gt;change();\r\n            $table-&gt;string('phone', 255)-&gt;change();\r\n        });\r\n    }\r\n}\r\n<\/pre>\n<p> \u3053\u308c\u3067\u3001\u500b\u4eba\u60c5\u5831\u306b\u95a2\u3059\u308b\u30c7\u30fc\u30bf\u3092\u3059\u3079\u3066\u6697\u53f7\u5316\u3057\u3066\u4fdd\u5b58\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p> \u304c\u3001\u3055\u3089\u306b\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<p> \u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6642\u306b\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u767b\u9332\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u6697\u53f7\u5316\u3057\u306a\u3044\u5834\u5408\u306f\u3053\u3061\u3089\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3067\u3046\u307e\u304f\u30c1\u30a7\u30c3\u30af\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n            'email' =&gt; &#x5B;'required', 'string', 'email:strict,dns', 'max:255', 'unique:users'],\r\n<\/pre>\n<p> \u300cunique:users\u300d\u306b\u3088\u3063\u3066\u3001\u767b\u9332\u6e08\u307f\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3060\u3063\u305f\u3089\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u306b\u306a\u308b\u306e\u3067\u3059\u3002<\/p>\n<p> \u3057\u304b\u3057\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u6697\u53f7\u5316\u3057\u3066\u683c\u7d0d\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u3053\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u30c1\u30a7\u30c3\u30af\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p> \u683c\u7d0d\u3057\u305f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u5fa9\u53f7\u3057\u3066\u6bd4\u8f03\u3059\u308b\u306e\u304c\u624b\u3063\u53d6\u308a\u65e9\u3044\u3067\u3059\u3002<\/p>\n<p> Varidator\u306e\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3001\u305d\u306e\u30af\u30e9\u30b9\u3067\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p> \u3059\u3079\u3066\u306e\u767b\u9332\u6e08\u307f\u30e6\u30fc\u30b6\u30fc\u3092\u53d6\u5f97\u3057\u3066\u3001\u7dcf\u5f53\u305f\u308a\u3067\u6bd4\u8f03\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Rules;\r\n\r\nuse Illuminate\\Contracts\\Validation\\Rule;\r\nuse App\\User;\r\n\r\nclass EmailUniqueValidator implements Rule\r\n{\r\n    \/**\r\n     * Create a new rule instance.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function __construct()\r\n    {\r\n        \/\/\r\n    }\r\n\r\n    \/**\r\n     * Determine if the validation rule passes.\r\n     *\r\n     * @param  string  $attribute\r\n     * @param  mixed  $value\r\n     * @return bool\r\n     *\/\r\n    public function passes($attribute, $value)\r\n    {\r\n        $users = User::all();\r\n        foreach($users as $u) {\r\n            $email = $u-&gt;email;\r\n            if ($email == $value) {\r\n                return false;\r\n            }\r\n        }\r\n        return true;\r\n    }\r\n\r\n    \/**\r\n     * Get the validation error message.\r\n     *\r\n     * @return string\r\n     *\/\r\n    public function message()\r\n    {\r\n        return '\u3053\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306f\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002';\r\n    }\r\n}\r\n<\/pre>\n<p> \u305d\u3057\u3066\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u90e8\u5206\u306f\u3001\u6b21\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n            'email' =&gt; &#x5B;'required', 'string', 'email:strict,dns', 'max:255', new EmailUniqueValidator, ],\r\n<\/pre>\n<p> \u3057\u304b\u3057\u3001\u3084\u306f\u308a\u8ca0\u8377\u304c\u6c17\u306b\u306a\u308a\u307e\u3059\u3002\u4f1a\u54e1\u767b\u9332\u6570\u304c\u5897\u3048\u308c\u3070\u5897\u3048\u308b\u307b\u3069\u767b\u9332\u6642\u306e\u4e00\u6642\u7684\u306a\u8ca0\u8377\u304c\u5897\u3048\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p> \u5168\u30e6\u30fc\u30b6\u30fc\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u305b\u305a\u306b\u3001\u308f\u305a\u304b\u306a\u30c7\u30fc\u30bf\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p> \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306b\u5bfe\u3057\u3066md5\u306e\u30cf\u30c3\u30b7\u30e5\u5024\u3092\u751f\u6210\u3057\u3066\u3001\u305d\u306e\u30cf\u30c3\u30b7\u30e5\u5024\u3092\u66f8\u304d\u8fbc\u3080\u30ab\u30e9\u30e0\u3092\u4f5c\u308a\u3001\u683c\u7d0d\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p> \u65b0\u898f\u767b\u9332\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u30cf\u30c3\u30b7\u30e5\u5024\u3067\u30af\u30a8\u30ea\u3057\u305f\u7d50\u679c\u3068\u7167\u5408\u3059\u308c\u3070\u3001\u305f\u307e\u305f\u307e\u5947\u8de1\u7684\u306b\u30cf\u30c3\u30b7\u30e5\u5024\u304c\u4e00\u81f4\u3059\u308b\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u3042\u3063\u305f\u3068\u3057\u3066\u30820\u500b\u3067\u3057\u3087\u3046\u3002Facebook\u4e26\u306e\u30e6\u30fc\u30b6\u30fc\u6570\u304c\u3044\u305f\u3068\u3057\u3066\u3082\u3001\u540c\u4e00\u306e\u30cf\u30c3\u30b7\u30e5\u5024\u3092\u6301\u3064\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c1\u500b\u898b\u3064\u304b\u308b\u3053\u3068\u306f\u3042\u308a\u5f97\u306a\u3044\u78ba\u7387\uff081\/2<sup>128<\/sup>\uff09\u306a\u306e\u3067\u3002\uff08\u8a73\u3057\u304f\u306fmd5\u3092\u3050\u3050\u3063\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<pre class=\"brush: php; highlight: [3,4]; title: ; notranslate\" title=\"\">\r\n    public function passes($attribute, $value)\r\n    {\r\n        $md5 = md5($value);\r\n        $users = User::where('md5', $md5)-&gt;get();\r\n        foreach($users as $u) {\r\n            $email = $u-&gt;email;\r\n            if ($email == $value) {\r\n                return false;\r\n            }\r\n        }\r\n        return true;\r\n    }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30c7\u30fc\u30bf\u3092\u6697\u53f7\u5316\u3057\u3066\u683c\u7d0d\u3059\u308b\u65b9\u6cd5\u3068\u3001\u6697\u53f7\u5316\u3057\u305f\u30c7\u30fc\u30bf\u3092\u81ea\u52d5\u7684\u306b\u8907\u5408\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u3044\u308d\u3044\u308d\u3068\u3050\u3050\u3063\u3066\u307f\u307e\u3057\u305f\u3002 \u3044\u308d\u3044\u308d\u306a\u3084\u308a\u65b9\u304c\u3042\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u65b9\u6cd5\u304c\u3088\u3055\u3052\u3060\u3063 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":63,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[67,64,69,68,14,65,66,63,62,70,61],"class_list":["post-188","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-crypt","tag-db","tag-decrypt","tag-encrypt","tag-laravel","tag-string","tag-text","tag-trait","tag-62","tag-70","tag-61"],"nelio_content":{"autoShareEndMode":"never","automationSources":{"useCustomSentences":false,"customSentences":[]},"efiAlt":"","efiUrl":"","followers":[1],"highlights":[],"isAutoShareEnabled":true,"networkImageIds":[],"permalinkQueryArgs":[],"series":[],"suggestedReferences":[]},"views":5942,"_links":{"self":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":7,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":214,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/214"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/media\/63"}],"wp:attachment":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}