Laravel BAP, MulitCRM — Creating Relations — Part 2—ManyToOne

Laravel BAP
Oct 3, 2018 · 3 min read

Laravel BAP is a Modular Backend Application Platform build on top of Laravel 5.6, Twitter Bootstrap and SCSS. The software contains over 20 core features, module generator, relations in tabs. BAP is Easy to extend, customize, developer, can build any back-office application with short time.

You can read more about platforms here:

Tutorial

In this tutorial, I'm going to show how to extend application and create relations between modules.

ManyToOne Relation

Example ManyToOne relation in CRM in when in single Ticket you can choose from many existing Accounts and bind one inside Account record in Ticket.

In application, many to many relations are represented by “Picker field”. When user will click on search icon application will show modal with list of available records to bind.

Creating ManyToOne Relation

In this example, we are going to add Account Picker in Ticket.

1.Creating migration

run artisan command

This function will create new migration in Tickets module.

Update migration file.

Explanation

We are adding new field “account_id” inside the tickets table. The new field is a relation with foreign key to accounts table.

2. Update Ticket Entity

Add new field to $fillable

Add new relation

3.Update TicketController

in $showFields add this

Explanation:

type: manyToOne relation: account (same name as in Entity) column: column from “account” that you want to display in this field. dont_translate: true — this field shouldn’t be translated.

4.Update Form

Find TicketForm class and update.

5.Update translations

Find module translation file and update variables.

/Tickets/Resources/lang/en/tickets.php

And that's all.

Laravel BAP

Written by

Passion for making great solutions in Laravel.