public function upload(Request $request)
 {
     $file = $request->file('image');
     if (Input::hasFile('image')) {
         $destinationPath = '/storage/avatars/';
         $size = $file->getSize();
         if ($size <= 41943040) {
             $fileName = Auth::user()->id . '.' . 'jpg';
             $file->move(base_path() . $destinationPath, $fileName);
             if (DB::table('photos')->where('user_id', Auth::user()->id)->value('user_id') == Auth::user()->id) {
             } else {
                 $photos = new Photo();
                 //обращается к контроллеру???
                 $photos->user_id = Auth::user()->id;
                 $photos->url = 'storage/avatars/' . $fileName;
                 //ссылки на картинки
                 $photos->main = 1;
                 $photos->save();
             }
             return view('home');
         } else {
             return view('errors.bigFile');
         }
     } else {
         return view('errors.noUploadFile');
     }
 }
Example #2
0
 /**
  * 根据ID获取相册所有图片
  * @param $id
  * @return $this
  */
 public function GetPhoList($id)
 {
     $photoSrv = new Photo();
     $albumSrv = new Album();
     $result['photo'] = $photoSrv->GetPhoList($id);
     $result['album'] = $albumSrv->GetAlbumInfo($id);
     return view('mei.pholist')->with('result', $result);
 }
 public function actionUpload()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $result = [];
     $files = UploadedFile::getInstances(new File(), 'uploadedFiles');
     foreach ($files as $index => $file) {
         $model = new File();
         $model->uploadedFiles = [$file];
         $model->user_id = Yii::$app->user->id;
         $model->storage = File::STORAGE_OS;
         $model->extension = $file->extension;
         $model->type = File::defineType($model->extension);
         if ($model->upload()) {
             $item = ['id' => $model->id, 'url' => $model->getUrl(), 'type' => $model->getMimeType()];
             if ($releaseId = Yii::$app->request->get('rid')) {
                 $release = Release::findOne($releaseId);
                 if ($release && $release->artist->user_id == Yii::$app->user->id) {
                     if ($model->type == $model::TYPE_IMAGE) {
                         $cover = new Cover(['release_id' => $release->id, 'file_id' => $model->id, 'is_main' => false]);
                         $cover->save();
                         $item['image_id'] = $cover->id;
                     } elseif ($model->type == $model::TYPE_AUDIO) {
                         $track = new Track(['release_id' => $release->id, 'original_name' => $file->baseName, 'number' => $release->getTracks()->count() + 1, 'file_id' => $model->id]);
                         $track->save();
                         $item['track_id'] = $track->id;
                         $item['comname'] = $track->getComname();
                         $item['number'] = $track->number;
                     }
                 }
             }
             if ($artistId = Yii::$app->request->get('aid')) {
                 $photo = new Photo(['artist_id' => (string) $artistId, 'file_id' => $model->id, 'is_main' => false]);
                 $artist = Artist::findOne($artistId);
                 if ($artist && $artist->user_id == Yii::$app->user->id) {
                     $photo->save();
                     $item['image_id'] = $photo->id;
                 }
             }
             //                if ($model->type == $model::TYPE_AUDIO) {
             //                    $getID3 = new getID3();
             //                    $tags = $getID3->analyze($model->getPath(true))['tags']['id3v2'];
             //                    $item['meta'] = [
             //                        'title' => $tags['title'][0],
             //                        'number' => explode('/', $tags['track_number'][0])[0],
             //                        'disc' => explode('/', $tags['part_of_a_set'][0])[0],
             //                        'lyric' => $tags['unsynchronised_lyric'][0],
             //                        'info' => $tags['comment'][0],
             //                    ];
             //                }
             if ($model->type == $model::TYPE_AUDIO) {
                 $item['meta'] = ['title' => $file->baseName, 'number' => $index + 1, 'disc' => '', 'lyric' => '', 'info' => ''];
             }
             $result[] = $item;
         }
     }
     return $result;
 }
