https://github.com/skybluesofa/laravel-microblog
Create a microblogging platform (e.g., Twitter, Tumblr).
https://github.com/skybluesofa/laravel-microblog
blog laravel-package microblog tumblr-like twitter-like
Last synced: 4 months ago
JSON representation
Create a microblogging platform (e.g., Twitter, Tumblr).
- Host: GitHub
- URL: https://github.com/skybluesofa/laravel-microblog
- Owner: skybluesofa
- License: mit
- Created: 2016-11-30T19:35:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-11-17T04:32:59.000Z (over 2 years ago)
- Last Synced: 2025-01-04T18:29:04.017Z (5 months ago)
- Topics: blog, laravel-package, microblog, tumblr-like, twitter-like
- Language: PHP
- Homepage:
- Size: 298 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/skybluesofa/laravel-microblog) [](https://codeclimate.com/github/skybluesofa/laravel-microblog) [](https://codeclimate.com/github/skybluesofa/laravel-microblog/coverage) [](https://packagist.org/packages/skybluesofa/laravel-microblog) [](https://packagist.org/packages/skybluesofa/laravel-microblog) [](LICENSE)
# Laravel 5 Microblog
Create a microblogging platform (e.g., Twitter, Tumblr).
## Installation
First, install the package through Composer.
```php
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`.
```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.
```php
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:
```php
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](https://github.com/skybluesofa/laravel-microblog/blob/master/tests/Unit/MicroblogPostBasicTest.php)### Blog posts
#### Create a blog post
The savePost() method will create the associated Journal model, if it doesn't exist for the User.
```php
$post = new Post;
$post->content = 'This is the story of my life';
$user->savePost($post);
```#### Delete a blog post
```php
$post->delete();
```#### Publish a blog post (move from draft to published status)
```php
$post->publish();
```#### Unpublish a blog post (move from published to draft status)
```php
$post->unpublish();
```#### Make a post visible to friends
```php
$post->share();
```
or
```php
$post->shareWithFriends();
```#### Make a post visible to everyone who has the URL
```php
$post->shareWithEveryone();
```## Contributing
See the [CONTRIBUTING](CONTRIBUTING.md) guide.