-
-
Notifications
You must be signed in to change notification settings - Fork 92
Model
Asep edited this page Feb 18, 2023
·
2 revisions
Let's start by creating a model
php artisan module:make-model Article --module=Blog
After successfully creating the model, the file will be saved as Modules/Blog/Models/Article.php
folder, see the sample contents below.
namespace Modules\Blog\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
use HasFactory;
protected static function newFactory()
{
return \Modules\Blog\Databases\Factories\ArticleFactory::new();
}
}
By default the factory class \Modules\Blog\Databases\Factories\ArticleFactory
will be created, but if you don't want to create it have it then the newFactory()
method can be removed so that it becomes as below.
namespace Modules\Blog\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
use HasFactory;
}
- #1 Create Module
- #2 Create Menu
- #3 Route
- #4 Create DataTables
- #5 Template Layout
- #6 Create Model
- #7 Create Command
- #8 Create Component
- #9 Broadcast Notification
- #10 Group Search
- #11 Flashing Message
- #12 Compiling Assets (ViteJs)
- #13 Ladmin Option
- #14 Utility & Helpers
- #15 Vendor Publish
- #16 Custom Style
- #17 Ladmin Awesome
- #18 Make Money