Exemplo n.º 1
0
 public function getTagListAttributeRu()
 {
     if (isset($this->id)) {
         $postId = $this->id;
         // Post ID
         $result = \Model\Tag\Tag::where('lang', '=', 'ru')->get();
         $tagsRu = $this->tags->lists('id')->toArray();
         $array = [];
         foreach ($result as $row) {
             foreach ($tagsRu as $tagRu) {
                 if ($tagRu == $row->id) {
                     $array[] = $row;
                 }
             }
         }
         return $array;
     } else {
         return [];
     }
 }
Exemplo n.º 2
0
 public function update(Request $request, PhotoChild $photoChild)
 {
     $photoChild->update($request->except('file', 'tag_kg', 'tag_ru', 'q'));
     $tag_kg_string = $request->input('tag_kg');
     $tags = explode("; ", $tag_kg_string);
     $tag_ru_string = $request->input('tag_ru');
     $tags2 = explode("; ", $tag_ru_string);
     if (!empty($tags)) {
         foreach ($tags as $key => $name) {
             if (!is_numeric($name) && !empty($name)) {
                 $tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
                 $tag->name = $name;
                 $tag->save();
                 $tags[$key] = $tag->id();
             }
         }
         //            $post->tags()->sync($tags);
     }
     // end if
     if (!empty($tags2)) {
         foreach ($tags2 as $key => $name) {
             if (!is_numeric($name) && !empty($name)) {
                 $tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
                 $tag->name = $name;
                 $tag->save();
                 $tags2[$key] = $tag->id();
             }
         }
         //            $post->tags()->sync($tags2);
     }
     // end if
     $tagsCommon = array_collapse([$tags, $tags2]);
     $photoChild->tags()->sync($tagsCommon);
     if ($request->hasFile('file')) {
         $file = $request->file('file');
         $time = time();
         $dir = 'froala/uploads';
         $name = $photoChild->id() . $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         Image::make($_FILES['file']['tmp_name'])->heighten(600)->save($dir . '/' . $name);
         $photoChild->file = $dir . '/' . $name;
         $photoChild->save();
     }
     return redirect()->route('admin.photoChild.show', $photoChild);
 }
Exemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Post $post)
 {
     $post->update($request->except('tag_kg', 'tag_ru', 'thumbnail', 'q', 'channel_id', 'created_at', 'time'));
     $tag_kg_string = $request->input('tag_kg');
     $tags = explode("; ", $tag_kg_string);
     $tag_ru_string = $request->input('tag_ru');
     $tags2 = explode("; ", $tag_ru_string);
     if (!empty($tags)) {
         foreach ($tags as $key => $name) {
             if (!is_numeric($name) && !empty($name)) {
                 $tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
                 $tag->name = $name;
                 $tag->save();
                 $tags[$key] = $tag->id();
             }
         }
         //            $post->tags()->sync($tags);
     }
     // end if
     if (!empty($tags2)) {
         foreach ($tags2 as $key => $name) {
             if (!is_numeric($name) && !empty($name)) {
                 $tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
                 $tag->name = $name;
                 $tag->save();
                 $tags2[$key] = $tag->id();
             }
         }
         //            $post->tags()->sync($tags2);
     }
     // end if
     $tagsCommon = array_collapse([$tags, $tags2]);
     $post->tags()->sync($tagsCommon);
     if ($request->hasFile('thumbnail')) {
         $file = $request->file('thumbnail');
         $dir = 'img/thumbnail';
         $btw = time();
         $name = $post->id() . $btw . '.' . $file->getClientOriginalExtension();
         $name2 = $post->id() . $btw . '_big.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         Image::make($_FILES['thumbnail']['tmp_name'])->fit(250, 150)->save($dir . '/' . $name);
         Image::make($_FILES['thumbnail']['tmp_name'])->fit(500, 300)->save($dir . '/' . $name2);
         $post->thumbnail = $dir . '/' . $name;
         $post->thumbnail_big = $dir . '/' . $name2;
         $post->save();
     }
     if ($request->input('channel_id') == null) {
         $channel_id = 1;
         $post->channel_id = $channel_id;
     }
     if ($request->input('created_at') != null) {
         $time = $request->input('time');
         $postDate = $request->input('created_at');
         $timeToSave = date('H:i:s', strtotime($time));
         $saveDate = date('Y-m-d', strtotime($postDate));
         $result = $saveDate . ' ' . $timeToSave;
         $post->created_at = $result;
         $post->save();
     } else {
         $today = date('Y-m-d H:i:s');
         dd($today);
         $post->created_at = date('Y-m-d H:i:s');
         $post->save();
     }
     return redirect()->route('admin.post.show', $post);
 }
