Skip to content

Commit d0096e2

Browse files
committed
company, employee migration models, controller, routes, requests
1 parent 4924910 commit d0096e2

12 files changed

+419
-0
lines changed
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Http\Requests\StoreCompanyRequest;
6+
use App\Http\Requests\UpdateCompanyRequest;
7+
use App\Models\Company;
8+
9+
class CompanyController extends Controller
10+
{
11+
/**
12+
* Display a listing of the resource.
13+
*
14+
* @return \Illuminate\Http\Response
15+
*/
16+
public function index()
17+
{
18+
//
19+
}
20+
21+
/**
22+
* Show the form for creating a new resource.
23+
*
24+
* @return \Illuminate\Http\Response
25+
*/
26+
public function create()
27+
{
28+
//
29+
}
30+
31+
/**
32+
* Store a newly created resource in storage.
33+
*
34+
* @param \App\Http\Requests\StoreCompanyRequest $request
35+
* @return \Illuminate\Http\Response
36+
*/
37+
public function store(StoreCompanyRequest $request)
38+
{
39+
//
40+
}
41+
42+
/**
43+
* Display the specified resource.
44+
*
45+
* @param \App\Models\Company $company
46+
* @return \Illuminate\Http\Response
47+
*/
48+
public function show(Company $company)
49+
{
50+
//
51+
}
52+
53+
/**
54+
* Show the form for editing the specified resource.
55+
*
56+
* @param \App\Models\Company $company
57+
* @return \Illuminate\Http\Response
58+
*/
59+
public function edit(Company $company)
60+
{
61+
//
62+
}
63+
64+
/**
65+
* Update the specified resource in storage.
66+
*
67+
* @param \App\Http\Requests\UpdateCompanyRequest $request
68+
* @param \App\Models\Company $company
69+
* @return \Illuminate\Http\Response
70+
*/
71+
public function update(UpdateCompanyRequest $request, Company $company)
72+
{
73+
//
74+
}
75+
76+
/**
77+
* Remove the specified resource from storage.
78+
*
79+
* @param \App\Models\Company $company
80+
* @return \Illuminate\Http\Response
81+
*/
82+
public function destroy(Company $company)
83+
{
84+
//
85+
}
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Http\Requests\StoreEmployeeRequest;
6+
use App\Http\Requests\UpdateEmployeeRequest;
7+
use App\Models\Employee;
8+
9+
class EmployeeController extends Controller
10+
{
11+
/**
12+
* Display a listing of the resource.
13+
*
14+
* @return \Illuminate\Http\Response
15+
*/
16+
public function index()
17+
{
18+
//
19+
}
20+
21+
/**
22+
* Show the form for creating a new resource.
23+
*
24+
* @return \Illuminate\Http\Response
25+
*/
26+
public function create()
27+
{
28+
//
29+
}
30+
31+
/**
32+
* Store a newly created resource in storage.
33+
*
34+
* @param \App\Http\Requests\StoreEmployeeRequest $request
35+
* @return \Illuminate\Http\Response
36+
*/
37+
public function store(StoreEmployeeRequest $request)
38+
{
39+
//
40+
}
41+
42+
/**
43+
* Display the specified resource.
44+
*
45+
* @param \App\Models\Employee $employee
46+
* @return \Illuminate\Http\Response
47+
*/
48+
public function show(Employee $employee)
49+
{
50+
//
51+
}
52+
53+
/**
54+
* Show the form for editing the specified resource.
55+
*
56+
* @param \App\Models\Employee $employee
57+
* @return \Illuminate\Http\Response
58+
*/
59+
public function edit(Employee $employee)
60+
{
61+
//
62+
}
63+
64+
/**
65+
* Update the specified resource in storage.
66+
*
67+
* @param \App\Http\Requests\UpdateEmployeeRequest $request
68+
* @param \App\Models\Employee $employee
69+
* @return \Illuminate\Http\Response
70+
*/
71+
public function update(UpdateEmployeeRequest $request, Employee $employee)
72+
{
73+
//
74+
}
75+
76+
/**
77+
* Remove the specified resource from storage.
78+
*
79+
* @param \App\Models\Employee $employee
80+
* @return \Illuminate\Http\Response
81+
*/
82+
public function destroy(Employee $employee)
83+
{
84+
//
85+
}
86+
}
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Http\Requests;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class StoreCompanyRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*
12+
* @return bool
13+
*/
14+
public function authorize()
15+
{
16+
return false;
17+
}
18+
19+
/**
20+
* Get the validation rules that apply to the request.
21+
*
22+
* @return array<string, mixed>
23+
*/
24+
public function rules()
25+
{
26+
return [
27+
'name' => 'required|unique:companies|max:255',
28+
'email' => 'required|unique:companies|email|max:255',
29+
'logo' => 'required|mimes:png,jpg,jpeg|max:255',
30+
'website' => 'url|max:255'
31+
];
32+
}
33+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace App\Http\Requests;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class StoreEmployeeRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*
12+
* @return bool
13+
*/
14+
public function authorize()
15+
{
16+
return false;
17+
}
18+
19+
/**
20+
* Get the validation rules that apply to the request.
21+
*
22+
* @return array<string, mixed>
23+
*/
24+
public function rules()
25+
{
26+
return [
27+
'first_name' => 'required|max:255',
28+
'last_name' => 'required|max:255',
29+
'email' => 'required|unique:employees|email|max:255',
30+
'company_id' => 'required',
31+
'phone' => 'max:255'
32+
];
33+
}
34+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Requests;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class UpdateCompanyRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*
12+
* @return bool
13+
*/
14+
public function authorize()
15+
{
16+
return false;
17+
}
18+
19+
/**
20+
* Get the validation rules that apply to the request.
21+
*
22+
* @return array<string, mixed>
23+
*/
24+
public function rules()
25+
{
26+
return [
27+
//
28+
];
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Requests;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class UpdateEmployeeRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*
12+
* @return bool
13+
*/
14+
public function authorize()
15+
{
16+
return false;
17+
}
18+
19+
/**
20+
* Get the validation rules that apply to the request.
21+
*
22+
* @return array<string, mixed>
23+
*/
24+
public function rules()
25+
{
26+
return [
27+
//
28+
];
29+
}
30+
}

app/Models/Company.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\SoftDeletes;
8+
9+
class Company extends Model
10+
{
11+
use HasFactory, SoftDeletes;
12+
}

app/Models/Employee.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\SoftDeletes;
8+
9+
class Employee extends Model
10+
{
11+
use HasFactory, SoftDeletes;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('companies', function (Blueprint $table) {
17+
$table->id();
18+
$table->timestamps();
19+
$table->string('name');
20+
$table->string('email');
21+
$table->string('logo');
22+
$table->string('website')->nullable();
23+
$table->softDeletesTz($column = 'deleted_at', $precision = 0);
24+
});
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*
30+
* @return void
31+
*/
32+
public function down()
33+
{
34+
Schema::dropIfExists('companies');
35+
}
36+
};

0 commit comments

Comments
 (0)