- Home
- Forum
- Angular - EJ 2
- using kanban angular frontend and laravel backend
using kanban angular frontend and laravel backend
11 Replies
1 reply marked as answer
BS
Buvana Sathasivam
Syncfusion Team
May 3, 2021 12:45 PM UTC
Hi taha,
We are currently validating your query, we will update you with further details on or before 6th May.
We appreciate your patience till then.
Regards,
Buvana S
TM
taha mejdoub
May 3, 2021 09:31 PM UTC
Thank you , i will wait until you response
RK
Revanth Krishnan
Syncfusion Team
May 4, 2021 01:04 PM UTC
Hi Taha,
As mentioned earlier we will provide you with further details on 6th May.
Regards,
Revanth
BS
Buvana Sathasivam
Syncfusion Team
May 6, 2021 11:05 AM UTC
Hi Taha,
Thanks for your patience.
We have created a simple sample based on your requirement. We have rendered the Syncfusion angular Kanban component as front-end and Laravel as back-end.
Prerequisites: Ensure the below software is installed on your machine.
Follow the below steps for running the sample.
Step #1: After installing XAMPP, the XAMPP folder is created on your installed drive. Created a new folder and provided the name as Laravel under the drive:\xampp\htdocs folder.
Step #2: Installed the composer and run the Laravel backend using below commands.
|
composer create-project laravel/laravel example-app
cd example-app
php artisan serve |
Step #3: Created the database table using phpMyAdmin page and enter the database credentials to .env file.
|
DB_DATABASE=laravel_api
DB_USERNAME=root
DB_PASSWORD= |
Step #4: We have created KanbanTask model using below command.
|
php artisan make:model KanbanTask -m |
Step #5: Mentioned the column names and their types in a database table under the database -> migrations -> database table name.
2021_05_05_095951_create_kanban_tasks_table.php
|
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateKanbanTasksTable extends Migration
{
public function up()
{
Schema::create('kanban_tasks', function (Blueprint $table) {
$table->id();
$table->string('title', 500);
$table->string('status', 500);
$table->string('assignee', 500);
$table->string('summary');
$table->timestamps();
});
}
….
}
|
Step #6: Now, migrated using below command.
|
php artisan migrate |
Step #7: Created KanbanTaskController using below command line.
|
php artisan make:controller KanbanTaskController |
Step #8: Registered the routes inside the routes->api.php file.
|
// Get all Kanban tasks
Route::get('kanban_tasks', 'App\Http\Controllers\KanbanTaskController@getKanbanTask'); |
Step #9: Included the $fillable property to prevent the mass assignment exceptions inside the app-> Models->KanbanTask.php file.
|
class KanbanTask extends Model
{
use HasFactory;
public $timestamps = false;
protected $fillable = ['title', 'status', 'assignee', 'summary'];
}
|
Step #10: Created the getKanbanTask function and written the code for saving the data into the database.
KanbanTaskController.php
|
use App\Models\KanbanTask;
class KanbanTaskController extends Controller
{
public function getKanbanTask() {
return response()->json(KanbanTask::all(), 200);
}
}
|
Step #11: Created the angular application inside the drive/xampp/htdocs folder.
|
npm install -g @angular/cli
ng new syncfusion-app
cd syncfusion-app |
Step #11: Installed the ej2-kanban-angular package through the command prompt.
|
npm install @syncfusion/ej2-angular-kanban –save |
Step #12: Imported the Kanban module in app.module.ts file.
|
import { KanbanAllModule } from '@syncfusion/ej2-angular-kanban';
import { HttpClientModule } from '@angular/common/http';
@NgModule({
imports: [
KanbanAllModule,
HttpClientModule,
],
})
export class AppModule { }
|
Step #13: Added the below angular Kanban styles in style.css file.
|
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
@import '../node_modules/@syncfusion/ej2-layouts/styles/material.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-angular-kanban/styles/material.css'; |
Step #14: Fetch the data from the Laravel backend and load into the Kanban board.
app.component.html
|
<ejs-kanban #kanbanObj cssClass="kanban-swimlane" keyField="status" [dataSource]="KanbanData"
[cardSettings]="cardSettings">
<e-columns>
<e-column headerText="To Do" keyField="Open"></e-column>
<e-column headerText="In Progress" keyField="InProgress"></e-column>
<e-column headerText="Done" keyField="Close"></e-column>
</e-columns>
</ejs-kanban>
|
app.component.ts
|
import { HttpClient } from "@angular/common/http";
import { CardSettingsModel } from "@syncfusion/ej2-angular-kanban";
….
export class AppComponent {
KanbanData: Object;
public cardSettings: CardSettingsModel = {
contentField: "summary",
headerField: "id"
};
constructor(private http: HttpClient) { }
ngOnInit() {
this.http.get('http://127.0.0.1:8000/api/kanban_tasks').subscribe(result => {
this.KanbanData = result;
})
}
} |
Please find the below sample for your reference.
Note: Paste above samples folder inside the drive:/xampp/htdocs folder and follow the above commands.
Regards,
Buvana S
TM
taha mejdoub
May 10, 2021 11:59 PM UTC
thank you but i need an edit and add button to this kanban can you help me??
BS
Buvana Sathasivam
Syncfusion Team
May 12, 2021 03:32 AM UTC
Hi Taha,
Thanks for your update.
We have validated your requirement “I need edit and add a button to this Kanban” at our end and prepared CRUD Kanban angular sample with PHP as backend. In the below provided sample, we fetch the data from the server and bound it to the Kanban component using `url` property of DataManager. We have performed CRUD operations like add/delete/update actions using `insertUrl`, `removeUrl` and `updateUrl` properties.
|
app.component.ts
public dataManger: DataManager = new DataManager({
url: 'http://localhost:8080/KanbanPHP/GetData.php', // Triggered server for initial Kanban loading
updateUrl: 'http://localhost:8080/KanbanPHP/KanbanCrud.php', // Triggered server when update action perform
removeUrl: 'http://localhost:8080/KanbanPHP/KanbanCrud.php',// Triggered server when delete action perform
insertUrl: 'http://localhost:8080/KanbanPHP/KanbanCrud.php', // Triggered server when add action perform
adaptor: new UrlAdaptor(),
crossDomain: true
})
app.component.html
<ejs-kanban #kanbanObj [dataSource]="dataManger">
…….
</ejs-kanban>
|
We have created GetData.php file and get the data from the database table and returned the JSON data to the Kanban board. Based on returned JSON data, the Kanban board is rendered at initial.
GetData.php
|
<?php
// used to connect to the database
$host = "localhost";
$db_name = "laravel_api"; /* Put your database name */
$username = "root";
$password = ""; /* Put your password */
header('Content-Type: application/json');
//create connection
$link = mysqli_connect($host,$username,$password,$db_name);
// SQL query for retrieve all the column data from a table
$query =$sql = "SELECT * FROM kanban_datas";
$result = $link->query($query);
$json=array();
while ($row = mysqli_fetch_assoc($result)) {
$json[]=$row;
}
echo json_encode($json);
?>
|
We have created KanbanCrud.php file to update, delete and add operations performed into the database table when Kanban CRUD operation happened. We have enabled `showAddButton` property inside the column to perform the add operation. You can edit the Kanban data when double click the particular card.
KanbanCrud.php
|
<?php
………..
// Insert new data into database table
if ($params['action'] == "insert") {
$value=$params['value'];
$id=$value['Id'];
$status =$value["Status"];
$summary =$value["Summary"];
$retval = mysqli_query($link,"INSERT INTO kanban_datas (Id,Status,Summary)
VALUES ('$id','$status','$summary')");
}
// Update modified data into database table
if ($params['action'] == "update") {
$value=$params['value'];
$id=$value['Id'];
$status =$value["Status"];
$summary =$value["Summary"];
$assignee =$value["Assignee"];
$retval = mysqli_query($link,"UPDATE kanban_datas SET Status='$status',Assignee='$assignee',Summary='$summary' WHERE Id=$id");
}
// Delete data into database table
if ($params['action'] == "remove") {
$value=$params['key'];
$res1 = $link->query("DELETE FROM `kanban_datas` WHERE Id=$value");
$success=array("Deleted"=>$value);
}
……….
echo json_encode($json);
?>
|
Find the below sample for your reference. Paste the below samples to drive:/xampp/htdocs folder. Now, run the Laravel backend and angular application.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Angluar_Kanban_Laravel-1501054990
Please let us know if you have any further queries.
Regards,
Buvana S
TM
taha mejdoub
May 12, 2021 06:49 AM UTC
i use sqlserver not mysql in laravel so can you help me ??
GK
Gunasekar Kuppusamy
Syncfusion Team
May 14, 2021 09:15 AM UTC
Hi taha,
Regards,
Gunasekar
BS
Buvana Sathasivam
Syncfusion Team
May 17, 2021 01:14 PM UTC
Hi Taha,
Thanks for your patience.
We have analyzed your requirement and prepared a simple sample based on SQL server with Laravel and Angular Kanban board. We have used UrlAdaptor for handling server-side actions like add, update, and delete operations performed by the Kanban component.
app.component.ts
|
public dataManger: DataManager = new DataManager({
url: 'http://localhost:8080/Laravel/example-app/routes/KanbanPHP/GetData.php',
updateUrl: 'http://localhost:8080/laravel/example-app/routes/KanbanPHP/KanbanCrud.php',
removeUrl: 'http://localhost:8080/laravel/example-app/routes/KanbanPHP/KanbanCrud.php',
insertUrl: 'http://localhost:8080/laravel/example-app/routes/KanbanPHP/KanbanCrud.php',
adaptor: new UrlAdaptor(),
crossDomain: true
}) |
Find the below sample for your reference.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Angluar_Kanban_Laravel2061901650
In above sample, paste the Kanban_Angular_App file into htdocs folder and Kanban_PHP file into inside the Laravel folder.
Note: Kanban_PHP folder path name needs to specify on Kanban angular application (app.component.ts file) DataManager URL paths for running the above sample.
Regards,
Buvana S
TM
taha mejdoub
May 19, 2021 09:34 AM UTC
how to paste the krudkanban folder in laravel and also work with sql server authentification
IS
Indrajith Srinivasan
Syncfusion Team
May 20, 2021 12:18 PM UTC
Hi Taha,
Good day to you,
We have validated your reported queries,
Query 1: “how to paste the krudkanban folder in laravel”
You can place the shared (KanBanPHP/kanbanCrud.php) and (KanBanPHP/GetData.php) files, inside any of the folders of the below location xampp -> htdocs.
Screenshot:
In the already shared sample, we have placed inside the routes folder check the below code blocks and already shared sample with the last update for reference.
|
'http://localhost:8080/Laravel/example-app/routes/KanbanPHP/GetData.php'
|
Screenshot:
Query 2: “Work with sql server authentification”
You can refer the below links for server authentication.
Please let us know if the solution helps,
Regards,
Indrajith
Marked as answer
SIGN IN To post a reply.
- 11 Replies
- 5 Participants
- Marked answer
-
TM taha mejdoub
- May 2, 2021 07:40 PM UTC
- May 20, 2021 12:18 PM UTC