Example #4
0
 /**
  * Display the specified resource.
  *
  * @param Request $request
  * @param  Photo $photo
  * @return \Illuminate\Http\Response
  */
 public function show(Request $request, $photo)
 {
     //
     if ($request->ajax()) {
         $uploader = $photo->owner->full_name;
         $rs = $photo->toArray();
         $rs['uploader'] = $uploader;
         return json_encode($rs);
     }
 }
 /**
  * @param array $attributes
  */
 public function saveFromArray(array $attributes = array())
 {
     $this->model->fill($attributes);
     $this->model->save();
     $attributes['customer_id'] = $this->model->id;
     if (isset($attributes['images'])) {
         foreach ($attributes['images'] as $image) {
             $photoModel = new Models\Photo();
             $params = ['customer_id' => $this->model->id, 'image' => $image];
             $photoModel->getRepository()->saveFromArray($params);
         }
     }
 }
Example #6
0
 public static function getComments($user_id, $type, $limit, $contentId, $contentType)
 {
     if ($contentId) {
         $date = (new Query())->select('date_time')->from('comments_' . $contentType)->where(['id' => $contentId])->scalar();
     }
     if ($type == 'user') {
         $articles_id = false;
         $photos_id = false;
         $club_photos_id = false;
     } else {
         $articles_id = Blog::getAllArticlesIdByAuthor($user_id);
         $photos_id = Photo::getAllPhotosIdByAuthor($user_id);
         $club_photos_id = ClubPhoto::getAllClubPhotosIdByAuthor($user_id);
     }
     $comment_blog_query = CommentsBlog::getCommentsQuery($user_id, $type, $articles_id);
     $comment_photo_query = CommentsPhoto::getCommentsQuery($user_id, $type, $photos_id);
     $comment_club_query = CommentsClub::getCommentsQuery($user_id, $type, $club_photos_id);
     $all_comments = $comment_blog_query->union($comment_photo_query, true)->union($comment_club_query, true);
     $sql = (new Query())->from(['ac' => $all_comments])->limit($limit)->orderBy('comment_date_time desc');
     if ($contentId) {
         $sql->andWhere(['<', 'comment_date_time', $date]);
     }
     $all_comments = $sql->all();
     foreach ($all_comments as &$comment) {
         self::DateCommentsInCorrectFormat($comment);
     }
     return $all_comments;
 }
 /**
  * Creates a new Artist model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Artist();
     $photos = [];
     if (Yii::$app->request->isPost) {
         for ($i = 0; $i < count(Yii::$app->request->post('Photo', [])); $i++) {
             $photos[] = new Photo();
         }
         $data = Yii::$app->request->post();
         $data['Artist']['user_id'] = Yii::$app->user->id;
     } else {
         $data = null;
     }
     if ($model->load($data) && $model->save()) {
         Photo::loadMultiple($photos, Yii::$app->request->post());
         foreach ($photos as $photo) {
             $photo->artist_id = $model->id;
         }
         if (Photo::validateMultiple($photos)) {
             foreach ($photos as $photo) {
                 $model->link('photos', $photo);
             }
         }
         $tags = Yii::$app->request->post('Artist', '');
         $tags = Tag::find()->where(['in', 'id', explode(',', $tags['tags'])])->all();
         foreach ($tags as $tag) {
             $model->link('tags', $tag);
         }
         return $this->redirect(['release/index', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'photos' => $photos]);
     }
 }
 public function addPhoto($id, Request $request)
 {
     $this->validate($request, ['photo' => 'required']);
     $file = $request->file('photo');
     $photo = Photo::named($file->getClientOriginalName())->move($file);
     Product::find($id)->addPhoto($photo);
 }
Example #9
0
 /**
  * @return string
  */
 public function getThumbnailAttribute()
 {
     $photo = $this->avatar;
     if ($photo == null) {
         return Photo::samplePhotoUrl();
     }
     return $photo->src;
 }
