public function course($domain, $linkId, Request $request)
 {
     if ($request->token) {
         $user = JWTAuth::parseToken()->authenticate();
         $this->courseTransformer->setUser($user);
     }
     $courses = Course::all();
     $return_data = new \stdClass();
     foreach ($courses as $course) {
         if ($linkId == convert_vi_to_en($course->name)) {
             $return_data = $this->courseTransformer->transform($course);
         }
     }
     return $this->respond($return_data);
 }
 public function user_profile($domain, $username)
 {
     $target_user = User::where('username', $username)->first();
     if ($target_user) {
         return $this->respond(['user' => ['id' => $target_user->id, 'email' => $target_user->email, 'username' => $target_user->username, 'name' => $target_user->name, 'university' => $target_user->university, "description" => $target_user->description, "avatar_url" => $target_user->avatar_url ? $target_user->avatar_url : "http://api.colorme.vn/img/user.png", "work" => $target_user->work, "address" => $target_user->address, "phone" => $target_user->phone, "dob" => $target_user->dob, "gender" => $target_user->gender . "", "courses" => $target_user->registers->map(function ($register) {
             return ['linkId' => convert_vi_to_en($register->studyClass->course->name), 'icon_url' => $register->studyClass->course->icon_url];
         })->reduce(function ($carry, $item) {
             if (!in_array($item, $carry)) {
                 $carry[] = $item;
             }
             return $carry;
         }, [])]]);
     } else {
         return $this->responseBadRequest("username not existed");
     }
 }
 public function paid_courses()
 {
     if ($this->user->role == 0) {
         $courses = $this->user->registers()->where('status', 1)->get()->map(function ($register) {
             return ["id" => $register->studyClass->course->id, "name" => $register->studyClass->course->name, "linkId" => convert_vi_to_en($register->studyClass->course->name), "icon_url" => $register->studyClass->course->icon_url, "image_url" => $register->studyClass->course->image_url, "lessons" => $register->studyClass->course->lessons()->orderBy('order')->get()->map(function ($lesson) {
                 return ["order" => $lesson->order, "id" => $lesson->id, "name" => $lesson->name];
             })];
         });
         return $this->respond($courses->unique('id')->values());
     } else {
         return $this->respond(Course::all()->map(function ($course) {
             return ["id" => $course->id, "name" => $course->name, "linkId" => convert_vi_to_en($course->name), "icon_url" => $course->icon_url, "image_url" => $course->image_url, "lessons" => $course->lessons()->orderBy('order')->get()->map(function ($lesson) {
                 return ["order" => $lesson->order, "id" => $lesson->id, "name" => $lesson->name];
             })];
         }));
     }
 }
Esempio n. 4
0
 public function topic_detail($topicId)
 {
     $topic = Topic::find($topicId);
     $topic->author;
     $topic->remain_time = time_remain_string(strtotime($topic->deadline));
     $topic->time_create = time_elapsed_string(strtotime($topic->created_at));
     $topic->submits = count(array_unique($topic->products->pluck('author_id')->toArray()));
     $topic->all_products = $topic->products()->orderBy('created_at', 'desc')->get();
     foreach ($topic->all_products as &$product) {
         $product->liked = isset($this->user) && $this->user->likes()->where('product_id', $product->id)->count() > 0;
         $product->author->url = url('profile/' . get_first_part_of_email($product->author->email));
         $product->created_time = time_elapsed_string(strtotime($product->created_at));
         $product->author->avatar_url = $product->author->avatar_url != null ? $product->author->avatar_url : url('img/user.png');
         $product->count_likes = $product->likes()->count();
         $product->count_comments = $product->comments()->count();
         $product->link = url('post/colormevn-' . convert_vi_to_en($product->description) . '?id=' . $product->id);
     }
     unset($topic->products);
     return response()->json($topic, 200);
 }
