Thanks @D9705996 and @jekinney , I have taken your advice and used an Eloquent model, no idea why or how, but it works. @jekinney , your diagnosis of my Laravel skills is spot on, this is my first project.
@staudenmeir , I used response($tasks)->original because the array of tasks I was after was in an element of response($tasks) called original - as admitted above, I am new at this.
I now have:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Hash;
use DB;
use App\Models\Occupation;
class ImportTasks extends Command {
protected $signature = 'jobdesc:importtasks';
protected $description = 'Imports tasks into a JSON column';
public function handle() {
$task_statements = DB::connection('master')->table('task_statements')->distinct()->select('occupation_id')->get();
foreach ($task_statements as $task_statement) {
$tasks = DB::connection('master')
->table('task_statements')
->where('occupation_id', '=', $task_statement->occupation_id)
->select('task')
// ->orderBy('task')
->get();
$occupation = Occupation::find($task_statement->occupation_id);
$occupation->tasks = $tasks;
$occupation->save();
}
}
}
which gives me the right stuff in my database:
[
{
"task" : "Direct or coordinate an organization's financial or budget activities to fund operations, maximize investments, or increase efficiency."
},
{
"task" : "Confer with board members, organization officials, or staff members to discuss issues, coordinate activities, or resolve problems."
},
{
"task" : "Analyze operations to evaluate performance of a company or its staff in meeting objectives or to determine areas of potential cost reduction, program improvement, or policy change."
},
{
"task" : "Direct, plan, or implement policies, objectives, or activities of organizations or businesses to ensure continuing operations, to maximize returns on investments, or to increase productivity."
},
{
"task" : "Prepare budgets for approval, including those for funding or implementation of programs."
},
{
"task" : "Direct or coordinate activities of businesses or departments concerned with production, pricing, sales, or distribution of products."
},
{
"task" : "Negotiate or approve contracts or agreements with suppliers, distributors, federal or state agencies, or other organizational entities."
},
{
"task" : "Review reports submitted by staff members to recommend approval or to suggest changes."
},
{
"task" : "Appoint department heads or managers and assign or delegate responsibilities to them."
},
{
"task" : "Direct human resources activities, including the approval of human resource plans or activities, the selection of directors or other high-level staff, or establishment or organization of major departments."
},
{
"task" : "Preside over or serve on boards of directors, management committees, or other governing boards."
},
{
"task" : "Prepare or present reports concerning activities, expenses, budgets, government statutes or rulings, or other items affecting businesses or program services."
},
{
"task" : "Establish departmental responsibilities and coordinate functions among departments and sites."
},
{
"task" : "Implement corrective action plans to solve organizational or departmental problems."
},
{
"task" : "Coordinate the development or implementation of budgetary control systems, recordkeeping systems, or other administrative control processes."
},
{
"task" : "Direct non-merchandising departments, such as advertising, purchasing, credit, or accounting."
},
{
"task" : "Deliver speeches, write articles, or present information at meetings or conventions to promote services, exchange ideas, or accomplish objectives."
},
{
"task" : "Serve as liaisons between organizations, shareholders, and outside organizations."
},
{
"task" : "Nominate citizens to boards or commissions."
},
{
"task" : "Interpret and explain policies, rules, regulations, or laws to organizations, government or corporate officials, or individuals."
},
{
"task" : "Make presentations to legislative or other government committees regarding policies, programs, or budgets."
},
{
"task" : "Refer major policy matters to elected representatives for final decisions."
},
{
"task" : "Administer programs for selection of sites, construction of buildings, or provision of equipment or supplies."
},
{
"task" : "Direct or coordinate activities of businesses involved with buying or selling investment products or financial services."
},
{
"task" : "Direct or conduct studies or research on issues affecting areas of responsibility."
},
{
"task" : "Attend and participate in meetings of municipal councils or council committees."
},
{
"task" : "Organize or approve promotional campaigns."
},
{
"task" : "Conduct or direct investigations or hearings to resolve complaints or violations of laws or testify at such hearings."
},
{
"task" : "Represent organizations or promote their objectives at official functions or delegate representatives to do so."
},
{
"task" : "Prepare bylaws approved by elected officials and ensure that bylaws are enforced."
},
{
"task" : "Review and analyze legislation, laws, or public policy and recommend changes to promote or support interests of the general population or special groups."
}
]
Thank you all for your help, I can now go to bed and actually sleep instead of worrying about this.