PHP code example of devniks / blog-curd

1. Go to this page and download the library: Download devniks/blog-curd 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/ */

    

devniks / blog-curd example snippets


use Devniks\BlogCurd\Models\Blog;

$blog = new Blog();
$blog->title = 'My First Blog';
$blog->content = 'This is the content of my first blog.';
$blog->author = 'Nikhil Singhal';
$blog->save();

$blog = Blog::find(1);
$blog->title = 'Updated Blog Title';
$blog->save();

$blog = Blog::find(1);
$blog->delete(); // This will soft delete the blog

use Devniks\BlogCurd\Models\Blog;

$blog = Blog::withTrashed()->find(1);
$blog->restore();

$blogs = Blog::paginate(10); // Fetch 10 blogs per page
sh
php artisan migrate