Example #10
0
 /**
  * @SWG\Api(
  *   path="/photo/add",
  *   @SWG\Operation(
  *     nickname="Add new photo",
  *     method="POST",
  *     summary="Add new photo",
  *     notes="Returns photo",
  *     type="Photo",
  *     authorizations={},
  *     @SWG\Parameter(
  *       name="customer_id",
  *       description="Customer ID",
  *       required=true,
  *       type="integer",
  *       format="int64",
  *       paramType="form",
  *       allowMultiple=false
  *     ),
  *     @SWG\Parameter(
  *       name="image",
  *       description="Image",
  *       type="file",
  *       required=true,
  *       allowMultiple=true,
  *       paramType="body"
  *     ),
  *     @SWG\ResponseMessage(code=500, message="Internal server error")
  *   )
  * )
  */
 public function add()
 {
     $statusCode = 200;
     $inputs = \Input::all();
     $validator = Validator::make($inputs, ['customer_id' => 'required|numeric|exists:customers,id', 'image' => 'required|image']);
     if ($validator->fails()) {
         $response = ['error' => $validator->errors()];
         $statusCode = 500;
     } else {
         $params = ['customer_id' => $inputs['customer_id'], 'image' => $inputs['image']];
         $photo = new Models\Photo();
         $photo->getRepository()->saveFromArray($params);
         $photoView = new ModelViews\Photo($photo);
         $response = $photoView->get();
     }
     return \Response::json($response, $statusCode);
 }
 public function actionPhoto()
 {
     $id = Yii::$app->request->get('id');
     $photos = Photo::findAll(['section' => $id]);
     if (Yii::$app->request->isAjax) {
         return json_encode(['title' => Yii::t('app', 'Photo') . " - " . Yii::t('app', 'Video operator for a wedding Kiev') . " ZEFIRMA " . Yii::t('app', 'Wedding videography and wedding video'), 'html' => $this->renderPartial('photo', ['title' => Yii::t('app', 'Photo') . " - " . Yii::t('app', 'Video operator for a wedding Kiev') . " ZEFIRMA " . Yii::t('app', 'Wedding videography and wedding video'), 'photos' => $photos])]);
     }
     return $this->render('photo', ['title' => Yii::t('app', 'Photo') . " - " . Yii::t('app', 'Video operator for a wedding Kiev') . " ZEFIRMA " . Yii::t('app', 'Wedding videography and wedding video'), 'photos' => $photos]);
 }
Example #12
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $photo = Photo::findOrFail($id);
     $storagePath = \Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix();
     $url = $storagePath . $photo->image_url;
     $photo->image_url = $url;
     $data = ['photo' => $photo];
     return view('photo.show', $data);
 }
 public function delete(Request $request)
 {
     $photo = Photo::find($request->input('id'));
     if (File::exists($photo->image_url)) {
         File::delete($photo->image_url);
     }
     $photo->delete();
     return response()->json(['success' => true, 'message' => "Изображение успешно удалено."]);
 }
Example #14
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function index(Request $request)
 {
     $email = Option::where('key', 'contact.email')->first()->value;
     $phone = Option::where('key', 'contact.phone')->first()->value;
     $company_data = array('name' => Option::where('key', 'company.name')->first()->value, 'address' => nl2br(Option::where('key', 'company.address')->first()->value), 'legal_left' => nl2br(Option::where('key', 'company.legal.left')->first()->value), 'legal_right' => nl2br(Option::where('key', 'company.legal.right')->first()->value));
     $social_links = array('facebook' => Option::where('key', 'facebook.link')->first()->value, 'twitter' => Option::where('key', 'twitter.link')->first()->value, 'youtube' => Option::where('key', 'youtube.link')->first()->value, 'linkedin' => Option::where('key', 'linkedin.link')->first()->value, 'instagram' => Option::where('key', 'instagram.link')->first()->value);
     $data = array('photos' => Photo::orderBy('sort_order')->get(), 'email' => $email, 'phone' => $phone, 'social_links' => $social_links, 'company_data' => $company_data);
     return view('contact', $data);
 }
Example #15
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function index(Request $request)
 {
     $email = Option::where('key', 'contact.email')->first()->value;
     $phone = Option::where('key', 'contact.phone')->first()->value;
     $slogan = Option::where('key', 'site.slogan')->first()->value;
     $social_links = array('facebook' => Option::where('key', 'facebook.link')->first()->value, 'twitter' => Option::where('key', 'twitter.link')->first()->value, 'youtube' => Option::where('key', 'youtube.link')->first()->value, 'linkedin' => Option::where('key', 'linkedin.link')->first()->value, 'instagram' => Option::where('key', 'instagram.link')->first()->value);
     $data = array('services' => Service::orderBy('sort_order')->get(), 'clients' => Client::orderBy('sort_order')->get(), 'photos' => Photo::orderBy('sort_order')->get(), 'email' => $email, 'phone' => $phone, 'slogan' => $slogan, 'social_links' => $social_links);
     return view('home', $data);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $file = $request->file('pic');
     $uploader = new FileUpload();
     $uploader = $uploader->uploadPic($file, 'insertions/');
     $post = new Insertion();
     $post->title = $request->title;
     $post->description = $request->description;
     $post->author_id = Auth::user()->id;
     $post->save();
     $photos = new Photo();
     $photos->user_id = Auth::user()->id;
     $photos->insertion_id = $post->id;
     $photos->url = '/storage/insertions/' . $uploader;
     //?????? ?? ????????
     $photos->main = 1;
     $photos->save();
     return redirect()->action('Insertions\\PostsController@index');
 }
 /**
  * Deletes a photo from the database.
  *
  * @param  $id - Id of the pack to be deleted
  * @return Response
  * @throws ResourceNotFoundException
  */
 public function delete($id)
 {
     $id = $this->filter->sanitize($id, 'int');
     try {
         $photo = Photo::findFirstOrFail(['id = ?0', 'bind' => [$id]]);
         return $this->response($this->request, $photo);
     } catch (ResourceNotFoundException $e) {
         return $e->returnResponse();
     }
 }
Example #18
0
 /**
  * Deletes photos
  *
  * @param integer $photoId
  * @return array
  */
 public function deletePhoto($photoId)
 {
     try {
         $photoModel = Models\Photo::where('id', $photoId)->first();
         $photoModel->delete();
         $result = ['error' => false];
     } catch (ModelNotFoundException $exception) {
         $result = ['error' => true, 'message' => $exception->getMessage()];
     }
     return json_encode($result);
 }
Example #19
0
 static function multiple_uploadPic($path)
 {
     // getting all of the post data
     $files = Input::file('images');
     // Making counting of uploaded images
     $file_count = count($files);
     // start count how many uploaded
     $uploadcount = 0;
     if ($uploadcount < 3) {
         foreach ($files as $file) {
             $rules = array('file' => 'required');
             //'required|mimes:png,gif,jpeg,txt,pdf,doc'
             $validator = Validator::make(array('file' => $file), $rules);
             if ($validator->passes()) {
                 $destinationPath = '/storage/' . $path;
                 $fileName = DB::table('photos')->max('id') + 1 . '-' . $file->getClientOriginalName();
                 /*(DB::table('photos')->max('id')) + 1 */
                 $file->move(base_path() . $destinationPath, $fileName);
                 $photos = new Photo();
                 if ($uploadcount == 0) {
                     $photos->advert_id = DB::table('advert')->max('id') + 1;
                     $photos->main = 1;
                 } else {
                     $photos->advert_id = DB::table('advert')->max('id') + 1;
                     $photos->main = 0;
                 }
                 $photos->url = '/storage/adverts/' . $fileName;
                 //ссылки на картинки
                 $photos->save();
                 $uploadcount++;
             }
         }
     }
     /*            if($uploadcount == $file_count){
                     return $fileName[];
                 }
                 else {
                     return Redirect::to('posts.index')->withInput()->withErrors($validator);
                 }*/
 }