Exemplo n.º 4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Post $post)
 {
     $post->update($request->except('tag_list', 'tag_list2', 'thumbnail', 'q'));
     $tags = $request->input('tag_list');
     $tags2 = $request->input('tag_list2');
     if (!empty($tags)) {
         foreach ($tags as $key => $name) {
             if (!is_numeric($name)) {
                 $tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
                 $tag->name = $name;
                 $tag->save();
                 $tags[$key] = $tag->id();
             }
         }
         $post->tags()->sync($tags);
     }
     // end if
     if (!empty($tags2)) {
         foreach ($tags2 as $key => $name) {
             if (!is_numeric($name)) {
                 $tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
                 $tag->name = $name;
                 $tag->save();
                 $tags2[$key] = $tag->id();
             }
         }
         $post->tags()->sync($tags2);
     }
     // end if
     if ($request->hasFile('thumbnail')) {
         $file = $request->file('thumbnail');
         $dir = 'img/thumbnail';
         $btw = time();
         $name = $post->id() . $btw . '.' . $file->getClientOriginalExtension();
         Image::make($_FILES['thumbnail']['tmp_name'])->resize(250, 150)->save($dir . '/' . $name);
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         $post->thumbnail = $dir . '/' . $name;
         $post->save();
     }
     return redirect()->route('admin.post.show', $post);
 }
Exemplo n.º 5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Post $post)
 {
     $post->update($request->except('tag_list', 'thumbnail', 'photo1', 'photo2', 'photo3', 'photo4', 'photo5', 'photo6', 'photo7', 'photo8', 'photo9', 'photo10'));
     $tags = $request->input('tag_list');
     foreach ($tags as $key => $name) {
         if (!is_numeric($name)) {
             $tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
             $tag->name = $name;
             $tag->save();
             $tags[$key] = $tag->id();
         }
     }
     $post->tags()->sync($tags);
     if ($request->hasFile('thumbnail')) {
         $file = $request->file('thumbnail');
         $dir = 'img/thumbnail';
         $name = $post->id() . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         $post->thumbnail = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo1')) {
         $file = $request->file('photo1');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo1 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo2')) {
         $file = $request->file('photo2');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo2 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo3')) {
         $file = $request->file('photo3');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo3 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo4')) {
         $file = $request->file('photo4');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo4 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo5')) {
         $file = $request->file('photo5');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo5 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo6')) {
         $file = $request->file('photo6');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo6 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo7')) {
         $file = $request->file('photo7');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo7 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo8')) {
         $file = $request->file('photo8');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo8 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo9')) {
         $file = $request->file('photo9');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo9 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     if ($request->hasFile('photo10')) {
         $file = $request->file('photo10');
         $dir = 'img/photogalery';
         $time = rand();
         $name = $time . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         // $storage->put($dir.'/'.$name, $file);
         $post->photo10 = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     return redirect()->route('admin.post.show', $post);
 }
Exemplo n.º 6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Post $post)
 {
     $post->update($request->except('tag_list'));
     $tags = $request->input('tag_list');
     foreach ($tags as $key => $name) {
         if (!is_numeric($name)) {
             $tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
             $tag->name = $name;
             $tag->save();
             $tags[$key] = $tag->id();
         }
     }
     $post->tags()->sync($tags);
     if ($request->hasFile('thumbnail')) {
         $file = $request->file('thumbnail');
         $dir = 'img/banner';
         $name = $post->id() . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         $post->thumbnail = $dir . '/' . $name;
         $post->save();
         $file->move($dir, $name);
     }
     return redirect()->route('admin.post.show', $post);
 }
Exemplo n.º 7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \Model\Tag\Tag::truncate();
     factory(\Model\Tag\Tag::class, 50)->create();
 }
Exemplo n.º 8
0
 public function Tags(Request $request)
 {
     $tags = \Model\Tag\Tag::where('name', 'LIKE', $request->input('tag') . '%')->select('id', 'name as text')->take(10)->get();
     return response()->json($tags);
 }
Exemplo n.º 9
0
    echo '<ul>';
    foreach ($article->getCommentaires() as $c) {
        echo '<li>' . $c->getAuthor() . ' <i>said</i> ' . $c->getMessage() . '</li>';
    }
    echo '</ul>';
    echo '<br />';
    echo '<b>And now ?</b>';
    echo '<br />';
    echo '- ' . Article::count() . ' article(s)';
    echo '<br />';
    echo '- ' . Commentaire::count() . ' commentaire(s)';
    echo '<br />';
    echo '- ' . Tag::count() . ' tag(s)';
    echo '<br />';
    echo '<br />';
    echo '<b>Delete the comment !</b>';
    $comment->delete();
    echo '<br />';
    echo '<br />';
    echo '<b>The end !</b>';
    echo '<br />';
    echo '- ' . Article::count() . ' article(s)';
    echo '<br />';
    echo '- ' . Commentaire::count() . ' commentaire(s)';
    echo '<br />';
    echo '- ' . Tag::count() . ' tag(s)';
    echo '<br />';
    echo '<br />';
} catch (\Exception $e) {
    echo 'Ooops! ' . $e->getMessage() . '<br />';
}