
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>laravel Archives - TECHNIG</title>
	<atom:link href="https://www.technig.com/tag/laravel/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.technig.com/tag/laravel/</link>
	<description>Gateway for IT Experts and Tech Geeks</description>
	<lastBuildDate>Mon, 06 Mar 2017 15:34:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>

<image>
	<url>https://www.technig.com/wp-content/uploads/2020/04/32x32.png</url>
	<title>laravel Archives - TECHNIG</title>
	<link>https://www.technig.com/tag/laravel/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">162720667</site>	<item>
		<title>How to Query Posts by Different Dates in Laravel 5</title>
		<link>https://www.technig.com/laravel-5-query-posts-dates/</link>
					<comments>https://www.technig.com/laravel-5-query-posts-dates/#comments</comments>
		
		<dc:creator><![CDATA[Hujatulla Asghari]]></dc:creator>
		<pubDate>Mon, 06 Mar 2017 15:34:48 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[Laravel 5]]></category>
		<category><![CDATA[Laravel Framework]]></category>
		<category><![CDATA[tips and tricks]]></category>
		<guid isPermaLink="false">https://www.technig.com/?p=9088</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="1200" height="720" src="https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Laravel 5 query posts by dates" decoding="async" fetchpriority="high" srcset="https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates.jpg 1200w, https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates-300x180.jpg 300w, https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates-768x461.jpg 768w, https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates-1024x614.jpg 1024w" sizes="(max-width: 1200px) 100vw, 1200px" /></div>
<p>Laravel 5 is the most popular PHP Framework. Developing php application is easy, fast and enjoyable with Laravel. In this tutorial you will learn Laravel 5 query posts by dates tips and tricks. You will learn how to query today&#8217;s post; how to query this week&#8217;s post and this months posts. This tutorial is going [&#8230;]</p>
<p>The post <a href="https://www.technig.com/laravel-5-query-posts-dates/">How to Query Posts by Different Dates in Laravel 5</a> appeared first on <a href="https://www.technig.com">TECHNIG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="1200" height="720" src="https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Laravel 5 query posts by dates" decoding="async" srcset="https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates.jpg 1200w, https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates-300x180.jpg 300w, https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates-768x461.jpg 768w, https://www.technig.com/wp-content/uploads/2017/03/Laravel-5-query-posts-by-dates-1024x614.jpg 1024w" sizes="(max-width: 1200px) 100vw, 1200px" /></div><p>Laravel 5 is the most popular PHP Framework. Developing php application is easy, fast and enjoyable with Laravel. In this tutorial you will learn Laravel 5 query posts by dates tips and tricks. You will learn how to query today&#8217;s post; how to query this week&#8217;s post and this months posts. This tutorial is going to short and show you the simple techniques for query posts by different dates.</p>
<h2>Laravel 5 Query Posts by Dates</h2>
<p>Laravel uses Carbon class date and time builder. You can learn more <a href="http://carbon.nesbot.com/docs/">here </a>about Carbon. As we promise to make this tutorial as short as possible, let&#8217;s start coding.</p>
<h3>How to Query Today&#8217;s Posts</h3>
<p>We assume you have a Post model and a created_at field in posts table of your database.</p>
<pre class="theme:sublime-text lang:php decode:true">$today_posts = App\Post::whereRaw('Date(created_at) = CURDATE()')-&gt;get();

</pre>
<h3>How to Query Yesterday&#8217;s Posts</h3>
<pre class="theme:sublime-text lang:php decode:true">$yesterday_posts = App\Post::whereRaw('Date(created_at) = DATE_ADD(CURDATE(), INTERVAL -1 DAY)')-&gt;get();

</pre>
<h3>How to Query this week&#8217;s Posts</h3>
<pre class="theme:sublime-text lang:php decode:true">$weekly_posts = App\Post::whereBetween( 'updated_at', [Carbon::today()-&gt;startOfWeek(), Carbon::today()-&gt;endOfWeek()] )-&gt;get();

</pre>
<h3> How to Query this Month Posts</h3>
<pre class="theme:sublime-text lang:php decode:true">$currentMonth = date('m');
$weekly_posts = App\Post::whereRaw('MONTH(created_at) = ?',[$currentMonth])-&gt;get();