Example #20
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Photo::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'artist_id' => $this->artist_id, 'file_id' => $this->file_id, 'is_main' => $this->is_main]);
     return $dataProvider;
 }
 public function actionUpload()
 {
     $file = UploadedFile::getInstanceByName('file');
     if ($file->hasError) {
         throw new ServerErrorHttpException('Ошибка при загрузке');
     }
     /** @var Users $user */
     $user = Users::findOne(Yii::$app->request->post('user_id'));
     if (!$user) {
         throw new NotFoundHttpException('Не наден пользователь');
     }
     $fileName = $file->name;
     $uploadDir = Yii::getAlias('@webroot/images/' . $user->id . '/');
     FileHelper::createDirectory($uploadDir);
     // Thumbnail
     $img = Image::getImagine()->open($file->tempName);
     $size = $img->getSize();
     $ratio = $size->getWidth() / $size->getHeight();
     $width = Yii::$app->params['thumbnailWidth'];
     $height = round($width / $ratio);
     // Save thumbnail
     Image::thumbnail($file->tempName, $width, $height)->save($uploadDir . 'thumbnail_' . $fileName, ['quality' => 70]);
     // Save image
     if (file_exists($uploadDir . $fileName)) {
         $fileName = $file->baseName . '-' . uniqid() . '.' . $file->extension;
     }
     if (!$file->saveAs($uploadDir . $fileName)) {
         throw new ServerErrorHttpException('Ошибка при сохранении файла');
     }
     // Save model
     $model = new Photo();
     $model->user_id = $user->id;
     $model->project_id = $user->project_id;
     $model->filename = $fileName;
     $model->save();
     $response = ['filename' => $fileName];
     return Json::encode($response);
 }
Example #22
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Photo::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['idphoto' => $this->idphoto]);
     $query->andFilterWhere(['like', 'photo', $this->photo])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #23
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Photo::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'width' => $this->width, 'heigth' => $this->heigth]);
     $query->andFilterWhere(['like', 'reference', $this->reference])->andFilterWhere(['like', 'place_id', $this->place_id]);
     return $dataProvider;
 }
Example #24
0
 public static function viewPhoto($photo_id)
 {
     if (!Yii::$app->user->isGuest) {
         $cookies_req = Yii::$app->request->cookies;
         $cookies_res = Yii::$app->response->cookies;
         $photo_views = $cookies_req->getValue('photo_views');
         $photo_views = explode('|', $photo_views);
         if (!in_array($photo_id, $photo_views)) {
             $photo_views[] = $photo_id;
             $cookies_res->add(new Cookie(['name' => 'photo_views', 'value' => implode('|', $photo_views), 'expire' => time() + 86400 * 30]));
             Photo::updateViews($photo_id);
             Rating::view($photo_id, Rating::PHOTO);
         }
     }
 }
Example #25
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(\App\Http\Requests\CreatePostRequest $request)
 {
     $input = \Request::all();
     $post = \App\Models\Post::create($input);
     foreach ($input['labels'] as $labelID) {
         $post->labels()->attach($labelID);
     }
     $photos = \App\Models\Photo::where("temp_id", \Request::get("photo_temp_id"))->get();
     //attaching photos to posts
     foreach ($photos as $photo) {
         $photo->post_id = $post->id;
         $photo->save();
     }
     return redirect("posts/" . $post->id);
 }
Example #26
0
 /**
  * Default width for image request is 600px
  * @param Request $request
  * @param $filename
  * @return mixed
  */
 private function getImage(Request $request, $filename)
 {
     /** @var int $maxWidth */
     $maxWidth = $request->query('w', 600);
     /** @var \Illuminate\Filesystem\FilesystemAdapter $disk */
     $disk = Storage::disk();
     try {
         $file = $disk->get('/imgtemp/' . $filename);
         $file = Photo::resize_photo($file, $maxWidth);
     } catch (Exception $e) {
         return response()->json((array) $disk, 404);
     }
     $mime = $disk->mimeType('/imgtemp/' . $filename);
     $response = response()->make($file, 200, ["Content-Type" => $mime]);
     return $response;
 }
