PHP code example of gaoj87 / laravel-crud-generator

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

    

gaoj87 / laravel-crud-generator example snippets




namespace XXX;

use Illuminate\Database\Eloquent\Model;

/**
 * This is the model class for table "users".
 * @property integer $id
 * @property integer $mid
 * @property string $real_name
 * @property string $mobile
 * @property string $created_at
 * @property string $updated_at
 */
class Users extends Model
{
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'users';

    /**
     * The primary key for the model.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * The name of the "created at" column.
     *
     * @var string
     */
    const CREATED_AT = 'created_at';

    /**
     * The name of the "updated at" column.
     *
     * @var string
     */
    const UPDATED_AT = 'updated_at';

    /**
     * Attributes that should be mass-assignable.
     *
     * @var array
     */
    protected $fillable = [
        'mid',
        'real_name',
        'mobile',
    ];


    /**
     * Returns the text label for the specified attribute or all attribute labels.
     * @param string $key the attribute name
     * @return array|string the attribute labels
     */
    public static function attributeLabels($key = null)
    {
        $data = [
            'id' => 'Id',
            'mid' => 'Mid',
            'real_name' => 'Real Name',
            'mobile' => 'Mobile',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];

        if ($key !== null) {
            return isset($data[$key]) ? $data[$key] : null;
        } else {
            return $data;
        }
    }

}


php composer.phar 
Shell
➜  php artisan  crud-model Models/Users --table=users --prefix=