SAJDEV/belara

使用belara(laravel博客)让它变得更简单

v0.2 2024-03-12 07:39 UTC

This package is auto-updated.

Last update: 2024-09-24 19:05:22 UTC


README

使用belara(laravel博客)让它变得更简单

Composer安装(适用于Laravel 8+)

composer require sajdev/belara

在你的config/app.php中

'providers' => [
	...
  \SAJDEV\belara\belaraProvider::class
],

发布并运行迁移

php artisan vendor:publish --tag=belaraMigarte 

php artisan migrate

发布供应商(config,public(*),view)

php artisan vendor:publish --tag=belara

php artisan vendor:publish --tag=belaraPublic

php artisan vendor:publish --tag=belaraView

运行你的应用

 php  artisan serve

#默认路由

route('blog.create')

/admin/blog/create

route('blog.edit',['id'=> blogId])

/admin/blog/{id}/edit

route('blog.delete',['id'=>blogId])

/admin/blog/{id}/delete

route('blogCategory.create')

/admin/blogCategory/create

route('blogCategory.edit',['id'=> blogCategoryId])

/admin/blogCategory/{id}/edit

route('blogCategory.delete',['id'=>blogCategoryId])

/admin/blogCategory/{id}/delete

模型

  \SAJDEV\belara\model\Blog

  \SAJDEV\belara\model\BlogCategory

如果在config/belara.php中author为true,则使用此(Models/User.php)

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use SAJDEV\belara\model\Blog;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;
    
    public function blogs()
    {
        return $this->hasMany(Blog::class, 'author', 'id');
    }
}