Esempio n. 5
0
function createEmail($masv, $hoten)
{
    $hoten = convert_vi_to_en($hoten);
    $email = "";
    //cat 2 ky tu 2,3 trong masv de lay nam nhap hoc
    //sau do: + 2000 -1974=Khoa
    //tao email
    $nam = intval(substr($masv, 1, 2));
    if ($nam >= 4 && $nam <= 90) {
        $khoa = $nam + 2000 - 1974;
        switch ($khoa) {
            case 38:
            case 39:
                $email = firstName($hoten) . $masv;
                break;
            case 36:
            case 37:
                $email = firstName($hoten) . substr($masv, -6);
                break;
            case 35:
                $email = firstName($hoten) . substr($masv, -3);
                break;
            case 31:
            case 32:
            case 33:
            case 34:
                $email = beginLastName($hoten) . firstName($hoten) . substr($masv, -2);
                break;
            case 30:
                $email = firstName($hoten) . '.' . $masv;
                break;
            default:
                break;
        }
        $email = $email . '@student.ctu.edu.vn';
        return $email;
    } else {
        return "";
    }
}
 public function transform($notification)
 {
     $data = ['id' => $notification->id, 'receiver' => ['id' => $notification->receiver->id, 'avatar_url' => $notification->receiver->avatar_url == null ? url('img/user.png') : $notification->receiver->avatar_url, 'name' => $notification->receiver->name, 'username' => $notification->receiver->username], 'actor' => ['id' => $notification->actor->id, 'avatar_url' => $notification->actor->avatar_url == null ? url('img/user.png') : $notification->actor->avatar_url, 'name' => $notification->actor->name, 'username' => $notification->actor->username], 'created_at' => time_elapsed_string(strtotime($notification->created_at)), 'seen' => $notification->seen == 1];
     if ($notification->type <= 2 && $notification->type >= 0) {
         //            if ($notification->product == null) {
         //                $notification->delete();
         //            }
         $data['product'] = ['id' => $notification->product->id, 'linkId' => $notification->product->name ? convert_vi_to_en($notification->product->name) . "-" . $notification->product->id : "bai-tap-colorme-" . $notification->product->id];
     } else {
         if ($notification->type == 3 || $notification->type == 4) {
             $data['transaction'] = ['id' => $notification->transaction->id, 'status' => $notification->transaction->status, 'money' => currency_vnd_format($notification->transaction->money)];
             if ($notification->transaction->status != 0 && $notification->type == 3) {
                 $notification->type = 4;
                 $notification->save();
             }
         } else {
             if ($notification->type == 5) {
                 $data['topic'] = ['id' => $notification->topic->id];
             }
         }
     }
     $data['type'] = notification_type($notification->type);
     return $data;
 }
Esempio n. 7
0
                        });

                    </script>
                                        

                    <div class="row same-height-row">
                        <div class="col-md-2 col-sm-6">
                            
                                <div class="box same-height">
                                    <h3 style="color:green">Sản phẩm tương tự</h3>
                                </div>
                            
                        </div>
                        <?php 