</pre>
<p><strong>You might probably ask;</strong></p>
<blockquote><p><em>Why should I learn Laravel 5 query posts by dates and when can I use it?</em></p></blockquote>
<p>You don&#8217;t need to query posts only. There are many situations where you want to compare today&#8217;s post count with yesterday&#8217;s posts. Or maybe you want to count today&#8217;s sold product and yesterday&#8217;s or this week or current month. So, this technique will be quite helpful in those types of applications.</p>
<h3>How to Count Today&#8217;s Posts</h3>
<p>Here is an small tips for counting today&#8217;s orders and you can use it to count other things as well.</p>
<pre class="lang:default decode:true ">$countTodayOrders = App\Order::whereRaw('Date(created_at) = CURDATE()')-&gt;count();
</pre>
<p>All you need to do is to replace the last get() function with count() function.</p>
<h2>Conclusion</h2>
<p>We hope you have learned something new and use it in your next project to create something cool and inspiring. If you have any questions, feel free to comment it bellow.  We will answer as soon as possible. 🙂</p>
<p>&nbsp;</p>
<p>The post <a href="https://www.technig.com/laravel-5-query-posts-dates/">How to Query Posts by Different Dates in Laravel 5</a> appeared first on <a href="https://www.technig.com">TECHNIG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technig.com/laravel-5-query-posts-dates/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">9088</post-id>	</item>
		<item>
		<title>How to Manage Laravel 5.4 Files Upload</title>
		<link>https://www.technig.com/manage-laravel-5-4-files-upload/</link>
					<comments>https://www.technig.com/manage-laravel-5-4-files-upload/#comments</comments>
		
		<dc:creator><![CDATA[Hujatulla Asghari]]></dc:creator>
		<pubDate>Tue, 28 Feb 2017 16:11:17 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[Laravel 5]]></category>
		<category><![CDATA[Laravel Framework]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.technig.com/?p=9065</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="900" height="456" src="https://www.technig.com/wp-content/uploads/2017/02/laravel-5.4.-Manage-Laravel-5.4-Files-Upload.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Manage Laravel 5.4 Files Upload" decoding="async" srcset="https://www.technig.com/wp-content/uploads/2017/02/laravel-5.4.-Manage-Laravel-5.4-Files-Upload.jpg 900w, https://www.technig.com/wp-content/uploads/2017/02/laravel-5.4.-Manage-Laravel-5.4-Files-Upload-300x152.jpg 300w, https://www.technig.com/wp-content/uploads/2017/02/laravel-5.4.-Manage-Laravel-5.4-Files-Upload-768x389.jpg 768w" sizes="(max-width: 900px) 100vw, 900px" /></div>
<p>Laravel is by far the most popular PHP Framework. It has significant numbers of active community members plus many updates and packages. In this short tutorial, will show you how to upload and manage Laravel 5.4 files upload. If you are new to Laravel, make sure you read our old articles about Laravel Framework. You [&#8230;]</p>
<p>The post <a href="https://www.technig.com/manage-laravel-5-4-files-upload/">How to Manage Laravel 5.4 Files Upload</a> appeared first on <a href="https://www.technig.com">TECHNIG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="900" height="456" src="https://www.technig.com/wp-content/uploads/2017/02/laravel-5.4.-Manage-Laravel-5.4-Files-Upload.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Manage Laravel 5.4 Files Upload" decoding="async" loading="lazy" srcset="https://www.technig.com/wp-content/uploads/2017/02/laravel-5.4.-Manage-Laravel-5.4-Files-Upload.jpg 900w, https://www.technig.com/wp-content/uploads/2017/02/laravel-5.4.-Manage-Laravel-5.4-Files-Upload-300x152.jpg 300w, https://www.technig.com/wp-content/uploads/2017/02/laravel-5.4.-Manage-Laravel-5.4-Files-Upload-768x389.jpg 768w" sizes="(max-width: 900px) 100vw, 900px" /></div><p><a href="https://laravel.com/">Laravel</a> is by far the most popular PHP Framework. It has significant numbers of active community members plus many updates and packages. In this short tutorial, will show you how to upload and manage Laravel 5.4 files upload. If you are new to Laravel, make sure you read our <a href="https://www.technig.com/tag/laravel-framework/">old articles</a> about Laravel Framework.</p>
<blockquote><p><em>You will learn the tips and technique on how to upload file, move files, give a unique name for upload files and more. </em></p></blockquote>
<h2>How to Upload Files in Laravel 5.4</h2>
<p>Firstly, let&#8217;s see how easy and straightforward it is to upload a file in Laravel and then we will manage and modify the uploaded file.</p>
<p>First, we must create a form with file input to let us upload our file.</p>
<pre class="theme:sublime-text lang:php decode:true ">{{Form::open(['route' =&gt; 'user.store', 'files' =&gt; true])}}

{{Form::label('user_photo', 'User Photo',['class' =&gt; 'control-label'])}}
{{Form::file('user_photo')}}
{{Form::submit('Save', ['class' =&gt; 'btn btn-success'])}}

{{Form::close()}}</pre>
<p>&nbsp;</p>
<p>Let&#8217;s Imagine that we are uploading a photo for our user. Here are the requirements for our user.</p>
<ul>
<li>We have table in database called user ( default Laravel auth )</li>
<li>We have an extra column called user_photo in that table</li>
<li>We have User model ( with fillable properties )</li>
<li>We have UserController</li>
<li>Resourceful Controller for User</li>
</ul>
<p>I hope you can manage the above requirements.</p>
<p>The above form will submit data to the store method in the controller ( as like other projects ). As you can see, we are using Laravel form build from LaravelCollective. Our opening form has an extra option for <span style="background-color: #d1d1d1;"><em>file =&gt; &#8220;true&#8221;. </em></span>It will add the<em><span style="background-color: #d1d1d1;"> enctype=&#8221;multipart/form-data&#8221;</span> </em>to the form which will let us upload file.</p>
<h3>How to Handle File Upload</h3>
<p>Here is how we can handle file in our controller.</p>
<pre class="theme:sublime-text lang:php decode:true ">&lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
/**
* Upload the avatar for the user.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$path = $request-&gt;file('user_photo')-&gt;store('avatars');

return $path;
}
}</pre>
<p>&nbsp;</p>
<p>Be default; It will upload the file to storage directory and create a folder called avatars if doesn&#8217;t exist. So far it was just like other tutorials, but how can we upload the to a public directory instead of storage and how to change the uploaded file name and give it a unique name?</p>
<h2>How to Manage Laravel 5.4 Files Upload</h2>
<p>Now, let&#8217;s move the file to the public folder and give it a unique name. That way you can access the file easily in your views.</p>
<pre class="theme:sublime-text lang:php decode:true">&lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
/**
* Upload the avatar for the user.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{

// get current time and append the upload file extension to it,
// then put that name to $photoName variable.
$photoName = time().'.'.$request-&gt;user_photo-&gt;getClientOriginalExtension();

/*
talk the select file and move it public directory and make avatars
folder if doesn't exsit then give it that unique name.
*/
$request-&gt;user_photo-&gt;move(public_path('avatars'), $photoName);


}
}</pre>
<p>That&#8217;s it. Now you can save the<span style="background-color: #dbdbdb;"> $photoName </span>to the database as a <em><span style="background-color: #dbdbdb;">user_photo</span></em> field value. You can use <em><span style="background-color: #dbdbdb;">asset(&#8216;avatars&#8217;) </span></em>function in your view and access the photos.</p>
<h2>Conclusion</h2>
<p>We hope you have learned how to manage Laravel 5.4 files upload. If you have any questions regarding Laravel and file upload, feel free to comment it bellow. 🙂</p>
<p>The post <a href="https://www.technig.com/manage-laravel-5-4-files-upload/">How to Manage Laravel 5.4 Files Upload</a> appeared first on <a href="https://www.technig.com">TECHNIG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technig.com/manage-laravel-5-4-files-upload/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">9065</post-id>	</item>
		<item>
		<title>How to Change Laravel 5 Public Folder to Your Site Name?</title>
		<link>https://www.technig.com/change-laravel-5-public-folder-site-name/</link>
					<comments>https://www.technig.com/change-laravel-5-public-folder-site-name/#comments</comments>
		
		<dc:creator><![CDATA[Hujatulla Asghari]]></dc:creator>
		<pubDate>Sat, 30 Apr 2016 06:20:27 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[Laravel 5]]></category>
		<category><![CDATA[Laravel Framework]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP framework]]></category>
		<guid isPermaLink="false">https://www.technig.com/?p=7222</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"></div>
