Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add make:cast command #99

Merged

Conversation

jorgemudry
Copy link
Collaborator

What does this Pull Request Do?

It adds the make:cast command.

How should this be manually tested?

  1. Add the fork to your composer.json file:
    "require": {
        "php": "^7.3|^8.0",
        "laravel/lumen-framework": "^8.0",
        "flipbox/lumen-generator": "dev-feature_add_make_cast_command"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/jorgemudry/lumen-generator"
        }
    ]
  1. Install the package:
$ composer update flipbox/lumen-generator;
  1. Use the make:cast command:
$ php artisan make:cast MyCast
  1. You should end up with a MyCast.php class in your app/Casts directory looking like this:
<?php

namespace App\Casts;

use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class MyCast implements CastsAttributes
{
    /**
     * Cast the given value.
     *
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @param  string  $key
     * @param  mixed  $value
     * @param  array  $attributes
     * @return mixed
     */
    public function get($model, $key, $value, $attributes)
    {
        return $value;
    }

    /**
     * Prepare the given value for storage.
     *
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @param  string  $key
     * @param  array  $value
     * @param  array  $attributes
     * @return mixed
     */
    public function set($model, $key, $value, $attributes)
    {
        return $value;
    }
}

Any background context you want to provide?

N/A

Any extra info?

excited

@aqidd aqidd merged commit 302d2fd into flipboxstudio:develop Dec 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants