コード例 #1
0
ファイル: AdminController.php プロジェクト: axovel/tattoo
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function tagTattooSave(Request $request)
 {
     $res = array();
     $res['success'] = false;
     $user = Auth::user();
     $tattoo = Tattoo::find($request->input('id'));
     if ($request->input('tags')) {
         $tattoo->tags_count = 1;
         $tattoo->tags()->sync($request->input('tags'));
         $tattoo->description = $request->input('desc');
         $tattoo->save();
         $res['success'] = true;
     }
     return $res;
 }
コード例 #2
0
 /**
  * Approve Tattoo
  *
  * @return View
  */
 public function rejectTattoo($id)
 {
     $user = Auth::user();
     $artist = Artist::where('user_id', $user->id)->first();
     $tattoo = Tattoo::find($id);
     if ($tattoo) {
         if ($tattoo->artist_id == $artist->id) {
             $tattoo->delete();
             return redirect('artist/' . $artist->id)->with('success', 'Tattoo Deleted Successfully');
         }
     }
     return redirect('artist/' . $artist->id);
 }
コード例 #3
0
ファイル: TattooController.php プロジェクト: axovel/tattoo
 /**
  * Remove the specified tattoo from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function deleteTattoo(Request $request)
 {
     if (!$request->ajax()) {
         dd("NO ASYNC REQUEST");
     }
     $res = array();
     $res['success'] = false;
     $tattooId = $request->input('tattoo');
     $tattoo = Tattoo::find($tattooId);
     $user = Auth::user();
     if ($tattoo) {
         if ($tattoo->user_id == $user->id) {
             $tattoo->delete();
             $res['success'] = true;
         } elseif ($user->type == 'artist') {
             $artist = Artist::where('user_id', $user->id)->first();
             $artist->tattoos()->detach($tattooId);
             $res['success'] = true;
         } elseif ($user->type == 'studio') {
             $studio = Studio::where('user_id', $user->id)->first();
             $studio->tattoos()->detach($tattooId);
             $res['success'] = true;
         }
     }
     return $res;
 }
コード例 #4
0
 /**
  * Display Studio profile
  *
  * @return View
  */
 public function studio($id)
 {
     $studio = Studio::find($id);
     $tattoos = Tattoo::whereIn('artist_id', $studio->artists->lists('user_id'))->get();
     $studio->cover = url('uploads/images/large/' . $studio->cover);
     return view('pages.studio', ['studio' => $studio, 'tattoos' => $tattoos]);
 }
コード例 #5
0
ファイル: MainController.php プロジェクト: axovel/tattoo
 public function adminUploadTattoosSave(Request $request)
 {
     $user = Auth::user();
     if ($request->hasFile('file')) {
         //upload an image to the /img/tmp directory and return the filepath.
         $file = $request->file('file');
         $tmpFilePath = '/uploads/images/original/';
         $tmpFileName = 'tattoo-' . time() . '-' . $file->getClientOriginalName();
         //save original file
         $file = $file->move(public_path() . $tmpFilePath, $tmpFileName);
         $path = $tmpFilePath . $tmpFileName;
         //edit image
         $img = \Image::make($file);
         $img->backup();
         // reset image (return to backup state)
         $img->reset();
         $img->fit(360);
         //240*240
         $img->save('uploads/images/thumbnail/' . $tmpFileName);
         // reset image (return to backup state)
         $img->reset();
         $img->fit(120);
         //100*100
         $img->save('uploads/images/small/' . $tmpFileName);
         //save tattoo in DB
         $tattoo = new Tattoo();
         $tattoo->title = '';
         $tattoo->url = $tmpFileName;
         $tattoo->description = '';
         $tattoo->user_id = $user->id;
         $tattoo->approved = true;
         $tattoo->save();
         if ($user->type == 'artist') {
             $profile = Artist::where('user_id', $user->id)->first();
             $profile->tattoos()->save($tattoo);
         } elseif ($user->type == 'studio') {
             $profile = Studio::where('user_id', $user->id)->first();
             $profile->tattoos()->save($tattoo);
         }
         return response()->json(array('path' => $tmpFileName), 200);
     } else {
         return response()->json(false, 200);
     }
 }