PHP code example of michal78 / laravel-tasks

1. Go to this page and download the library: Download michal78/laravel-tasks 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/ */

    

michal78 / laravel-tasks example snippets


// Add the HasTasks trait to your model
use Michal78\Tasks\Traits\HasTasks;

class User extends Model
{
    use HasTasks;
}

// Create a task
$user->addTask(
    [
        'name' => 'My task',
        'description' => 'My task description',
        'priority' => 2,
        'due_date' => now()->addDays(7),
    ]
);

// Get all tasks
$user->tasks;

// Get all tasks that are not completed
$user->tasks()->notCompleted()->get();

// Get all tasks that are completed
$user->tasks()->completed()->get();

// Get all tasks that are completed and have a due date in the future
$user->tasks()->completed()->future()->get();