Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['apk' => 'required', 'version_id' => 'required|numeric|unique:apps,version_id', 'version_name' => 'required']);
     if ($validator->fails()) {
         if ($validator->errors()->has('apk')) {
             return response()->json($validator->errors()->first('apk'), 400);
         }
         if ($validator->errors()->has('version_id')) {
             return response()->json($validator->errors()->first('version_id'), 400);
         }
         if ($validator->errors()->has('version_name')) {
             return response()->json($validator->errors()->first('version_name'), 400);
         }
     }
     $apk_name = $this->uploadAPK($request->apk, '/apk/');
     $apps = new Apk();
     $apps->name = $apk_name;
     $apps->version_id = $request->version_id;
     $apps->version_name = $request->version_name;
     $apps->save();
     return response()->json($apps);
 }
Example #2
0
 public function search($input)
 {
     $query = Apk::query();
     $columns = Schema::getColumnListing('apks');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }