I make 2 table inside up function. I can access groups table. But how can I retrieve group_details table from create_group function?
public function up()
{
Schema::create('groups', function (Blueprint $table) {
$table->increments('id');
$table->string('email');
$table->string('group_id');
$table->timestamps();
});
Schema::create('group_details', function (Blueprint $table) {
$table->increments('id');
$table->string('group_id');
$table->string('members');
$table->string('total_balance');
$table->string('cost');
$table->string('deposite');
$table->string('meal');
$table->string('meal_helper');
$table->timestamps();
});
public function down()
{
Schema::dropIfExists('groups');
Schema::dropIfExists('group_details');
}
public function create_group(Request $request){
$groupname = $request['group_name'];
$email = $request['email'];
$groups = new Groups();
$groups->group_id = $groupname . "-".$email;
$groups->email = $email;
$group_details = new Groups();
$group_details->group_id = $groupname . "-".$email;
$group_details->members = '[]';
$group_details->total_balance = '7000';
$group_details->cost = '[]';
$group_details->deposite = '4000';
$group_details->meal = '[]';
$group_details->meal_helper = '[]';
$message = "Group creation fail!";
if($groups->save()&& $group_details->save()){
$message = 'Group Created success!';
}
return redirect()->route('profile')->with(['message'=> $message]);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community