foreach ($relative as $row) {
    $slug = convert_vi_to_en($row->name);
    ?>
                            <div class="col-md-2 col-sm-6">
                            
                                <div class="product same-height">
                                    <div class="flip-container">
                                        <div class="flipper">
                                            <div class="front">
                                                <a href="{{url('product-details/'.$row->id.'-product-'.$slug.'.html')}}">
                                                    <img src="{{asset('upload/product/'.$row->image)}}" alt="" class="img-responsive">
                                                </a>
                                            </div>
                                            <div class="back">
                                                <a href="{{url('product-details/'.$row->id.'-product-'.$slug.'.html')}}">
                                                    <img src="{{asset('upload/product/'.$row->image)}}" alt="" class="img-responsive">
                                                </a>
Esempio n. 8
0
 public function save_product($domain, Request $request)
 {
     if ($request->id) {
         $product = Product::find($request->id);
     } else {
         $product = new Product();
     }
     $product->description = $request->description;
     $product->title = $request->title;
     $product->content = $request->product_content;
     $product->author_id = $this->user->id;
     $product->tags = $request->tags_string;
     $product->category_id = $request->category_id;
     if ($request->video_url) {
         $product->url = $request->video_url;
         $product->image_name = $request->video_name;
         $product->thumb_url = $request->thumb_url;
     } else {
         $product->url = $request->image_url;
         $product->image_name = $request->image_name;
         $product->thumb_name = $request->thumb_name;
         $product->thumb_url = $request->thumb_url;
     }
     $product->type = 2;
     $product->save();
     foreach ($product->colors as $color) {
         $color->delete();
     }
     $colorStr = $request->colorStr;
     $colors = explode("#", $colorStr);
     foreach ($colors as $c) {
         $color = new Color();
         $color->product_id = $product->id;
         $color->value = $c;
         $color->save();
     }
     return $this->respond(['message' => "Đăng bài thành công", "url" => convert_vi_to_en($product->title) . "-" . $product->id]);
 }
Esempio n. 9
0
                    <!-- /.box -->
                </div>
                <!-- /#blog-post -->

                <div class="col-sm-3">
                    <div class="panel panel-default sidebar-menu">

                        <div class="panel-heading">
                            <h3 class="panel-title">Tin tức khác</h3>
                        </div>

                        <div class="panel-body">

                            <?php 
foreach ($news as $new) {
    $slug = convert_vi_to_en($new->title);
    ?>
                            <div class="box">
                                <div class="row">
                                    <div class="image">
                                        <a href="{{url('news/'.$new->id.'-'.$slug.'.html')}}">
                                            <img src="{{asset('upload/news/'.$new->image)}}" class="img-responsive" alt="{{$new->title}}">
                                        </a>
                                    </div>
                                    <h4><center><a href="{{url('news/'.$new->id.'-'.$slug.'.html')}}">{{$new->title}}</a></center></h4>
                                    <p class="author-category">By <a href="#"><em><?php 
    foreach ($auth as $author) {
        if ($author->id == $new->author_id) {
            echo $author->name;
        }
    }
Esempio n. 10
0
 public function test()
 {
     $products = Product::whereBetween('id', [0, 50])->get();
     foreach ($products as $product) {
         re_scrape(url('/post/' . convert_vi_to_en($product->description) . '-' . $product->id));
     }
     return 'done';
 }
Esempio n. 11
0
            
                                        <div class="table-responsive">
                                            <table class="table">
                                                <thead>
                                                    <tr>
                                                        <th colspan="2">Sản phẩm</th>
                                                        <th>Số lượng</th>
                                                        <th>Đơn Giá</th>
                                                        <th>Giảm giá</th>
                                                        <th colspan="2">Thành tiền</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                @foreach($data as $showdata)
                                                    <?php 
    $slug = convert_vi_to_en($showdata['name']);
    ?>
 
                                                    <tr>
                                                        <td>
                                                            <a href="{{url('product-details/'.$showdata['id'].'-product-'.$slug.'.html')}}">
                                                                <img src="{{asset('upload/product/'.$showdata['thumbnail'])}}" alt="{{$showdata['name']}}">
                                                            </a>
                                                        </td>
                                                        <td><a href="{{url('product-details/'.$showdata['id'].'-product-'.$slug.'.html')}}">{{$showdata['name']}}</a>
                                                        </td>
                                                        <td>
                                                            <input type="number" value="{{$showdata['quantity']}}" class="form-control">
                                                        </td>
                                                        <td><?php 
    echo number_format($showdata['price']);
Esempio n. 12
0
 public function transform($product)
 {
     $data = ['id' => $product->id, 'type' => $product->type, 'views_count' => $product->views, 'title' => "Bài tập ColorME", 'likes_count' => $product->likes()->count(), 'created_at' => time_elapsed_string(strtotime($product->created_at)), 'comments_count' => $product->comments()->count(), 'author' => $this->authorTransformer->transform($product->author), 'tags' => explode(",", $product->tags), 'more_products' => [], 'likers' => $product->likes->map(function ($like) {
         return ['name' => $like->liker->name, 'username' => $like->liker->username, 'avatar_url' => $like->liker->avatar_url ? $like->liker->avatar_url : "http://d1j8r0kxyu9tj8.cloudfront.net/webs/user.png"];
     })];
     if ($product->category) {
         $data['category'] = ['name' => $product->category->name, 'id' => $product->category->id];
         $data['category_id'] = $product->category->id;
     }
     if ($this->user) {
         $liked = $product->likes()->where('liker_id', $this->user->id)->first() != null;
         $data['liked'] = $liked;
     }
     switch ($product->type) {
         case 0:
             $data['thumb_url'] = $product->thumb_url;
             $data['image_url'] = $product->url;
             //                $data['tags'] = $product->tags;
             $data['description'] = $product->description;
             break;
         case 1:
             $data['video_url'] = $product->url;
             //                $data['tags'] = $product->tags;
             $data['description'] = $product->description;
             break;
         case 2:
             if ($product->thumb_name) {
                 $data['thumb_url'] = $product->thumb_url;
                 $data['thumb_name'] = $product->thumb_name;
                 $data['image_url'] = $product->url;
                 $data['colors'] = $product->colors->map(function ($color) {
                     return $color->value;
                 });
             } else {
                 $data['video_url'] = $product->url;
                 $data['thumb_url'] = $product->thumb_url;
             }
             //                $data['tags'] = $product->tags;
             $data['title'] = $product->title;
             $data['description'] = $product->description;
             break;
         case 3:
             if ($product->thumb_url) {
                 $data['thumb_url'] = $product->thumb_url;
                 $data['image_url'] = $product->url;
                 $data['sub_type'] = 0;
             } else {
                 $data['video_url'] = $product->url;
                 $data['sub_type'] = 1;
             }
             //                $data['tags'] = $product->tags;
             $data['title'] = $product->title;
             $data['description'] = $product->description;
             break;
     }
     if ($data['title'] == null || $data['title'] == "") {
         $data['title'] = "Bài tập ColorME";
     }
     $data['linkId'] = convert_vi_to_en($data['title']) . "-" . $product->id;
     return $data;
 }
Esempio n. 13
0
                    <div class="panel panel-default sidebar-menu">

                        <div class="panel-heading">
                            <h3 class="panel-title">Sản phẩm đã xem</h3>
                        </div>

                        <div class="panel-body">

                            <?php 
$data = Session::get('cookie');
if (!is_null($data)) {
    foreach ($data as $value) {
        $slug = convert_vi_to_en($value['name']);
        ?>
                            <div class="product same-height">
                                <div class="flip-container">
                                    <div class="flipper">
                                        <div class="front">
                                            <a href="{{url('product-details/'.$value['id'].'-product-'.$slug.'.html')}}">
                                                <img src="{{asset('upload/product/'.$value['thumbnail'])}}" alt="" class="img-responsive">
                                            </a>
                                        </div>
                                        <div class="back">
                                            <a href="{{url('product-details/'.$value['id'].'-product-'.$slug.'.html')}}">
                                                <img src="{{asset('upload/product/'.$value['thumbnail'])}}" alt="" class="img-responsive">
                                            </a>
                                        </div>
                                    </div>
                                </div>
                                <a href="{{url('product-details/'.$value['id'].'-product-'.$slug.'.html')}}" class="invisible">
                                    <img src="{{asset('upload/product/'.$value['thumbnail'])}}" alt="" class="img-responsive">
Esempio n. 14
0
                    <thead>
                      <tr>
                        <th>image</th>
                        <th>title</th>
                        <th>desciption</th>
                        <th>content</th>
                        <th>author</th>
                        <th width="10%">update</th>
                        <th width="10%">delete</th>
                      </tr>
                    </thead>
                    <tbody>
                    @include ('frontend.includes.format')
                      <?php 
foreach ($news as $row) {
    $slug = convert_vi_to_en($row->title);
    ?>
                      <tr>
                        <td>
                          <?php 
    if (!$row->image) {
        echo "NULL";
    } else {
        ?>
                          <img src="{{Asset('upload/news/'.$row->image)}}" height="50" width="50">
                          <?php 
    }
    ?>
                        </td>
                        <td><h4><a href="{{url('news/'.$row->id.'-'.$slug.'.html')}}"> {{$row->title}}</a></h4></td>
                        <td><textarea class="form-control" rows="3" name="description"><?php 
 public function transform($regis)
 {
     return ['id' => $regis->id, 'course_name' => $regis->studyClass->course->name, 'class' => "lớp " . $regis->studyClass->name, 'code' => $regis->code, 'money' => $regis->money, 'note' => $regis->note, 'paid_time' => $regis->paid_time, 'status' => $regis->status, 'avatar_url' => $regis->studyClass->course->icon_url, 'link' => "/course/" . convert_vi_to_en($regis->studyClass->course->name)];
 }