PHP code example of thiagoprz / crud-tools

1. Go to this page and download the library: Download thiagoprz/crud-tools 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/ */

    

thiagoprz / crud-tools example snippets



...
use Thiagoprz\CrudTools\Models\ModelCrud;
class Books extends Model
{
    ...
    
    /**
     * Searching only by the start of the title of the book with LIKE
     */
    public static function searchTitle($query, $title)
    {
        $query->where('title', 'LIKE', "$title%");    
    }

}



php artisan make:crud-model NAMESPACE/Model   
 php artisan make:crud-controller NAMESPACE1/NAMEController NAMESPACE2/Model 

    /**
     * @param $forRedirect
     * @return string
     */
    public function getViewPath($forRedirect = false): string
    {
        return $forRedirect ? 'custom/url' : 'custom.path';
    }