<p>We have a few articles about Laravel framework, but we have not shown how to in install and Laravel in production. If you have ever tried to install Laravel in your site, you might have seen some problems that needs to open public folder in order to run the site properly. In short, when you open [&#8230;]</p>
<p>The post <a href="https://www.technig.com/change-laravel-5-public-folder-site-name/">How to Change Laravel 5 Public Folder to Your Site Name?</a> appeared first on <a href="https://www.technig.com">TECHNIG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"></div><p>We have a few <a href="https://www.technig.com/installing-laravel-5-on-windows/" target="_blank" rel="noopener noreferrer">articles</a> about<a href="https://www.technig.com/tag/laravel-framework/"> Laravel framework</a>, but we have not shown how to in install and Laravel in production. If you have ever tried to install Laravel in your site, you might have seen some problems that needs to open public folder in order to run the site properly. In short, when you open the Laravel application directory, you expect to open the application index file. But it&#8217;s showing the directory structure and the files and folders. In this tutorial we will show you how to solve this problem step by step with proper and reliable way to change Laravel 5 public folder.</p>
<h2>Introduction</h2>
<p>Before starting, let&#8217;s see the default directory of Laravel and how you might run the Laravel projects. If you install Laravel inside www directory of you wamp or mamp, you probably go to localhost/laravelapp direcotry. In this cause you have to navigate to public directory and it will show you the application home page. On the other hand, if you install Laravel out of the www directory, you can run it through artisan command.</p>
<pre class="lang:default decode:true">php artisan serve</pre>
<p>I this case, you don&#8217;t need to open the public directory. All you need to do is to open localhost::8000 on windows OS. It will open the Laravel home page.</p>
<p>The point is here, if you put your project online for production, you can&#8217;t run php artisan serve command there, and you don&#8217;t want to open public folder to see your home page as well. Now let&#8217;s learn how to solve this problem.</p>
<h2>How to Change Laravel 5 Public Folder?</h2>
<p>Mainly there is two way to do solve this problem. Using htaccess or changing the directory structure. We will got the second option which is the best way and reliable way as well.</p>
<h3>Step 1</h3>
<p>The default directory will look like this.</p>
<figure id="attachment_7246" aria-describedby="caption-attachment-7246" style="width: 784px" class="wp-caption aligncenter"><a href="https://www.technig.com/wp-content/uploads/2016/04/change-laravel-5-pubic-folder-default-structure.jpg"><img loading="lazy" decoding="async" class="wp-image-7246 size-full" src="https://www.technig.com/wp-content/uploads/2016/04/change-laravel-5-pubic-folder-default-structure.jpg" alt="change laravel 5 public folder" width="784" height="430" /></a><figcaption id="caption-attachment-7246" class="wp-caption-text">change laravel 5 public folder default structure</figcaption></figure>
<p>Create a folder inside this directory and move all the files except public folder. We will create a folder and name it technig.</p>
<h3>Step 2</h3>
<p>Move all the files that are inside public directory one folder back. Your folder structure should look like this.</p>
<figure id="attachment_7247" aria-describedby="caption-attachment-7247" style="width: 696px" class="wp-caption aligncenter"><a href="https://www.technig.com/wp-content/uploads/2016/04/laravel-5-public-directory-changed.jpg"><img loading="lazy" decoding="async" class="wp-image-7247 size-full" src="https://www.technig.com/wp-content/uploads/2016/04/laravel-5-public-directory-changed.jpg" alt="change laravel 5 public folder" width="696" height="218" /></a><figcaption id="caption-attachment-7247" class="wp-caption-text">change laravel 5 public folder</figcaption></figure>
<p>Now you can delete the public folder,</p>
<h3>Final step</h3>
<p>Open the<span style="background-color: #d4d4d4;"> index.php </span>file that you see in the above directory and change the following lines of code.</p>
<pre class="theme:sublime-text lang:php decode:true">require __DIR__.'/../bootstrap/autoload.php';
</pre>
<p>change it to</p>
<pre class="theme:sublime-text lang:php decode:true">require __DIR__.'/technig/bootstrap/autoload.php';
</pre>
<p>And the another line near line 36.</p>
<pre class="theme:sublime-text lang:php decode:true">require __DIR__.'/../bootstrap/app.php';
</pre>
<p>change this one to</p>
<pre class="theme:sublime-text lang:php decode:true">require __DIR__.'/technig/bootstrap/app.php';
</pre>
<p>You are don&#8217;t know. If you open you application directory now, you will see you Laravel home page.</p>
<h2>Conclusion</h2>
<p>It was an easy and reliable way to change Laravel 5 public folder. If you face any problem during this file changing laravel files, feel free to comment it bellow. We hope it help you. 🙂</p>
<p>The post <a href="https://www.technig.com/change-laravel-5-public-folder-site-name/">How to Change Laravel 5 Public Folder to Your Site Name?</a> appeared first on <a href="https://www.technig.com">TECHNIG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technig.com/change-laravel-5-public-folder-site-name/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7222</post-id>	</item>
	</channel>
</rss>
