public function create($catalog_id) { $rules = array('images' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::route(array('admin.newsletter.create', $catalog_id))->withErrors($validator)->With(Input::all()); } else { $catalog = Catalog::find($catalog_id); $pictures = $catalog->pictures; $car = $catalog->car; $images = Input::get('images'); $newsletter = new Newsletter(); $newsletter->title = $catalog->title; $newsletter->images = $images; $newsletter->send_to = 0; $newsletter->user_id = Auth::user()->id; $newsletter->catalog_id = $catalog_id; $newsletter->save(); $settingsEmail = Settings::where('key', '=', 'contact_email')->first(); $settingsEmailName = Settings::where('key', '=', 'contact_name')->first(); // Subscribers::find(8001) for testing $subscribers = Subscribers::all(); foreach ($subscribers as $subscriber) { $data = array('subject' => $catalog->title, 'to' => $subscriber->email, 'to_name' => $subscriber->name, 'from_name' => $settingsEmailName->value, 'from' => $settingsEmail->value, 'catalog' => $catalog, 'images' => $images, 'car' => $car, 'pictures' => $pictures, 'user' => $subscriber); Mail::queue('emails.newsletter.html', $data, function ($message) use($data) { $message->to($data['to'], $data['to_name'])->from($data['from'], $data['from_name'])->subject($data['subject']); }); } return Redirect::route('admin.newsletter.index')->with('success', Lang::get('messages.newsletter_created')); } return Redirect::route('admin.newsletter.index')->with('success', Lang::get('messages.newsletter_created')); }
function getCatalogInfo() { // $fileName = $this->getPath().$this->_props['name'].'.'.Q::ini('appini/catalog/fileInfoExt', 'inf'); // //读取文件编目信息 // $handle = @fopen($fileName, 'a+'); // if($handle){ // $filesize = @filesize($fileName); // if ($filesize > 0){ // $json = @fread ($handle, $filesize); // $catalogInfo = Helper_JSON::decode($json); // }else{ // $catalogInfo = array(); // } // @fclose ($handle); // } $catalogInfo = $this->_props['catalog_info'] == null ? array() : Helper_JSON::decode($this->_props['catalog_info']); //获得编目信息分类 $catalog = Catalog::find('path like ? and enabled=1', '%,' . ($this->_props['type'] + 1) . ',%')->order('weight desc')->asArray()->getAll(); $catalog = Helper_Array::toTree($catalog, 'id', 'parent_id', 'children'); //合并编目信息 foreach ($catalog as $k => $v) { if (isset($catalogInfo[$v['name']])) { foreach ($v['children'] as $_k => $_v) { if (!isset($catalogInfo[$v['name']][$_v['name']])) { $catalogInfo[$v['name']][$_v['name']] = ''; } } } else { foreach ($v['children'] as $_k => $_v) { $catalogInfo[$v['name']][$_v['name']] = ''; } } } return $catalogInfo; }
/** * @api {get} /enrollment/courses/:idCourse/users/:idUser/membership/:id Enroll Course from Membership * @apiName Enroll Course from Membership * @apiGroup Enrollment * @apiDescription * @apiParam {Number} id Membership id. * @apiParam {Number} idUser User id. * @apiParam {Number} idCourse Course id. * * @apiError 400 Link Invalid. This will happen if param is not sent out. * @apiError 404 Not found. This will happen if the role id/user id/group id is not in our system. * @apiError 409 Link already activated. * @apiError 409 Enrollment exist. */ public static function enrollByMembership($idMembership, $idUser, $idCourse) { $app = \Slim\Slim::getInstance(); if (!User::find($idUser)) { $app->halt(404, json_encode("User does not exist")); } $course = Course::find($idCourse); if (!$course || !Course::find($idMembership) || !self::isEnroll($idMembership, $idUser)) { $app->halt(404, json_encode("Course does not exist")); } $courses = Catalog::find($idMembership)->course->lists('id')->toArray(); if (!in_array($idCourse, $courses)) { $app->halt(404, json_encode("Course does not exist")); } // if(self::isEnroll($idCourse,$idUser)){ // $app->halt(409,json_encode("Enrollment already exist")); // } $membership = Enrollment::where('course_id', $idMembership)->where('user_id', $idUser)->first(); echo self::enroll($idCourse, $idUser, $membership->end_at); }
/** * @api {get} courses/enrolled/users/:id Get User's course history * @apiName Get User's course history * @apiGroup Enrollment * * @apiHeader (Header) {String} X_Authorization Authorization value. * * @apiParam {Number} idUser Mandatory Users unique ID. * * @apiSuccessExample {json} Success-Response: * HTTP/1.1 200 OK * [ * { * "membership_id": 1, * "course_id": 26262, * "name": "TurboChef: iSeries", * "manufacturer": "TurboChef", * "type": "3d", * "note": null, * "pak": " iSeries", * "html5": 0, * "safety": -1, * "short_description": null, * "status": "Active to Enroll", * "end_at": "2016-11-29 11:05:07" *}, *{ * "id": 103, * "course_id": 45950, * "name": "Scotsman: Prodigy Eclipse Ice Cuber EH222", * "manufacturer": "Scotsman Ice Systems", * "type": "course", * "note": null, * "pak": "Prodigy Eclipse Ice Cuber EH222", * "html5": 1, * "safety": -1, * "short_description": null, * "status": "Enrolled", * "end_at": null, * "enrolled_at": "2015-11-30 12:27:52" *} * ] */ public static function getEnrollments($idUser) { $app = \Slim\Slim::getInstance(); if (!User::find($idUser)) { $app->response->setStatus(400); return json_encode("User does not exist"); } $enrollments = User::find($idUser)->enrollment; $active_enrollment_ids = Enrollment::where('end_at', '>', date('Y-m-d H:i:s'))->orwhere('end_at', null)->where('user_id', '=', $idUser)->lists('course_id')->toArray(); $result = []; foreach ($enrollments as &$enrollment) { if (!is_null($enrollment->end_at)) { if (date("Y-m-d H:i:s") > $enrollment->end_at) { $enrollment->status = "expired"; continue; } } $course = Enrollment::find($enrollment->id)->course; if ($course->type == "membership") { if ($enrollment->status == "expired") { continue; } $membership_courses = Catalog::find($course->id)->course()->where("isPublished", "1"); foreach ($membership_courses as $key => $value) { if (is_array($active_enrollment_ids) && in_array($value->id, $active_enrollment_ids)) { continue; } $data = array("membership_id" => $enrollment->course_id, "course_id" => $value->id, "name" => $value->name, "manufacturer" => $value->manufacturer, "type" => $value->type, "note" => $value->note, "pak" => trim($value->pak), "html5" => $course->html5, "safety" => $enrollment->isSafety, "short_description" => $value->shortDescription, "status" => "Active to Enroll", "scorm_registration_id" => $enrollment->scorm_registration_id, "end_at" => $enrollment->end_at); array_push($result, $data); } } else { $data = array("id" => $enrollment->id, "course_id" => $course->id, "name" => $course->name, "manufacturer" => $course->manufacturer, "type" => $course->type, "note" => $course->note, "pak" => trim($course->pak), "html5" => $course->html5, "safety" => $enrollment->isSafety, "short_description" => $course->shortDescription, "progress" => $enrollment->progress, "status" => ucfirst($enrollment->status), "end_at" => $enrollment->end_at, "scorm_registration_id" => $enrollment->scorm_registration_id, "enrolled_at" => date($enrollment->created_at)); array_push($result, $data); } } // Add additional recommend course to user's library $paks = array(); $courses = array(); foreach ($result as $data) { if (!in_array($data['pak'], $paks)) { array_push($paks, trim($data['pak'])); } array_push($courses, $data['course_id']); } foreach ($paks as $key => $value) { $ids = Course::where('pak', '=', $value)->lists('id')->toArray(); foreach ($ids as $id) { if (!in_array($id, $courses)) { $course = Course::find($id); $price = Price::where('course_id', $id)->orderBy('length')->first(); //priority $data = array("status" => "Recommend to buy", "course_id" => $course->id, "name" => $course->name, "manufacturer" => $course->manufacturer, "type" => $course->type, "note" => $course->note, "pak" => trim($course->pak), "html5" => $course->html5, "short_description" => $course->shortDescription); if ($price) { $data['price'] = $price->price; $data['idSale'] = $price->id; } array_push($result, $data); } } } //print_r($paks); return json_encode($result); }
public function detailsContact($id) { $rules = array('name' => 'required|min:3', 'email' => 'required|email|min:3', 'message' => 'required|min:10'); $page = Page::where('type', '=', 3)->first(); $entry = Catalog::find($id); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return View::make('front.pages.details')->withErrors($validator)->with(Input::all())->with(['entry' => $entry, 'page' => $page]); } else { $settingsEmail = Settings::where('key', '=', 'contact_email')->first(); $settingsEmailName = Settings::where('key', '=', 'contact_name')->first(); $data = array('subject' => 'Inventory contact Classiccarseurope.eu', 'to' => $settingsEmail->value, 'to_name' => $settingsEmailName->value, 'from_message' => Input::get('message'), 'from_name' => Input::get('name'), 'from' => Input::get('email'), 'phone' => Input::get('phone')); Mail::send('emails.front.contact', $data, function ($message) use($data) { $message->to($data['to'], $data['to_name'])->from($data['from'], $data['from_name'])->subject($data['subject']); }); return View::make('front.pages.details')->with(['entry' => $entry, 'page' => $page, 'message' => 'Mail send successfully']); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $inputs = Input::all(); $catalog = Catalog::find($id); $catalog->title = $inputs['title']; $catalog->description = $inputs['description']; $catalog->user_id = Auth::user()->id; $catalog->save(); $car = $catalog->car; if (empty($car)) { $car = new Car(); } else { $car = Car::find($catalog->car->id); } $car->brand = $inputs['brand']; $car->engine = $inputs['engine']; $car->make = $inputs['make']; $car->milage = $inputs['milage']; $car->type = $inputs['type']; $car->transmission = $inputs['transmission']; $car->status = $inputs['status']; $car->location = $inputs['location']; $car->price = $inputs['price']; $car->youtube = $inputs['youtube']; $car->main_pic = $inputs['main_pic']; $car->user_id = Auth::user()->id; $car->catalog_id = $catalog->id; $car->save(); $pictures = $inputs['pictures']; if (!File::isDirectory(user_photo_path() . $catalog->id . '/')) { File::makeDirectory(user_photo_path() . $catalog->id . '/', 0777, true, true); } if (isset($pictures) && count($pictures) > 0) { foreach ($pictures as $picture) { if ($picture != null) { $fileName = str_replace(' ', '_', strtolower($picture->getClientOriginalName())); $image = Image::make($picture->getRealPath()); $image->resize(1024, null, function ($constraint) { $constraint->aspectRatio(); })->save(user_photo_path() . $catalog->id . '/' . $fileName)->resize(750, null, function ($constraint) { $constraint->aspectRatio(); })->save(user_photo_path() . $catalog->id . '/' . '750-' . $fileName)->resize(500, null, function ($constraint) { $constraint->aspectRatio(); })->save(user_photo_path() . $catalog->id . '/' . '500-' . $fileName)->resize(250, null, function ($constraint) { $constraint->aspectRatio(); })->save(user_photo_path() . $catalog->id . '/' . '250-' . $fileName); $pic = new Pictures(); $pic->url = $fileName; $pic->user_id = Auth::user()->id; $pic->catalog_id = $catalog->id; $pic->type = 'catalog'; $pic->save(); } } } return Redirect::route('admin.catalog.index')->with('success', Lang::get('messages.catalog_updated')); }
/** * 删除 文件编目 */ function actionCatalogDel() { $this->_pathway->addStep('删除文件编目信息'); $id = $this->_context->id; if ($id < 6) { return '不能删除'; } $catalogs = Catalog::find("id = {$id} or path like '%,{$id},%'")->setColumns('id')->getAll(); $catalogs->destroy(); return 'true'; }
/** * @api {get} /courses/:id/bundle/detail Get Available Courses for bundle * @apiName Get Available Courses for bundle * @apiGroup Course * @apiDescription Returns a collection of items that can be shown in the a bundle. * * @apiSuccessExample {json} Success-Response: * HTTP/1.1 200 OK * [ * {"id":26453, * "code":"258010", * "name":"E-Course: Alto-Shaam: Combitherm Electric Oven Steamer", * "pak":"Combitherm Electric Oven Steamer", * "manufacturer":"Alto-Shaam", * "fuse_id":null, * "fuse_status":"", * "shortDescription":"short descr", * "note":null, * "isPublished":1, * "time":180,"type": * "course","safety":-1, * "html5":0,"video": * "https:\/\/player.vimeo.com\/video\/50304386", * "scorm_id":"ScormTest5f4888ea-f79b-4487-9346-6bc77c1a266d", * "scrom_zip_file_path":null, * "thumbnail":"http:\/\/localhost\/ignitor-api\/courses\/thumbnail\/26453", * "price" : "450", * "idSale" : "321" * } * ] */ public static function getCourseBundleDetail($idCourse) { $app = \Slim\Slim::getInstance(); $course = self::getCourseDetails($idCourse, false); if (!($course->type == "bundle")) { $app->halt("400", json_encode("Not a course")); } //$catalog = Catalog::where('id','=',$idCourse)->get(); $courseIds = Catalog::find($idCourse)->course->lists('id')->toArray(); $result = []; foreach ($courseIds as &$courseId) { $course = Course::find($courseId); $price = Price::where('course_id', $course->id)->orderBy('length')->first(); //priority if ($price) { $course['price'] = $price->price; $course['idSale'] = $price->id; } array_push($result, $course); } return json_encode($result); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $catalog = Catalog::find($id); $project = Project::find($catalog->project->id); $catalog->delete(); $project->delete(); return Redirect::route('admin.catalog.index')->with('success', Lang::get('messages.catalog_delete')); }