Beispiel #1
0
 public function store()
 {
     $posts = \Input::get('posts');
     $results = array();
     if (count($posts)) {
         $insertData = [];
         foreach ($posts as $post) {
             $tags = isset($post['tags']) ? $post['tags'] : array();
             $result = Post::create(array('title' => $post['title'], 'body' => $post['body']));
             if (count($tags) && $result) {
                 $this->savePostTags($result->id, $tags);
             }
             array_push($results, $result);
         }
         if (count($results)) {
             $emails = json_decode(\Storage::get('emails.json'), true);
             \Mail::send('emails.post', ['results' => $results], function ($message) use($emails) {
                 $message->from(env('MAIL_FROM_ADDRESS'), env('MAIL_FROM_NAME'));
                 $message->to($emails)->subject('New posts');
             });
             Cache::forget('all_post');
             return self::makeResponse($results, 201);
         } else {
             return self::makeResponse(array(), 500, 'Server Error');
         }
     } else {
         return self::makeResponse(array(), 400, 'Bad Request');
     }
 }
 public function run()
 {
     DB::table('Posts')->delete();
     Post::create(['name' => 'First Name', 'email' => '*****@*****.**', 'city' => 1, 'content' => 'First Feedbuck 24', 'slag' => 'first-feed', 'published' => true, 'created_at' => time(), 'mood' => '1']);
     Post::create(['name' => 'Second Name', 'email' => '*****@*****.**', 'city' => 2, 'content' => 'Second Feedbuck 24', 'slag' => 'second-feed', 'published' => true, 'created_at' => time(), 'mood' => '2']);
     Post::create(['name' => 'Third Name', 'email' => '*****@*****.**', 'city' => 3, 'content' => 'Third Feedbuck 24sdsds', 'slag' => 'third-feed', 'published' => true, 'created_at' => time(), 'mood' => '1']);
 }
 public function run()
 {
     DB::table('posts')->delete();
     Post::create(['title' => 'First Post', 'content' => 'My first post', 'author' => 'Yevgeniy Zholkevskiy', 'published' => true]);
     Post::create(['title' => 'Two Post', 'content' => 'My second post', 'author' => 'Yevgeniy Zholkevskiy', 'published' => true]);
     Post::create(['title' => 'Three Post', 'content' => 'My third post', 'author' => 'Yevgeniy Zholkevskiy', 'published' => true]);
 }
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'content' => 'required', 'author' => 'required']);
     $input = $request->all();
     Post::create($input);
     return redirect()->route('posts.index');
 }
 public function run()
 {
     DB::table('Posts')->delete();
     Post::create(['title' => 'First Post', 'author' => 'Евгений', 'excerpt' => 'First Post body', 'text' => 'Content First Post body', 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
     Post::create(['title' => 'Second Post', 'author' => 'Евгений', 'excerpt' => 'Second Post body', 'text' => 'Content Second Post body', 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
     Post::create(['title' => 'Third Post', 'author' => 'Евгений', 'excerpt' => 'Third Post body', 'text' => 'Content Third Post body', 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
 }
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function create(Request $request, $id = '')
 {
     //echo Auth::user()->id; exit;
     if (empty($id)) {
         $model = new \App\Models\Post();
     } else {
         $model = \App\Models\Post::find($id);
         if (is_null($model)) {
             return response()->view('errors.404', array(), 404);
         }
     }
     if ($request->isMethod('post')) {
         $this->validate($request, ['title' => 'required|max:255', 'content' => 'required']);
         $title = \Illuminate\Support\Facades\Request::input('title');
         $content = \Illuminate\Support\Facades\Request::input('content');
         $publish = \Illuminate\Support\Facades\Request::input('publish') === null ? 0 : 1;
         if (empty($id)) {
             \App\Models\Post::create(array('title' => $title, 'content' => $content, 'publish' => $publish, 'user_id' => (int) Auth::user()->id, 'created_at' => date('Y-m-d H:i:s')));
         } else {
             $model->fill(['title' => $title, 'content' => $content, 'publish' => $publish, 'updated_at' => date('Y-m-d H:i:s')]);
             $model->save();
         }
         //echo "23423"; exit;
         return redirect()->to('/');
     }
     return view('post.create')->with(compact('model'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Post $postModel, Request $request)
 {
     //dd($request->all());
     //$request=$request->except('_token');
     $postModel->create($request->all());
     return redirect()->route('posts');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(PostCreateRequest $request)
 {
     //
     $post = Post::create($request->postFillData());
     $post->syncTags($request->get('tags', []));
     return redirect()->route('admin.post.index')->withSuccess('New Post Successful Created');
 }
Beispiel #9
0
 public function run()
 {
     DB::table('Posts')->delete();
     Post::create(['title' => 'First Post', 'slug' => 'first-post', 'excerpt' => 'First Post body', 'content' => 'Content First Post body', 'published' => true, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
     Post::create(['title' => 'Second Post', 'slug' => 'second-post', 'excerpt' => 'Second Post body', 'content' => 'Content Second Post body', 'published' => false, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
     Post::create(['title' => 'Third Post', 'slug' => 'third-post', 'excerpt' => 'Third Post body', 'content' => 'Content Third Post body', 'published' => false, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
 }
 /**
  * Store a newly created post in storage.
  *
  * @param CreatepostRequest $request
  *
  * @return Response
  */
 public function store(CreatePostRequest $request)
 {
     $input = Request::all();
     if (!empty($input['imagen'])) {
         $this->carpeta = 'posts/' . $input['id_usuario'] . '/';
         if (!File::exists($this->carpeta)) {
             //Crear carpeta de archivos adjuntos
             File::makeDirectory($this->carpeta);
         }
         $filename = 'posts/' . $input['id_usuario'] . '/' . $input['titulo'] . date("GisdY") . '.jpg';
         $input['imagen'] = $filename;
         Image::make(Input::file('imagen'))->resize(480, 360)->save($filename);
     }
     if (!empty($input['archivo'])) {
         $this->carpeta = 'posts/' . $input['id_usuario'] . '/';
         if (!File::exists($this->carpeta)) {
             //Crear carpeta de archivos adjuntos
             File::makeDirectory($this->carpeta);
         }
         $destinationPath = 'posts/' . $input['id_usuario'] . '/';
         // upload path
         $nombre = Input::file('archivo')->getClientOriginalName();
         // getting image extension
         Input::file('archivo')->move($destinationPath, $nombre);
         $input['archivo'] = $destinationPath . $nombre;
     }
     $post = Post::create($input);
     return redirect('home');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if (!$request->title or !$request->post or !$request->user_id) {
         return Response::json(['error' => ['message' => 'Insufficient data']], 422);
     }
     $post = Post::create($request->all());
     return Response::json(['message' => 'Post Created Succesfully', 'data' => $this->transform($post)]);
 }
Beispiel #12
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     foreach (range(1, 10) as $value) {
         $faker = \Faker\Factory::create('zh_TW');
         Post::create(['title' => $faker->title, 'content' => $faker->name, 'is_feature' => rand(1, 0), 'page_view' => rand(1, 1000), 'created_at' => Carbon::now()->subDays($value), 'updated_at' => Carbon::now()->subDays($value)]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     foreach (range(10, 1) as $num) {
         $faker = Faker\Factory::create('zh_TW');
         Post::create(['title' => $faker->name, 'content' => $faker->sentence, 'id' => rand(0, 100), 'created_at' => $faker->dateTime($max = 'now'), 'updated_at' => Carbon::now()->subDays($num)->subYears(rand(1, 5))]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     $faker = Factory::create('zh_tw');
     foreach (range(10, 1) as $number) {
         Post::create(['title' => $faker->title, 'is_feature' => rand(0, 1), 'content' => $faker->name, 'created_at' => Carbon::now()->subDay($number), 'updated_at' => Carbon::now()->subDay($number)]);
     }
 }
 public function run()
 {
     $faker = Faker::create();
     $cates = Category::lists('id')->toArray();
     for ($i = 1; $i <= 50; $i++) {
         Post::create(['title' => $faker->sentence(), 'summary' => $faker->paragraph(), 'category_id' => $faker->randomElement($cates), 'body' => $faker->text(10000), 'origin' => '', 'comment_count' => rand(0, 10), 'view_count' => rand(0, 200), 'favorite_count' => rand(0, 100), 'published' => rand(0, 1), 'slug' => 'post-' . $i]);
     }
 }
Beispiel #16
0
    public function run()
    {
        DB::table('Posts')->delete();
        Post::create(['title' => '«Деревянный» ЦОД группы Inoventica', 'slug' => 'wooden-cod', 'excerpt' => '<p>ЦОД Inoventica размещается в Судогодском районе Владимирской области и является первым облачным ЦОД Группы компаний Inoventica. Сдан в коммерческую эксплуатацию в феврале 2012 года.</p>', 'content' => '<p>Оптимальная структура капитальных вложений при строительстве первого ЦОД Inoventica была достигнута за счет использования инновационных технологических решений (применение системы охлаждения по технологии фрикулинга и наличие системы удаленного мониторинга и управления инфраструктурой), а также автоматической системы управления сервисами. ЦОД был построен в рекордно короткие сроки — за шесть месяцев, при том, что общестроительные работы были завершены за 90 дней. Минимизация операционных затрат на этапе коммерческой эксплуатации ЦОД достигается за счет его интеграции в объект двойного назначения — рекреационно-оздоровительный комплекс. Из-за необходимости соблюдения единого экостиля всех построек комплекса ЦОД приобрел уникальный дизайн и название — первый в мире «деревянный» ЦОД.</p>', 'published' => true, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
        Post::create(['title' => 'Проброс DLNA в удаленную сеть ', 'slug' => 'dlna-remote', 'excerpt' => '<p>Итак, появилась необходимость дать возможность просматривать фильмы с моего сервера на телевизоре. Ну казалось бы, поднимаем DLNA, например miniDLNA и проблема решена.</p>', 'content' => '<p>У родителей я уже давно поставил отличный роутер, с которым я давно работаю и доверяю — Mikrotik 951Ui 12HnD. Кто не знаком с этим великолепным маршрутизатором, советую познакомиться. Ценовая политика позволяет подобрать решения как для дома, так и для офиса. При этом получаем функционал, как у дорогих enterprise решений.</p>', 'published' => false, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
        Post::create(['title' => 'Microsoft выпустит свой собственный дистрибутив Linux', 'slug' => 'microsoft-linux', 'excerpt' => '<p>Да. Вы не ослышались: корпорация Microsoft действительно планирует выпустить собственный дистрибутив открытой операционной системы Linux.</p>', 'content' => '<p>Вы наверняка в курсе, что в распоряжении Microsoft имеется личная облачная платформа Azure, которая позволяет хранить и обрабатывать громадные массивы данных, удалённо выполнять различные приложения и даже наделяет игровую консоль Xbox One дополнительной вычислительной мощностью. На сегодняшний день дата-центры Azure насчитывают более 300 000 мощных серверов.
Microsoft верит в будущее сетей открытого типа, поэтому ACS, прежде всего, нацелена на то, чтобы упростить настройку, мониторинг, диагностику и процесс управления дата-центрами и огромными массивами сетевых коммутаторов (в народе знаменитые, как «свитчи») самых разных производителей. ACS, если верить пресс-релизу, будет использовать все преимущества экосистемы Linux. Разумеется, система будет поддерживать не только софт, выпускаемый для неё Microsoft, но и любое другое open source программное обеспечение.</p>', 'published' => false, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
    }
 public function run()
 {
     // TestDummy::times(20)->create('App\Post');
     $faker = Faker\Factory::create();
     foreach (range(1, 10) as $index) {
         Post::create(['title' => $faker->paragraph($nbWords = 3), 'post' => $faker->text($maxNbChars = 200), 'user_id' => $faker->numberBetween($min = 1, $max = 5)]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('posts')->truncate();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 50; $i++) {
         Post::create(['title' => $faker->sentence(6), 'slug' => $faker->slug(), 'content' => $faker->text(200), 'featured_img' => $faker->imageUrl(400, 200), 'status' => $faker->randomElement([1, 2]), 'user_id' => $faker->randomElement([1, 2, 3]), 'category_id' => $faker->randomElement([1, 2, 3])]);
     }
 }
 /**
  * Create a post object
  * @param int PostRequest $request 
  * @return Post
  */
 public function create($input)
 {
     $post = Post::create($input);
     //save the components values
     $componentIds = $post->retrieveComponentIds($input);
     $this->attachComponentPosts($componentIds, $post->id, $input);
     return $post;
 }
Beispiel #20
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     $faker = \Faker\Factory::create('zh_TW');
     foreach (range(10, 1) as $number) {
         Post::create(['title' => $faker->Title, 'content' => $faker->Name, 'is_feature' => rand(0, 1), 'page_view' => rand(1, 1000), 'created_at' => Carbon::now()->subDay($number), 'updated_at' => Carbon::now()->subDay($number)]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     $faker = \Faker\Factory::create('zh_TW');
     foreach (range(15, 1) as $number) {
         Post::create(['title' => $faker->sentence, 'content' => $faker->paragraph, 'is_feature' => rand(0, 1), 'created_at' => Carbon::now()->subDays($number), 'updated_at' => Carbon::now()->subDays($number)]);
     }
 }
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Model::unguard();
        $lipsum = new LoremIpsumGenerator();
        Role::create(['title' => 'Administrator', 'slug' => 'admin']);
        Role::create(['title' => 'Redactor', 'slug' => 'redac']);
        Role::create(['title' => 'User', 'slug' => 'user']);
        User::create(['username' => 'GreatAdmin', 'email' => '*****@*****.**', 'password' => bcrypt('admin'), 'seen' => true, 'role_id' => 1, 'confirmed' => true]);
        User::create(['username' => 'GreatRedactor', 'email' => '*****@*****.**', 'password' => bcrypt('redac'), 'seen' => true, 'role_id' => 2, 'valid' => true, 'confirmed' => true]);
        User::create(['username' => 'Walker', 'email' => '*****@*****.**', 'password' => bcrypt('walker'), 'role_id' => 3, 'confirmed' => true]);
        User::create(['username' => 'Slacker', 'email' => '*****@*****.**', 'password' => bcrypt('slacker'), 'role_id' => 3, 'confirmed' => true]);
        Contact::create(['name' => 'Dupont', 'email' => '*****@*****.**', 'text' => 'Lorem ipsum inceptos malesuada leo fusce tortor sociosqu semper, facilisis semper class tempus faucibus tristique duis eros, cubilia quisque habitasse aliquam fringilla orci non. Vel laoreet dolor enim justo facilisis neque accumsan, in ad venenatis hac per dictumst nulla ligula, donec mollis massa porttitor ullamcorper risus. Eu platea fringilla, habitasse.']);
        Contact::create(['name' => 'Durand', 'email' => '*****@*****.**', 'text' => ' Lorem ipsum erat non elit ultrices placerat, netus metus feugiat non conubia fusce porttitor, sociosqu diam commodo metus in. Himenaeos vitae aptent consequat luctus purus eleifend enim, sollicitudin eleifend porta malesuada ac class conubia, condimentum mauris facilisis conubia quis scelerisque. Lacinia tempus nullam felis fusce ac potenti netus ornare semper molestie, iaculis fermentum ornare curabitur tincidunt imperdiet scelerisque imperdiet euismod.']);
        Contact::create(['name' => 'Martin', 'email' => '*****@*****.**', 'text' => 'Lorem ipsum tempor netus aenean ligula habitant vehicula tempor ultrices, placerat sociosqu ultrices consectetur ullamcorper tincidunt quisque tellus, ante nostra euismod nec suspendisse sem curabitur elit. Malesuada lacus viverra sagittis sit ornare orci, augue nullam adipiscing pulvinar libero aliquam vestibulum, platea cursus pellentesque leo dui. Lectus curabitur euismod ad, erat.', 'seen' => true]);
        Tag::create(['tag' => 'Tag1']);
        Tag::create(['tag' => 'Tag2']);
        Tag::create(['tag' => 'Tag3']);
        Tag::create(['tag' => 'Tag4']);
        Post::create(['title' => 'Post 1', 'slug' => 'post-1', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/mega-champignon.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => $lipsum->getContent(500), 'active' => true, 'user_id' => 1]);
        Post::create(['title' => 'Post 2', 'slug' => 'post-2', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/goomba.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => '<p>Lorem ipsum convallis ac curae non elit ultrices placerat netus metus feugiat, non conubia fusce porttitor sociosqu diam commodo metus in himenaeos, vitae aptent consequat luctus purus eleifend enim sollicitudin eleifend porta. Malesuada ac class conubia condimentum mauris facilisis conubia quis scelerisque lacinia, tempus nullam felis fusce ac potenti netus ornare semper. Molestie iaculis fermentum ornare curabitur tincidunt imperdiet scelerisque, imperdiet euismod scelerisque torquent curae rhoncus, sollicitudin tortor placerat aptent hac nec. Posuere suscipit sed tortor neque urna hendrerit vehicula duis litora tristique congue nec auctor felis libero, ornare habitasse nec elit felis inceptos tellus inceptos cubilia quis mattis faucibus sem non.</p>

<p>Odio fringilla class aliquam metus ipsum lorem luctus pharetra dictum, vehicula tempus in venenatis gravida ut gravida proin orci, quis sed platea mi quisque hendrerit semper hendrerit. Facilisis ante sapien faucibus ligula commodo vestibulum rutrum pretium, varius sem aliquet himenaeos dolor cursus nunc habitasse, aliquam ut curabitur ipsum luctus ut rutrum. Odio condimentum donec suscipit molestie est etiam sit rutrum dui nostra, sem aliquet conubia nullam sollicitudin rhoncus venenatis vivamus rhoncus netus, risus tortor non mauris turpis eget integer nibh dolor. Commodo venenatis ut molestie semper adipiscing amet cras, class donec sapien malesuada auctor sapien arcu inceptos, aenean consequat metus litora mattis vivamus.</p>

<pre>
<code class="language-php">protected function getUserByRecaller($recaller)
{
	if ($this-&gt;validRecaller($recaller) &amp;&amp; ! $this-&gt;tokenRetrievalAttempted)
	{
		$this-&gt;tokenRetrievalAttempted = true;

		list($id, $token) = explode("|", $recaller, 2);

		$this-&gt;viaRemember = ! is_null($user = $this-&gt;provider-&gt;retrieveByToken($id, $token));

		return $user;
	}
}</code></pre>

<p>Feugiat arcu adipiscing mauris primis ante ullamcorper ad nisi, lobortis arcu per orci malesuada blandit metus tortor, urna turpis consectetur porttitor egestas sed eleifend. Eget tincidunt pharetra varius tincidunt morbi malesuada elementum mi torquent mollis, eu lobortis curae purus amet vivamus amet nulla torquent, nibh eu diam aliquam pretium donec aliquam tempus lacus. Tempus feugiat lectus cras non velit mollis sit et integer, egestas habitant auctor integer sem at nam massa himenaeos, netus vel dapibus nibh malesuada leo fusce tortor. Sociosqu semper facilisis semper class tempus faucibus tristique duis eros, cubilia quisque habitasse aliquam fringilla orci non vel, laoreet dolor enim justo facilisis neque accumsan in.</p>

<p>Ad venenatis hac per dictumst nulla ligula donec, mollis massa porttitor ullamcorper risus eu platea, fringilla habitasse suscipit pellentesque donec est. Habitant vehicula tempor ultrices placerat sociosqu ultrices consectetur ullamcorper tincidunt quisque tellus, ante nostra euismod nec suspendisse sem curabitur elit malesuada lacus. Viverra sagittis sit ornare orci augue nullam adipiscing pulvinar libero aliquam vestibulum platea cursus pellentesque leo dui lectus, curabitur euismod ad erat curae non elit ultrices placerat netus metus feugiat non conubia fusce porttitor. Sociosqu diam commodo metus in himenaeos vitae aptent consequat luctus purus eleifend enim sollicitudin eleifend, porta malesuada ac class conubia condimentum mauris facilisis conubia quis scelerisque lacinia.</p>

<p>Tempus nullam felis fusce ac potenti netus ornare semper molestie iaculis, fermentum ornare curabitur tincidunt imperdiet scelerisque imperdiet euismod. Scelerisque torquent curae rhoncus sollicitudin tortor placerat aptent hac, nec posuere suscipit sed tortor neque urna hendrerit, vehicula duis litora tristique congue nec auctor. Felis libero ornare habitasse nec elit felis, inceptos tellus inceptos cubilia quis mattis, faucibus sem non odio fringilla. Class aliquam metus ipsum lorem luctus pharetra dictum vehicula, tempus in venenatis gravida ut gravida proin orci, quis sed platea mi quisque hendrerit semper.</p>
', 'active' => true, 'user_id' => 2]);
        Post::create(['title' => 'Post 3', 'slug' => 'post-3', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/rouge-shell.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => $lipsum->getContent(500), 'active' => true, 'user_id' => 2]);
        Post::create(['title' => 'Post 4', 'slug' => 'post-4', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/rouge-shyguy.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => $lipsum->getContent(500), 'active' => true, 'user_id' => 2]);
        PostTag::create(['post_id' => 1, 'tag_id' => 1]);
        PostTag::create(['post_id' => 1, 'tag_id' => 2]);
        PostTag::create(['post_id' => 2, 'tag_id' => 1]);
        PostTag::create(['post_id' => 2, 'tag_id' => 2]);
        PostTag::create(['post_id' => 2, 'tag_id' => 3]);
        PostTag::create(['post_id' => 3, 'tag_id' => 1]);
        PostTag::create(['post_id' => 3, 'tag_id' => 2]);
        PostTag::create(['post_id' => 3, 'tag_id' => 4]);
        Comment::create(['content' => $lipsum->getContent(200), 'user_id' => 2, 'post_id' => 1]);
        Comment::create(['content' => $lipsum->getContent(200), 'user_id' => 2, 'post_id' => 2]);
        Comment::create(['content' => $lipsum->getContent(200), 'user_id' => 3, 'post_id' => 1]);
    }
 public function add()
 {
     $success = false;
     if ($this->request->data) {
         $post = Post::create($this->request->data);
         $success = $post->save();
     }
     return compact('success');
 }
 public function run()
 {
     Post::truncate();
     $faker = Faker\Factory::create();
     $authorIds = User::lists('id');
     for ($i = 0; $i < 10; $i++) {
         Post::create(['title' => $faker->word, 'desc' => $faker->sentence, 'image_url' => $faker->imageUrl($width = 640, $height = 480), 'share_url' => $faker->url, 'status' => $faker->randomElement(array(0, 1)), 'author_id' => $faker->randomElement($authorIds)]);
     }
 }
Beispiel #25
0
 public function savePostDb($data)
 {
     try {
         if (Auth::check()) {
             $data['user_id'] = Auth::user()->id;
         }
         $post = Post::create(['header' => $data['header'], 'link' => $data['link'], 'article' => $data['article'], 'author' => Auth::user()->name]);
     } catch (Exception $e) {
         return $e;
     }
     return $post;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $lipsum = new LoremIpsumGenerator();
     Role::create(['title' => 'Administrator', 'slug' => 'admin']);
     Role::create(['title' => 'Redactor', 'slug' => 'redac']);
     Role::create(['title' => 'User', 'slug' => 'user']);
     User::create(['user_name' => 'samad', 'email' => '*****@*****.**', 'name' => 'صمد سلطانزاد', 'password' => bcrypt('admin'), 'seen' => true, 'role_id' => 1, 'confirmed' => true]);
     Post::create(['tag' => 'link1', 'title' => 'پست تست شماره یک', 'read_more' => 'این پست برای تست ایجاد شده است. تمامی این وبلاگ با تکنولوژی پی اچ پی و بر اساس ام وی سی با فریم ورک لاراول طراحی شده است.', 'content' => 'این پست برای تست ایجاد شده است. تمامی این وبلاگ با تکنولوژی پی اچ پی و بر اساس ام وی سی با فریم ورک لاراول طراحی شده است.', 'active' => true, 'seen' => 0]);
     Post::create(['tag' => 'link2', 'title' => 'پست تست شماره دو', 'read_more' => 'این پست برای تست ایجاد شده است. تمامی این وبلاگ با تکنولوژی پی اچ پی و بر اساس ام وی سی با فریم ورک لاراول طراحی شده است.', 'content' => 'این پست برای تست ایجاد شده است. تمامی این وبلاگ با تکنولوژی پی اچ پی و بر اساس ام وی سی با فریم ورک لاراول طراحی شده است.', 'active' => true, 'seen' => 0]);
     Comment::create(['approved' => '1', 'comment' => 'نظری که به منظور تست نهاده شده است', 'email' => '*****@*****.**', 'commenter' => 'صمد سلطانزاد', 'seen' => '1', 'pst_id' => 1]);
     Comment::create(['approved' => '1', 'comment' => 'نظری که به منظور تست نهاده شده است', 'email' => '*****@*****.**', 'commenter' => 'صمد سلطانزاد', 'seen' => '1', 'pst_id' => 2]);
 }
Beispiel #27
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(PostRequest $request)
 {
     $post = $request->all();
     $archive = Archive::whereYearAndMonth(date("Y"), date("n"))->first();
     if ($archive) {
         $post['archive_id'] = $archive->id;
     } else {
         $newArchive = Archive::create(['year' => date("Y"), 'month' => date("n")]);
         $post['archive_id'] = $newArchive->id;
     }
     $post['slug'] = str_slug($post['title']);
     $post = Post::create($post);
     CategoryPost::create(['category_id' => $request->get("category_id"), 'post_id' => $post->id]);
 }
Beispiel #28
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);
 }
Beispiel #29
0
 public static function add($data)
 {
     try {
         $post = Post::where('code', '=', $data['code'])->first();
         if (is_null($post)) {
             $post = Post::create(array('name' => $data['name'], 'code' => $data['code'], 'public_date' => date('Y-m-d H:i:s'), 'preview_text' => Purifier::clean($data['preview_text']), 'text' => Purifier::clean($data['text']), 'user_id' => Auth::user()->id));
         } else {
             return false;
         }
     } catch (Exception $e) {
         Log::info('Post:add(): ' . $e->getMessage());
         return false;
     }
     return $post;
 }
Beispiel #30
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();
     $input['user_id'] = \Auth::user()->id;
     $post = \App\Models\Post::create($input);
     foreach ($input['labels'] as $labelID) {
         $post->labels()->attach($labelID);
     }
     //move file for temp location productphotos
     $fileName = \Carbon\Carbon::now()->timestamp . "_post.jpg";
     $request->file('photo')->move('images', $fileName);
     $post->photo = $fileName;
     $post->save();
     //add a new post
     return redirect('posts/' . $post->id);
 }