PHP code example of rumspeed / laravel-notes

1. Go to this page and download the library: Download rumspeed/laravel-notes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rumspeed / laravel-notes example snippets


return [

    /* -----------------------------------------------------------------
     |  Models
     | -----------------------------------------------------------------
     */

    'authors' => [
        'table' => 'users',
        'model' => App\Models\User::class,
    ],

    'notes' => [
        'table' => 'notes',
        'model' => Rumspeed\LaravelNotes\Models\Note::class,
    ],
];

 namespace App;

use Illuminate\Database\Eloquent\Model;
use Rumspeed\LaravelNotes\Traits\HasManyNotes;

class Post extends Model {
    use HasManyNotes;

    // Other stuff ...
}

$post = App\Post::first();
$note = $post->createNote('Hello world #1');

$user = App\User::first();
$post = App\Post::first();
$note = $post->createNote('Hello world #1', $user);

 namespace App;

use Illuminate\Database\Eloquent\Model;
use Rumspeed\LaravelNotes\Traits\HasManyNotes;

class Post extends Model {
    use HasManyNotes;

    // Other stuff ...

    /**
     * Get the current author's id.
     *
     * @return int|null
     */
     protected function getCurrentAuthorId()
     {
         return auth()->id();
     }
}

$post  = App\Post::first();
$notes = $post->notes;

$user = App\User::first();
$post = App\Post::first();
$post->createNote('Hello world #1', $user);

$notes = $user->authoredNotes;

$post = App\Post::first();
$note = $post->findNote(1);
bash
php artisan vendor:publish --tag="notes-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="notes-config"