RESTful backend with Laravel 5.3 and Angular 2 as frontend
-
The ng2 directory hosts the Angular 2 app
-
Other directories/files in the project root belongs to Laravel (5.3)
- Start PHP's built-in development server for Laravel
git clone https://github.com/abrarShariar/laravel-angular2-REST.git
cd laravel-angular2-REST
php artisan serve
- Start lite-server for Angular 2
cd laravel-angular2-REST
cd ng2
npm start
-
Some of the config files are not in the repo since they are kept as is out-of-the-box.
-
Config your database:
./config/database.php
./env
- Database schema is as follows:
Schema::create('employee', function (Blueprint $table) {
$table->increments('id'); //primary key + auto increment
$table->string('firstname');
$table->string('lastname');
$table->date('DOB');
$table->string('description',100);
$table->timestamps(); //'created_at' 'updated_at' cols
- Perform migration:
php artisan migrate
- EmployeeTableSeeder defines the seeds for the database. For initial seeding:
php artisan db:seed --class="EmployeeTableSeeder"
-
Now run
php artisan serve
in the project root and you will be Up and Running !! -
API endpoints defined in api.php
/api/all //get all employee data
/api/show/id=$id //get specific employee data
- Web routes defined in web.php
/create //create a new employee recored
//authentication required
- routes defined app.routing
/employee/all //show all employee data
/employee/add //add new employee
/search //search employee
-
FIX
/employee/add
in ng2 -
FIX http.post() in AddEmployeeService