Example #27
0
 public function actionShow($id)
 {
     $model = Photo::findOne($id);
     $marks = AdminPhoto::getMarks($id);
     $comments = AdminCommon::getComments('photo', $id, 0, 5);
     $content = ['content_type' => 'photo', 'content_id' => $id];
     $categories = Category::getAllCategory();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->save();
     }
     $photo = AdminPhoto::getPhotoInfo($id);
     if (!isset($photo['photo_id'])) {
         return $this->render('error.404.php');
     }
     return $this->render('show', ['photo' => $photo, 'marks' => $marks, 'comments' => $comments, 'model' => $model, 'categories' => $categories, 'content' => $content]);
 }
Example #28
0
 public function actionConfirm()
 {
     if (!Yii::$app->request->post() or !Yii::$app->request->isAjax) {
         throw new BadRequestHttpException('Only POST Ajax requests');
     }
     $checkedPhotosId = Yii::$app->request->post('checkedPhotos');
     if (!$checkedPhotosId or $checkedPhotosId == []) {
         throw new \HttpInvalidParamException('No photos');
     }
     /** @var Users $user */
     $user = Yii::$app->session->get('user');
     if (!$user) {
         throw new UnauthorizedHttpException('Need login');
     }
     $checkedPhotosNames = [];
     // Mark selected photos
     foreach ($checkedPhotosId as $checkedPhotoId) {
         /** @var Photo $photoModel */
         $photoModel = Photo::findOne($checkedPhotoId);
         if (!$photoModel) {
             throw new NotFoundHttpException('Photo ' . $checkedPhotoId . ' not found');
         }
         if ($photoModel->project_id !== $user->project_id) {
             throw new HttpException(403);
         }
         if ($photoModel->selected === true) {
             continue;
         }
         $photoModel->selected = true;
         $photoModel->save();
         $checkedPhotosNames[] = '#' . $photoModel->id . ' - ' . $photoModel->filename;
     }
     // Deselect not checked photos
     $checkedPhotos = Photo::findAll(['user_id' => $user->id, 'selected' => true]);
     foreach ($checkedPhotos as $checkedPhoto) {
         if (!in_array($checkedPhoto->id, $checkedPhotosId)) {
             $checkedPhoto->selected = false;
             $checkedPhoto->save();
         }
     }
     // Notify by email
     try {
         Yii::$app->mailer->compose('checked', ['checkedPhotosNames' => $checkedPhotosNames, 'user' => $user])->setFrom([Yii::$app->params['siteEmail'] => 'Fotoboom.net'])->setTo(Yii::$app->params['adminEmail'])->setSubject('Пользователь ' . $user->name . ' выбрал фото')->send();
     } catch (\Exception $e) {
     }
     return json_encode(['success' => true, 'message' => 'Выбранные фото успешно отправлены фотографу. Теперь вы можете просто закрыть страницу.']);
 }
 public function show($id)
 {
     if ($id) {
         if ($id == "photos") {
             $datas = Photo::get();
         } elseif ($id == "videos") {
             $datas = Video::get();
         } elseif ($id == "documents") {
             $datas = Document::get();
         } elseif ($id == "audios") {
             $datas = Audio::get();
         } elseif ($id == "uploadedfiles") {
             $datas = UploadedFile::get();
         }
         return view("Modvel::admin." . $this->theme . ".files.show")->with('datas', $datas)->with('headName', $this->headName);
     }
 }
Example #30
0
 public function run()
 {
     if (strpos(\Yii::$app->request->url, "view-post")) {
         $post = Post::findOne(\Yii::$app->request->get('id'));
         $current_page = $post->page;
     } else {
         if (strpos(\Yii::$app->request->url, "view-album")) {
             $photo = Photo::findOne(\Yii::$app->request->get('id'));
             $current_page = $photo->page;
         } else {
             $slug = \Yii::$app->request->get('slug');
             $current_page = Page::find()->where(['slug' => $slug])->one();
         }
     }
     $parent = $current_page->parent_id == 0 ? null : Page::findOne($current_page->parent_id);
     return $this->render('breadCrumb', ['parent' => $parent, 'current_page' => $current_page]);
 }