Ejemplo n.º 1
0
 public function postAddPart(Request $request)
 {
     if (!$request->ajax()) {
         return response('Bad request', 400);
     }
     $track = Track::findOrFail($request->id);
     $user = User::where('name', '=', $request->name)->first();
     if (!$user) {
         return response()->json(['status' => false, 'msg' => trans('track.no_user')]);
     }
     $track->participants()->attach($user->id, ['type_id' => $request->part]);
     $part_id = DB::table('track_participants')->where('user_id', $user->id)->where('track_id', $track->id)->where('type_id', $request->part)->first()->id;
     return response()->json(['status' => true, 'user_id' => $user->id, 'part_id' => $part_id, 'text' => [trans('track.features'), trans('track.productions'), trans('track.remixes')]]);
 }
Ejemplo n.º 2
0
 public function getRemove($id)
 {
     $track = Track::findOrFail($id);
     if (Auth::user()->id == $track->creator->id || Auth::user()->staff) {
         $track->delete();
         return redirect('/');
     }
     return redirect('/');
 }
Ejemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Track $track)
 {
     if (Request::ajax()) {
         return Track::findOrFail($track->id) ? Track::destroy($track->id) : null;
     } else {
     }
     Track::findOrFail($track->id) ? Track::destroy($track->id) : null;
     flash('Track is deleted');
     return redirect('tracks');
 }