Once the action has been attached to the field, you will be able to select the action and execute it from the relationship index on the parent resource’s detail page.To learn more about Nova actions, check out
along with a "Revoke" button, within an "account settings" portion of your web application's UI. When the user clicks the "Revoke" button, you can delete the token from the database. Remember, you can access a user's API tokens via the tokens relationship provided by the Laravel\Sanctum...
A one-to-many relationship is used to define relationships where a single model is the parent to one or more child models. For example, a blog post may have an infinite number of comments. Like all other Eloquent relationships, one-to-many relationships are defined by defining a method on...
You may also come across situations where you want to update an existing model or create a new model if none exists. Laravel provides an updateOrCreate method to do this in one step. Like the firstOrCreate method, updateOrCreate persists the model, so there's no need to call save():...
永远不要在未检测关联是否存在的情况下使用 $model->relationship->field。 It may be deleted for whatever reason, outside your code, by someone else's queued job etc. 可以通过 if-else,在 Blade 中使用 {{ $model->relationship->field ?? '' }}, 或者 {{ optional($model->relationship)->field...
You may also come across situations where you want to update an existing model or create a new model if none exists. Laravel provides an updateOrCreate method to do this in one step. Like the firstOrCreate method, updateOrCreate persists the model, so there's no need to call save():...
{ return array_key_exists($key, $this->relations); } 可以看到,关联的加载带有缓存,laravel 首先会验证当前关联关系是否已经被加载,如果加载过,那么直接返回缓存结果。 protected function getRelationshipFromMethod($method) { $relation = $this->$method();if...
You may also come across situations where you want to update an existing model or create a new model if none exists. Laravel provides an updateOrCreate method to do this in one step. Like the firstOrCreate method, updateOrCreate persists the model, so there's no need to call save():...
// check album slider dir is exists if (!Storage::disk('public')->exists('photo/slider')) { Storage::disk('public')->makeDirectory('photo/slider'); } // resize image for album slider and upload $slider = Image::make($image)->resize(500,333)->stream(); Storage::disk('public')...
Illuminate\Bus\Events Illuminate\Cache Illuminate\Cache\Console Illuminate\Cache\Events Illuminate\Cache\RateLimiting Illuminate\Concurrency Illuminate\Concurrency\Console Illuminate\Config Illuminate\Console Illuminate\Console\Concerns Illuminate\Console\Contracts Illuminate\Console\Events Illuminate\Console\Scheduling ...