定制 skybluesofa/laravel-microblog 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

skybluesofa/laravel-microblog

Composer 安装命令:

composer require skybluesofa/laravel-microblog

包简介

This package creates the ability to create micro blog posts for Eloquent Users.

README 文档

README

Build Status Code Climate Test Coverage Total Downloads Version Software License

Laravel 5 Microblog

Create a microblogging platform (e.g., Twitter, Tumblr).

Installation

First, install the package through Composer.

composer require skybluesofa/laravel-microblog

The service provider should be automatically installed on Laravel 5.5+. If you are running a lesser verion, then include the service provider inside config/app.php.

'providers' => [
    ...
    Skybluesofa\Microblog\ServiceProvider::class,
    ...
];

Publish config and migrations

php artisan vendor:publish --provider="Skybluesofa\Microblog\ServiceProvider"

Configure the published config in

config\microblog.php

Finally, migrate the database

php artisan migrate

Add Authorship to a User

When a User is a MicroblogAuthor, they can create blog posts.

use Skybluesofa\Microblog\Model\Traits\MicroblogAuthor;
class User extends Model
{
    use MicroblogAuthor;
    ...
}

Add Blog Friends to a User

The getBlogFriends() method allows for limiting who can see a User's blog posts.

The Skybluesofa\Microblog\Model\Traits\MicroblogFriends Trait enforces that this method exists on the User model, but does not implement it. You'll need to do that however you see fit. Below is an example:

use Skybluesofa\Microblog\Model\Traits\MicroblogFriends;
class User extends Model
{
    use MicroblogFriends;
    
    ...
    public function getBlogFriends()
    {
        // Return null to get all users
        return null;
    
        // Return an array to get specific user ids
        // return [1,2,3];
    
        // Return an empty array to get no user ids (no one else)
        //return [];
    }
    ...
}

How to use

Check the Test file to see the package in action

Blog posts

Create a blog post

The savePost() method will create the associated Journal model, if it doesn't exist for the User.

$post = new Post;
$post->content = 'This is the story of my life';
$user->savePost($post);

Delete a blog post

$post->delete();

Publish a blog post (move from draft to published status)

$post->publish();

Unpublish a blog post (move from published to draft status)

$post->unpublish();

Make a post visible to friends

$post->share();

or

$post->shareWithFriends();

Make a post visible to everyone who has the URL

$post->shareWithEveryone();

Contributing

See the CONTRIBUTING guide.

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固