Commit ad1c26f2fbceffe553b0c4d0c1c6f304b4f34d8e
1 parent
3575d19ae6
Exists in
master
Админка - контакты компании
Showing 2 changed files with 8 additions and 1 deletions Inline Diff
app/Http/Controllers/Admin/CompanyAreaController.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Http\Controllers\Admin; | 3 | namespace App\Http\Controllers\Admin; |
4 | 4 | ||
5 | use App\Http\Controllers\Controller; | 5 | use App\Http\Controllers\Controller; |
6 | use App\Models\Contact; | 6 | use App\Models\Contact; |
7 | use Illuminate\Http\Request; | 7 | use Illuminate\Http\Request; |
8 | use Illuminate\Support\Facades\Validator; | 8 | use Illuminate\Support\Facades\Validator; |
9 | 9 | ||
10 | class CompanyAreaController extends Controller | 10 | class CompanyAreaController extends Controller |
11 | { | 11 | { |
12 | /** | 12 | /** |
13 | * Display a listing of the resource. | 13 | * Display a listing of the resource. |
14 | * | 14 | * |
15 | * @return \Illuminate\Http\Response | 15 | * @return \Illuminate\Http\Response |
16 | */ | 16 | */ |
17 | public function index() | 17 | public function index() |
18 | { | 18 | { |
19 | // | 19 | // |
20 | } | 20 | } |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Show the form for creating a new resource. | 23 | * Show the form for creating a new resource. |
24 | * | 24 | * |
25 | * @return \Illuminate\Http\Response | 25 | * @return \Illuminate\Http\Response |
26 | */ | 26 | */ |
27 | public function create() | 27 | public function create() |
28 | { | 28 | { |
29 | // | 29 | // |
30 | } | 30 | } |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Store a newly created resource in storage. | 33 | * Store a newly created resource in storage. |
34 | * | 34 | * |
35 | * @param \Illuminate\Http\Request $request | 35 | * @param \Illuminate\Http\Request $request |
36 | * @return \Illuminate\Http\Response | 36 | * @return \Illuminate\Http\Response |
37 | */ | 37 | */ |
38 | public function store(Request $request) | 38 | public function store(Request $request) |
39 | { | 39 | { |
40 | // | 40 | // |
41 | } | 41 | } |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Display the specified resource. | 44 | * Display the specified resource. |
45 | * | 45 | * |
46 | * @param \App\Models\Contact $contact | 46 | * @param \App\Models\Contact $contact |
47 | * @return \Illuminate\Http\Response | 47 | * @return \Illuminate\Http\Response |
48 | */ | 48 | */ |
49 | public function show(Contact $contact) | 49 | public function show(Contact $contact) |
50 | { | 50 | { |
51 | $firm_data = Contact::find(1); | 51 | $firm_data = Contact::find(1); |
52 | return view('admin.company.view', compact('firm_data')); | 52 | return view('admin.company.view', compact('firm_data')); |
53 | } | 53 | } |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Show the form for editing the specified resource. | 56 | * Show the form for editing the specified resource. |
57 | * | 57 | * |
58 | * @param \App\Models\Contact $contact | 58 | * @param \App\Models\Contact $contact |
59 | * @return \Illuminate\Http\Response | 59 | * @return \Illuminate\Http\Response |
60 | */ | 60 | */ |
61 | public function edit(Contact $contact) | 61 | public function edit(Contact $contact) |
62 | { | 62 | { |
63 | $firm_data = Contact::find(1); | 63 | $firm_data = Contact::find(1); |
64 | return view('admin.company.edit', compact('firm_data')); | 64 | return view('admin.company.edit', compact('firm_data')); |
65 | } | 65 | } |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Update the specified resource in storage. | 68 | * Update the specified resource in storage. |
69 | * | 69 | * |
70 | * @param \Illuminate\Http\Request $request | 70 | * @param \Illuminate\Http\Request $request |
71 | * @param \App\Models\Contact $contact | 71 | * @param \App\Models\Contact $contact |
72 | * @return \Illuminate\Http\Response | 72 | * @return \Illuminate\Http\Response |
73 | */ | 73 | */ |
74 | public function update(Request $request, Contact $contact) | 74 | public function update(Request $request, Contact $contact) |
75 | { | 75 | { |
76 | $rules = [ | 76 | $rules = [ |
77 | 'email' => 'required|min:3|max:255', | 77 | 'email' => 'required|min:3|max:255', |
78 | 'telephone' => 'required|min:3|max:255', | 78 | 'telephone' => 'required|min:3|max:255', |
79 | ]; | 79 | ]; |
80 | $messages = [ | 80 | $messages = [ |
81 | 'required' => 'Укажите обязательное поле', | 81 | 'required' => 'Укажите обязательное поле', |
82 | ]; | 82 | ]; |
83 | 83 | ||
84 | $validator = Validator::make($request->all(), $rules, $messages); | 84 | $validator = Validator::make($request->all(), $rules, $messages); |
85 | 85 | ||
86 | if ($validator->fails()) { | 86 | if ($validator->fails()) { |
87 | return redirect()->route('admin.company.edit', ['company' => 1]) | 87 | return redirect()->route('admin.company.edit', ['company' => 1]) |
88 | ->withErrors($validator); | 88 | ->withErrors($validator); |
89 | } else { | 89 | } else { |
90 | $params = $request->all(); | 90 | $params = $request->all(); |
91 | $contact->update($params); | 91 | $company = Contact::find(1); |
92 | $company->update($params); | ||
92 | return redirect()->route('admin.company.show', ['company' => 1]); | 93 | return redirect()->route('admin.company.show', ['company' => 1]); |
93 | } | 94 | } |
94 | } | 95 | } |
95 | 96 | ||
96 | /** | 97 | /** |
97 | * Remove the specified resource from storage. | 98 | * Remove the specified resource from storage. |
98 | * | 99 | * |
99 | * @param \App\Models\Contact $contact | 100 | * @param \App\Models\Contact $contact |
100 | * @return \Illuminate\Http\Response | 101 | * @return \Illuminate\Http\Response |
101 | */ | 102 | */ |
102 | public function destroy(Contact $contact) | 103 | public function destroy(Contact $contact) |
103 | { | 104 | { |
104 | // | 105 | // |
105 | } | 106 | } |
106 | } | 107 | } |
107 | 108 |
app/Models/Contact.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Models; | 3 | namespace App\Models; |
4 | 4 | ||
5 | use Illuminate\Database\Eloquent\Factories\HasFactory; | 5 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
6 | use Illuminate\Database\Eloquent\Model; | 6 | use Illuminate\Database\Eloquent\Model; |
7 | 7 | ||
8 | class Contact extends Model | 8 | class Contact extends Model |
9 | { | 9 | { |
10 | use HasFactory; | 10 | use HasFactory; |
11 | |||
12 | protected $fillable = ['email', 'telephone', 'title', 'title_t', 'description', | ||
13 | 'whatapp', 'telegram', 'title1', 'title2', 'title3', 'text1', 'text2', 'text3', | ||
14 | 'year', 'conf' | ||
15 | ]; | ||
16 | |||
11 | } | 17 | } |
12 | 18 |