Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. public function update($id)
  2. {
  3. $datas = [];
  4. foreach (config('app.available_locale') as $index => $value)
  5. {
  6. $datas [$value] =
  7. [
  8. IndustriesTrans::where('locale',$value)->first()
  9. ];
  10. }
  11.  
  12. $params =
  13. [
  14. 'datas' => $datas,
  15. 'untranslated' => Industries::find($id)
  16. ];
  17.  
  18. return view('backend.industries.detail',$params);
  19. }
  20.  
  21. public function store(Request $request)
  22. {
  23. $industries = $this->model->find($request->industries_id);
  24. if($request->hasFile('thumbnail'))
  25. {
  26. $thumbnail = $request->file('thumbnail');
  27. try{
  28. File::delete($industries->thumbnail);
  29. $thumbnail->move('backend/images/industries',$thumbnail->getClientOriginalName());
  30. $industries->update([
  31. 'thumbnail' => 'backend/images/industries/'.$thumbnail->getClientOriginalName()
  32. ]);
  33. }catch(Exception $e)
  34. {
  35. $e->getMessage();
  36. }
  37. }
  38.  
  39. try{
  40. foreach (config('app.available_locale') as $index => $locale)
  41. {
  42. IndustriesTrans::updateOrCreate(
  43. [
  44. 'locale' => $locale,
  45. 'industries_id' => $request->industries_id
  46. ],
  47. [
  48. 'title' => $request->titles[$locale],
  49. 'content' => $request->contents[$locale],
  50. 'cta' => $request->ctas[$locale]
  51. ]);
  52. }
  53. }catch (Exception $e)
  54. {
  55. dd($e->getMessage());
  56. }
  57.  
  58. return redirect()->route('industries_page');
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement