When dealing with validation rules that check against a database like exists and unique, you should use the fully-qualified namespace (FQN) of the model instead of the table name. The Orbit version adds in the necessary hooks to perform file system operations as well as ensure you don't completely delete your content. This trait uses the Eloquent one under-the-hood, so you can still access all of your normal SoftDeletes methods, including isForceDeleting() and forceDelete(). If you want to add soft delete support to your Orbit model, you can instead use the Orbit\Concerns\SoftDeletes trait. Since Orbit needs to update files on disk when your model is updated, the standard Eloquent SoftDeletes trait doesn't quite work. Be sure to rename your files afterwards so that Orbit doesn't create duplicate content. ? Changing the key for a model after records already exist can cause damage. a Post with the slug hello-world will write to the content/posts/hello-world.md file. Standard Orbit drivers will respect the new key name and use that when creating, updating and deleting files on disk, e.g. If your model's primary key (the key you defined in getKeyName) doesn't need to automatically increment, you should either define public $incrementing = false on the model or overwrite the getIncrementing method. Overwrite the Model::getKeyName method and return the name of your new model. Just like a normal Eloquent model, you can change the primary key of your Orbit model. The driver is then responsible for performing the necessary file system calls. If you wish to change the name of the folder, overwrite the public static function getOrbitalName method on your model class and return the old name instead.Īny time you call Model::create(), Model::update or Model::delete, Orbit will intercept those calls and forward to the necessary driver method. ? Changing the name of a model will prevent Orbit from finding any existing records in the old folder. Post -> content/posts, PostCategory => content/post_categories. Orbit will transform the base name of your model into a pluralized snake-cased string and use that as the main folder name, e.g. If you wish to change this, publish the orbit.php configuration file and change the option. Storing contentīy default, all content is stored inside of a content folder in the root of your application. If some of your data is optional, make sure the corresponding column is nullable. Public static function schema( Blueprint $table) Use Illuminate\ Database\ Schema\ Blueprint
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |