How to resolve Laravel php artisan migrate Undefined table: 7 ERROR: relation does not exist

create a new database test002 $ php artisan migrate Illuminate\Database\QueryException : SQLSTATE[42P01]: Undefined table: 7 ERROR: relation “extractees” does not exist Exception trace: 1 App\Console\Commands\ImportCsvFile::__construct() => Means something wrong is here ImportCsvFile after fix above issue, new error happened: $ php artisan migrate Illuminate\Database\QueryException : SQLSTATE[42P01]: Undefined table: 7 ERROR: relation “users” does not exist …

How to generate migration and seed for exists database tables in Laravel

“orangehill/iseed”: “dev-master”, => generate seed for exists database tables in Laravel “xethron/migrations-generator”: “^2.0” generate migration for exists database tables in Laravel https://github.com/orangehill/iseed example: php artisan iseed table1,table2,table3 –max=5000 –exclude=id,created_at,updated_at php artisan iseed users,permission_role,permissions,roles,user_roles –force https://github.com/Xethron/migrations-generator generate migration for all exists database tables: To generate migrations from a database, you need to have your database setup …

How to create a postgresql database view for same table join on same column to get the latest record

How to create a postgresql database view(table_view) for same table(same_table) join on same column(someid) to get the latest record max(a.id) CREATE OR REPLACE VIEW table_view AS SELECT i.id,i.created_at AS time_in,i.action AS action_in,i.alert_msg AS alert_in, o.created_at AS time_out,o.action AS action_out,o.alert_msg AS alert_out FROM same_table i INNER JOIN same_table o ON i.someid = o.someid WHERE i.id IN …

How to send json data request to api use Postman or Swager

In postman: Set header Content-Type to application/json Set body request type to raw, content must be json format, eg. { “msg”:{“address”: {“street”: “end”, “number”: 31, “road”: 2, “suburb”: “hillcrest”}, “price”: 23380,”on_market_time”: “2018-09-03T19:42:19.296591”} } In Swager: By default, the Content-Type is already set to application/json Set body value must be json format, eg. { “msg”:{“address”: {“street”: …

How to use laravel Repository Pattern to handle database logic by override create() method

use InfyOm\Generator\Common\BaseRepository; class xxxRepository extends BaseRepository { public function create(array$attributes) { // dd($attributes); // only for debug if (!isset($attributes[‘msg’]) || strpos($attributes[‘msg’], ‘}’) === false) { $rs = parent::create($attributes); } else { $analyze_data = $this->analyze($attributes); if (is_object($analyze_data) && isset($analyze_data->site_id)) { $attributes[‘site_id’] = $analyze_data->site_id; } $rs = parent::create($attributes); $rs->mqtt_action_msg = $analyze_data; } return$rs; }

How to subscribe MQTT message in mac

Mosquitto can be installed from the homebrew project. See brew.sh and then use brew install mosquitto $ mosquitto_sub -h 10.0.2.1 -t “#” -d Client mosqsub|xx-mac received PUBLISH (d0, q0, r1, m0, ‘line-1/xx/topicname’, … (216 bytes)) {“xx”: {“xx”: “xx”, “xx”: 1, “xx”: 1, “xx”: “xxweigh-scale”}, “xx”: 820, “xx”: “235325”, “timestamp”: “2018-08-30T19:42:19.296591”, “xx”: true}

How to modify or change input data before form request validation

How to modify or change input data before form request validation? Solution: Override the prepareForValidation() method of the FormRequest So in the form request file: class CreateAbcdefgRequest extends APIRequest { protected function prepareForValidation() { if ($this->has(‘first_name’)) $this->merge([‘first_name’=>’Mr ‘.$this->first_name]); } As of laravel 5.4 you can override the prepareForValidation method of the ValidatesWhenResolvedTrait to modify any input. Something similar should …

Connect to MQTT server with WILL via PHP

In MQTT, you use the Last Will and Testament (LWT) feature to notify other clients about an ungracefully disconnected client. Each client can specify its last will message when it connects to a broker. The last will message is a normal MQTT message with a topic, retained message flag, QoS, and payload. The broker stores …