Hi,
I am new to Laravel and Nova. This workflow package seems to be very useful. But unfortunately, it is not working on my windows environment. Following is the detail of my WAMP configuration:
- Laravel 5.8
- Nova 2.8.0
- PHP 7.3.12
- MySQL 8.0.18
- Apache 2.4.41
Here is the Workflow Configuration File:
<?php
return [
'workflows' => [
'request' => [ // workflow name
'model' => \App\Country::class, //workflow applied to this model
'column' => 'status', // on this column
'states' => [ // the possible statuses
'pending',
'escalated',
'approved',
'rejected',
],
'transitions' => [
'Approve' => [
'from' => ['pending', 'escalated'],
'to' => 'approved',
'event' => \App\Events\SubmissionApproved::class, // fire event
'style_classes' => 'bg-success text-20'
],
'Escalate' => [
'from' => ['pending'],
'to' => 'escalated',
],
'Reject' => [
'from' => ['pending', 'escalated'],
'to' => 'rejected',
'style_classes' => 'bg-danger text-20'
],
'Back to My Employee' => [
'from' => ['escalated'],
'to' => 'pending',
'with_reasons' => 'escalation_note', // display a free textarea to write the comment on the this column name
],
],
],
],
];`
Following is the detail of my table:
CREATE TABLE countries ( country_idint(10) UNSIGNED NOT NULL AUTO_INCREMENT, namevarchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, statusvarchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, created_attimestamp(0) NULL DEFAULT NULL, updated_at timestamp(0) NULL DEFAULT NULL, PRIMARY KEY (country_id) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
Here is the Model:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Laravel\Nova\Fields\HasMany;
use App\State;
class Country extends Model
{
protected $primaryKey = 'country_id';
public function country() {
return $this->belongsTo(self::class, 'country','country_id');
}
public function state() {
return $this->hasMany('App\State', 'state', 'state_id');
}
}
Here is the resource file:
<?php
namespace App\Nova;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\MorphToMany;
use Illuminate\Http\Request;
use Laravel\Nova\Http\Requests\NovaRequest;
use Cammac\Workflow\Fields\Workflow;
class Country extends Resource
{
public static $group = "Locations Formation";
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = 'App\Country';
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'name';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'name',
];
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make('country_id')->sortable(),
Text::make('Name')
->sortable()
->rules('required', 'max:255'),
Workflow::make('request')->onlyOnDetail(),
];
}
/**
* Get the cards available for the request.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function cards(Request $request)
{
return [];
}
/**
* Get the filters available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function filters(Request $request)
{
return [];
}
/**
* Get the lenses available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function lenses(Request $request)
{
return [];
}
/**
* Get the actions available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function actions(Request $request)
{
return [];
}
}
Hi,
I am new to Laravel and Nova. This workflow package seems to be very useful. But unfortunately, it is not working on my windows environment. Following is the detail of my WAMP configuration:
Here is the Workflow Configuration File:
Following is the detail of my table:
Here is the Model:
Here is the resource file: