{"id":197454,"date":"2013-10-14T14:36:02","date_gmt":"2013-10-14T10:36:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=197454"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=197454","title":{"rendered":"<span class=\"post_title\">Laravel. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0434\u0435\u043f\u043b\u043e\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0418\u0442\u0430\u043a, \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 <a href=\"http:\/\/laravel.com\/\">Laravel<\/a>. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0444\u0430\u043c\u0438\u043b\u044c\u044f\u0440\u043d\u044b \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 <code>PHP<\/code> \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438 \u2014 \u0434\u043b\u044f \u0432\u0430\u0441 \u044d\u0442\u043e \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0442\u0440\u0443\u0434\u0430, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442 \u2014 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/968\/4ff\/aee\/9684ffaeefd3b2c70d00bb5a196ed8aa.png\" alt=\"Laravel - PHP framework for artisans!\"\/><\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0430\u044f. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445.<\/p>\n<p>  \u0414\u043b\u044f \u043b\u0435\u043d\u0438\u0432\u044b\u0445: <br \/>  <a href=\"https:\/\/github.com\/andrewdacenko\/habrahabr\">GitHub<\/a><br \/>  <a href=\"http:\/\/habr.eu1.frbit.net\/\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/a><\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<p>  \u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Laravel \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <a href=\"http:\/\/getcomposer.org\/\">Composer<\/a>  <\/p>\n<blockquote><p>Composer \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0432 <code>PHP<\/code>. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442.<br \/>   \u2014 <a href=\"http:\/\/getcomposer.org\/doc\/00-intro.md#introduction\">Composer<\/a>  <\/p><\/blockquote>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0441\u0440\u0435\u0434\u0435 <code>*nix<\/code> (\u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0442\u0430\u043a \u0436\u0435 \u0435\u0441\u0442\u044c \u043c\u0430\u043d\u0443\u0430\u043b \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043d\u0430 <a href=\"http:\/\/getcomposer.org\/doc\/00-intro.md#installation-windows\">Windows<\/a>, \u043f\u043b\u044e\u0441 \u043a \u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"http:\/\/www.wampserver.com\/ru\/\">WAMP<\/a> \u0438 <a href=\"http:\/\/windows.github.com\/\">Git<\/a>).<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u0412\u0430\u0441 \u0441\u043e\u0432\u0441\u0435\u043c \u0447\u0438\u0441\u0442\u0435\u043d\u044c\u043a\u0430\u044f \u041e\u0421. \u0422\u043e\u0433\u0434\u0430 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 <s>\u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438<\/s> \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435<\/p>\n<pre><code class=\"bash\"># \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 sudo apt-get update sudo apt-get install -y build-essential sudo apt-get install -y python-software-properties  # \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 php 5.5 sudo add-apt-repository ppa:ondrej\/php5\t sudo apt-get update  # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 sudo apt-get install -y php5 sudo apt-get install -y apache2 sudo apt-get install -y libapache2-mod-php5 sudo apt-get install -y mysql-server sudo apt-get install -y php5-mysql sudo apt-get install -y php5-curl sudo apt-get install -y php5-gd sudo apt-get install -y php5-mcrypt sudo apt-get install -y git-core sudo apt-get install -y phpmyadmin  # \u0425\u0430\u043a \u0434\u043b\u044f phpmyadmin echo &quot;Include \/etc\/phpmyadmin\/apache.conf&quot; | sudo tee -a \/etc\/apache2\/apache2.conf  # \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c apache sudo \/etc\/init.d\/apache2 restart  # \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 mod_rewrite sudo a2enmod rewrite   # \u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c Composer curl -sS https:\/\/getcomposer.org\/installer | php  sudo mv composer.phar \/usr\/local\/bin\/composer <\/code><\/pre>\n<p>  \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b. <br \/>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 <code>Laravel<\/code>.<\/p>\n<pre><code class=\"bash\"># \u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u0430\u044f \u043c\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u043f\u043e\u043a cd # \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \/home\/%user% mkdir workspace #\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 workspace cd workspace # \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u043d\u0435\u0435 mkdir php # \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 php cd php # \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 php <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 <code>laravel<\/code>code&gt; \u0432 \u043f\u0430\u043f\u043a\u0435 <i>habr<\/i><\/p>\n<pre><code class=\"bash\">composer create-project laravel\/laravel habr --prefer-dist  # .... \u0442\u0443\u0442 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043b\u0433\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 .... <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>php artisan serve<\/code><\/p>\n<pre><code class=\"bash\">cd habr php artisan serve <\/code><\/pre>\n<p>  \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost:8000\">http:\/\/localhost:8000<\/a>.<\/p>\n<blockquote><p>\u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 <b>artisan<\/b> \u2014 \u044d\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0441\u0442\u044c \u0432 <code>Laravel<\/code>. \u041e\u043d \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u044f\u0434 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u041e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0440\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 <code>Symfony<\/code>. (<a href=\"http:\/\/laravel.com\/docs\/artisan\">Artisan CLI<\/a>). \u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0432\u0435\u0449\u0438. \u0414\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434 \u0432\u0432\u0435\u0434\u0438\u0442\u0435 <code>php artisan list<\/code> \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0440\u043e\u043a\u0435.<\/p><\/blockquote>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost:8000\">http:\/\/localhost:8000<\/a> \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u0443\u044e \u0437\u0430\u0441\u0442\u0430\u0432\u043a\u0443 \u043a\u0430\u043a \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u043e\u0441\u0442\u0430.<\/p>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430<\/h4>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u043e\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0434\u0430\u043b\u0435\u0435 \u0411\u0414) \u0443 <code>Laravel \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b &lt;i&gt;database.php&lt;\/i&gt;, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u043d \u0432 \u043f\u0430\u043f\u043a\u0435 &lt;i&gt;app\/config\/&lt;\/i&gt;. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0411\u0414 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 &lt;code&gt;MySQL<\/code><\/p>\n<pre><code class=\"bash\">mysql -u root -p  # \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u0432\u043e\u0439 \u043f\u0430\u0440\u043e\u043b\u044c &gt; CREATE DATABASE `habr` CHARACTER SET utf8 COLLATE utf8_general_ci; &gt; CREATE USER 'habr'@'localhost' IDENTIFIED BY 'my_password'; &gt; GRANT ALL PRIVILEGES ON habr.* TO 'habr'@'localhost'; &gt; exit <\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a <code>MySQL<\/code>: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <b>habr<\/b> \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c <b>my_password<\/b> \u0438 \u0411\u0414 <b>habr<\/b> \u043d\u0430 \u0445\u043e\u0441\u0442\u0435 <b>localhost<\/b>. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0411\u0414 \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/159\/ce3\/324\/159ce332443fe910d34558683727f9f2.png\" alt=\"Laravel \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0411\u0414\"\/><\/p>\n<p>  \u0412 <code>Laravel<\/code> \u0435\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u2014 <a href=\"http:\/\/laravel.com\/docs\/migrations\">\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/a> \u0438 <a href=\"http:\/\/laravel.com\/docs\/schema\">\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c \u0421\u0445\u0435\u043c<\/a>.  <\/p>\n<blockquote><p>\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u044d\u0442\u043e \u0442\u0438\u043f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0443\u0440\u0441\u0435 \u043e \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441\u0445\u0435\u043c\u044b. \u041c\u0438\u0433\u0440\u0430\u0446\u0438\u044f, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432 \u043f\u0430\u0440\u0435 \u0441 \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u0435\u043c \u0421\u0445\u0435\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u044e\u0442 \u043b\u0435\u0433\u043a\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0445\u0435\u043c\u043e\u0439 \u0411\u0414.<br \/>   \u2014 <a href=\"http:\/\/laravel.com\/docs\/migrations\">\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/a><br \/>  \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c \u0421\u0445\u0435\u043c \u2014 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 <b>Sheme<\/b>. \u041e\u043d \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0432 \u0411\u0414. \u041e\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0411\u0414, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f <code>Laravel<\/code>, \u0438 \u0438\u043c\u0435\u0435\u0442 \u0435\u0434\u0438\u043d\u044b\u0439 <code>API<\/code> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c.<br \/>   \u2014 <a href=\"http:\/\/laravel.com\/docs\/schema\">\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c \u0421\u0445\u0435\u043c<\/a><\/p><\/blockquote>\n<p>  \u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439:<\/p>\n<pre><code class=\"bash\">php artisan migrate:install <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b, \u0442\u043e \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<br \/>  \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0445\u043e\u0447\u0443 \u0432\u0430\u0441 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h5>Laravel 4 Generators<\/h5>\n<p>  \u041c\u0435\u0433\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u2014 <b>generators<\/b> \u043e\u0442 <b>Jeffrey Way<\/b>. <a href=\"https:\/\/github.com\/JeffreyWay\/Laravel-4-GeneratotHub\">GitHub<\/a>.<\/p>\n<p>  \u041e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <b>artisan<\/b> \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a:<\/p>\n<ul>\n<li>generate:model \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/li>\n<li>generate:controller \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432<\/li>\n<li>generate:seed \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0434\u043b\u044f \u043d\u0430\u0431\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0411\u0414 \u0444\u0435\u0439\u043a\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439<\/li>\n<li>generate:view \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432<\/li>\n<li>generate:migration \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439<\/li>\n<li>generate:resource \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/li>\n<li>generate:scaffold \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u043e\u0432 (\u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435, \u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435!)<\/li>\n<li>generate:form \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u043e\u0440\u043c<\/li>\n<li>generate:test \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432<\/li>\n<li>generate:pivot \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/li>\n<\/ul>\n<h6>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u0430<\/h6>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Composer<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0443\u0436\u043d\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b <b>composer.json<\/b> \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 <code>&quot;way\/generators&quot;: &quot;dev-master&quot;<\/code> \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <code>&quot;require&quot;<\/code>.<\/p>\n<pre><code class=\"javascript\">&quot;require&quot;: { \t&quot;laravel\/framework&quot;: &quot;4.0.*&quot;, \t&quot;way\/generators&quot;: &quot;dev-master&quot; }, <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435<\/p>\n<pre><code class=\"bash\">composer update <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0448\u0442\u0440\u0438\u0445\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <b>app\/config\/app.php<\/b> \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 <\/p>\n<pre><code class=\"javascript\">'Way\\Generators\\GeneratorsServiceProvider' <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043c\u0430\u043d\u0434 <code>php artisan<\/code> \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>generate<\/code>. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>generate<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h4>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0435\u043a\u0438\u0439 <s>\u0431\u043b\u043e\u0433<\/s> \u0441\u0430\u0439\u0442 \u0441\u043e \u0441\u043a\u0438\u0434\u043a\u0430\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ul>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u0438\u043c\u0435\u0439\u043b\u043e\u043c, username \u0438 \u043f\u0430\u0440\u043e\u043b\u0435\u043c<\/li>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0440\u043e\u043b\u0435\u0439<\/li>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0440\u043e\u043b\u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/li>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0433\u043e\u0440\u043e\u0434\u043e\u0432<\/li>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439<\/li>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0442\u0435\u0433\u043e\u0432<\/li>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043a\u0438\u0434\u043e\u043a \u0441 \u043f\u043e\u043b\u044f\u043c\u0438: \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0433\u043e\u0440\u043e\u0434, \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f, % \u0441\u043a\u0438\u0434\u043a\u0438, \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0438 \u0434\u0430\u0442\u0430 \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u043a\u0438\u0434\u043a\u0438<\/li>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0441 \u043e\u0446\u0435\u043d\u043a\u0430\u043c\u0438<\/li>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0442\u0435\u0433\u043e\u0432 \u0441\u043a\u0438\u0434\u043e\u043a<\/li>\n<\/ul>\n<p>  \u041d\u0430\u0431\u0440\u043e\u0441\u0430\u0435\u043c \u0441\u0445\u0435\u043c\u0443 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u0411\u0414. \u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043a\u043e\u0435:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/417\/1f6\/d30\/4171f6d30ade09ddde3058abd9f072eb.png\" alt=\"Initial DB Schema\"\/><br \/>  \u0417\u0430 \u044d\u0442\u043e \u0441\u043f\u0430\u0441\u0438\u0431\u043e <b>generator<\/b>&#8216;\u0443. \u0422\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435, \u0447\u0442\u043e \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043b 10 \u0441\u0442\u0440\u043e\u043a, \u043a\u0441\u0442\u0430\u0442\u0438, \u0432\u043e\u0442 \u0438 \u043e\u043d\u0438:<\/p>\n<pre><code class=\"bash\">php artisan generate:migration create_users_table --fields=&quot;email:string:unique, password:string[60], username:string:unique&quot; php artisan generate:scaffold role --fields=&quot;role:string:unique&quot; php artisan generate:pivot users roles php artisan generate:scaffold city --fields=&quot;name:string:unique&quot; php artisan generate:scaffold company --fields=&quot;title:string:unique&quot; php artisan generate:scaffold tag --fields=&quot;title:string:unique&quot; php artisan generate:scaffold offer --fields=&quot;title:string, description:text, city_id:integer:unsigned, company_id:integer:unsigned, off:integer:unsigned, image:string, expires:date&quot; php artisan generate:scaffold comment --fields=&quot;body:text, user_id:integer:unsigned, offer_id:integer:unsigned, mark:integer&quot; php artisan generate:pivot offers tags  # \u0418 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0441\u0445\u0435\u043c\u044b \u0432 \u0411\u0414 php artisan migrate  <\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0411\u0414 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043d\u0435\u0441\u0435\u043d\u044b \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b. \u0412\u0430\u0436\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u043d\u043e\u0432\u044b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u043e\u0434\u043d\u0438\u043c \u0441\u0442\u044d\u043a\u043e\u043c. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>php artisan migrate:rollback<\/code>, \u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043e \u043d\u0443\u043b\u044f <code>migrate:reset<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0430\u0442\u0438\u0442\u044c \u0434\u043e \u043d\u0443\u043b\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 <code>migrate:refresh<\/code>.<\/p>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430:<\/p>\n<ul>\n<li><b>generate:migration<\/b> \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0438\u043c\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u044e\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443. \u0412 \u0438\u043c\u0435\u043d\u0438 \u0441\u0445\u0435\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <b>create<\/b> \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435, \u0434\u0430\u043b\u0435\u0435 \u0438\u0434\u0435\u0442 <b>\u0438\u043c\u044f<\/b> \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <b>table<\/b>. \u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0446\u0438\u044e <b>&#8212;fields=&quot;&quot;<\/b>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044f \u0441 \u0438\u0445\u043d\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445. <a href=\"https:\/\/github.com\/JeffreyWay\/Laravel-4-Generators#generating-schema\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/a>, <a href=\"http:\/\/laravel.com\/docs\/schema#adding-columns\">\u0422\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435<\/a><\/li>\n<li><b>generate:scaffold<\/b> \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0430\u043a \u0430\u0433\u0440\u0443\u043c\u0435\u043d\u0442 \u0440\u0435\u0441\u0443\u0440\u0441 (\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 <b>role<\/b>), \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b:<br \/> \n<ul>\n<li><i>app\/models\/Role.php<\/i> \u2014 \u043a\u043b\u0430\u0441 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0439 \u043e\u0442 <a href=\"http:\/\/laravel.com\/docs\/eloquent\">Eloquent ORM<\/a> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0440\u043e\u043b\u0435\u0439 (\u0438\u043c\u044f \u0441\u0430\u043c\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u2014 \u044d\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430)<\/li>\n<li><i>app\/controllers\/RolesController.php<\/i> \u2014 \u043a\u043b\u0430\u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0441\u0430\u0439\u0442\u0443, \u0442\u0430\u043a \u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"http:\/\/laravel.com\/docs\/controllers#resource-controllers\">REST<\/a> \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c<br \/> <br \/>\n<table>\n<tbody>\n<tr>\n<td>\u041c\u0435\u0442\u043e\u0434 HTTP<\/td>\n<td>\u041f\u0443\u0442\u044c (URL)<\/td>\n<td>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/td>\n<td>\u0418\u043c\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430<\/td>\n<\/tr>\n<tr>\n<td>GET<\/td>\n<td>\/resource<\/td>\n<td>index<\/td>\n<td>resource.index<\/td>\n<\/tr>\n<tr>\n<td>GET<\/td>\n<td>\/resource\/create<\/td>\n<td>create<\/td>\n<td>resource.create<\/td>\n<\/tr>\n<tr>\n<td>POST<\/td>\n<td>\/resource<\/td>\n<td>store<\/td>\n<td>resource.store<\/td>\n<\/tr>\n<tr>\n<td>GET<\/td>\n<td>\/resource\/{id}<\/td>\n<td>show<\/td>\n<td>resource.show<\/td>\n<\/tr>\n<tr>\n<td>GET<\/td>\n<td>\/resource\/{id}\/edit<\/td>\n<td>edit<\/td>\n<td>resource.edit<\/td>\n<\/tr>\n<tr>\n<td>PUT\/PATCH<\/td>\n<td>\/resource\/{id}<\/td>\n<td>update<\/td>\n<td>resource.update<\/td>\n<\/tr>\n<tr>\n<td>DELETE<\/td>\n<td>\/resource\/{id}<\/td>\n<td>destroy<\/td>\n<td>resource.destroy<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>   <\/li>\n<li><i>app\/views\/roles\/index.blade.php<\/i> \u2014 \u0448\u0430\u0431\u043b\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 (\u043e\u0431\u044b\u0447\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 <code>GET<\/code> \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043f\u043e <code>URL<\/code> <b>\/roles<\/b>), \u043f\u0440\u043e \u0441\u0430\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435<\/li>\n<li><i>app\/views\/roles\/show.blade.php<\/i> \u2014 \u0448\u0430\u0431\u043b\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (<code>GET<\/code> \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 <code>URL<\/code> <b>\/roles\/{id}<\/b>)<\/li>\n<li><i>app\/views\/roles\/create.blade.php<\/i> \u2014 \u0448\u0430\u0431\u043b\u043e\u043d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (<code>GET<\/code> \u043d\u0430 <code>URL<\/code> <b>\/roles\/create<\/b>)<\/li>\n<li><i>app\/views\/roles\/edit.blade.php<\/i> \u2014 \u0448\u0430\u0431\u043b\u043e\u043d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (<code>GET<\/code> \u043d\u0430 <code>URL<\/code> <b>\/roles\/{id}\/edit}<\/b>)<\/li>\n<li><i>app\/views\/layouts\/scaffold.blade.php<\/i> \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043b\u0435\u0439\u0430\u0443\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 html + bootstrap + \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430)<\/li>\n<li><i>app\/database\/migrations\/Create_roles_table.php<\/i> \u2014 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f<\/li>\n<li><i>app\/database\/seeds\/RolesTableSeeder.php<\/i> \u2014 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/li>\n<li><i>app\/tests\/controllers\/RolesTest.php<\/i> \u2014 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b<\/li>\n<\/ul>\n<p>   \u0430 \u0442\u0430\u043a \u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u044b   <\/p>\n<ul>\n<li><i>app\/database\/seeds\/DatabaseSeeder.php<\/i> \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 RolesTableSeeder<\/li>\n<li><i>app\/routes.php<\/i> \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (<a href=\"http:\/\/laravel.com\/docs\/controllers#resource-controllers\">REST<\/a>)<\/li>\n<\/ul>\n<p>   <\/li>\n<li><b>generate:pivot<\/b> \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 2 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 (\u0438\u043c\u0435\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446). \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0432\u043e\u0434\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 2 <code>foreign key<\/code><\/li>\n<\/ul>\n<p>  \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u043f\u043e\u043b\u0435\u0437\u0435\u043d.<\/p>\n<p>  \u0427\u0435\u0433\u043e \u043d\u0430\u043c \u0435\u0449\u0435 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u2014 \u0442\u0430\u043a \u044d\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0432\u044f\u0437\u043e\u043a \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438.   <\/p>\n<blockquote><p><b>\u0412\u0430\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c!<\/b> \u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 foreign key \u043a \u043a\u043e\u043b\u043e\u043d\u043a\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f unsigned.<\/p><\/blockquote>\n<p>  \u0427\u0442\u043e \u0436, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0445:<\/p>\n<pre><code class=\"bash\">php artisan generate:migration add_foreign_user_id_and_offer_id_to_comments_table php artisan generate:migration add_foreign_city_id_and_company_id_to_offers_table <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0430\u043c\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0430\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f.<\/p>\n<pre><code class=\"php\">... class AddForeignUserIdAndOfferIdToCommentsTable extends Migration { \t... \tpublic function up() \t{ \t\tSchema::table('comments', function(Blueprint $table) { \t\t\t$table-&gt;index('user_id'); \t\t\t$table-&gt;index('offer_id'); \t\t\t$table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users')-&gt;onDelete('cascade'); \t\t\t$table-&gt;foreign('offer_id')-&gt;references('id')-&gt;on('offers')-&gt;onDelete('cascade'); \t\t}); \t} \t... \tpublic function down() \t{ \t\tSchema::table('comments', function(Blueprint $table) { \t\t\t$table-&gt;dropForeign('comments_user_id_foreign'); \t\t\t$table-&gt;dropForeign('comments_offer_id_foreign'); \t\t\t$table-&gt;dropIndex('comments_user_id_index'); \t\t\t$table-&gt;dropIndex('comments_offer_id_index'); \t\t}); \t} } ... class AddForeignCityIdAndCompanyIdToOffersTable extends Migration { \t... \tpublic function up() \t{ \t\tSchema::table('offers', function(Blueprint $table) { \t\t\t$table-&gt;index('city_id'); \t\t\t$table-&gt;index('company_id'); \t\t\t$table-&gt;foreign('city_id')-&gt;references('id')-&gt;on('cities')-&gt;onDelete('cascade'); \t\t\t$table-&gt;foreign('company_id')-&gt;references('id')-&gt;on('companies')-&gt;onDelete('cascade'); \t\t}); \t} \t... \tpublic function down() \t{ \t\tSchema::table('offers', function(Blueprint $table) { \t\t\t$table-&gt;dropForeign('offers_city_id_foreign'); \t\t\t$table-&gt;dropForeign('offers_company_id_foreign'); \t\t\t$table-&gt;dropIndex('offers_city_id_index'); \t\t\t$table-&gt;dropIndex('offers_company_id_index'); \t\t}); \t} } <\/code><\/pre>\n<p>  \u0412\u0437\u0433\u044f\u043d\u0443\u0432 \u043d\u0430 \u0441\u0445\u0435\u043c\u0443 \u0411\u0414 \u0432\u0438\u0434\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u043f\u043e \u043b\u0443\u0447\u0448\u0435<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/aca\/171\/3f0\/aca1713f0b1850e967ffbb9ce82d3baa.png\" alt=\"Cool DB Schema\"\/><\/p>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438, \u0438 \u043f\u043e \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435\u043c \u043a\u043e\u043c\u0443 \u0443\u0433\u043e\u0434\u043d\u043e.<br \/>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0440\u043e\u043b\u044c admin. \u041f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"http:\/\/localhost:8000\/roles\">http:\/\/localhost:8000\/roles<\/a> \u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/7f7\/b56\/ec5\/7f7b56ec5bbc8a111f825f66b9c02812.png\" alt=\"Admin role added\"\/><\/p>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u0435 <a href=\"http:\/\/laravel.com\/docs\/templates#blade-templating\">Blade<\/a> \u0432 Laravel.<br \/>  \u0414\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <u>.balde.php<\/u>. \u0417\u0430\u0433\u043b\u044f\u043d\u0443\u0432 \u0432 \u0444\u0430\u0439\u043b <i>app\/views\/layouts\/scaffold.blade.php<\/i> \u043c\u044b \u0432\u0438\u0434\u0438\u043c<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/layouts\/scaffold.blade.php &lt;!doctype html&gt; &lt;html&gt; \t&lt;head&gt; \t\t&lt;meta charset=&quot;utf-8&quot;&gt; \t\t&lt;link href=&quot;\/\/netdna.bootstrapcdn.com\/twitter-bootstrap\/2.3.1\/css\/bootstrap-combined.min.css&quot; rel=&quot;stylesheet&quot;&gt; \t\t&lt;style&gt; \t\t\ttable form { margin-bottom: 0; } \t\t\tform ul { margin-left: 0; list-style: none; } \t\t\t.error { color: red; font-style: italic; } \t\t\tbody { padding-top: 20px; } \t\t&lt;\/style&gt; \t&lt;\/head&gt;  \t&lt;body&gt;  \t\t&lt;div class=&quot;container&quot;&gt; \t\t\t@if (Session::has('message')) \t\t\t\t&lt;div class=&quot;flash alert&quot;&gt; \t\t\t\t\t&lt;p&gt;{{ Session::get('message') }}&lt;\/p&gt; \t\t\t\t&lt;\/div&gt; \t\t\t@endif  \t\t\t@yield('main') \t\t&lt;\/div&gt;  \t&lt;\/body&gt;  &lt;\/html&gt; <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u0421\u0430\u043c \u0444\u0430\u0439\u043b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043a\u0435\u043b\u0435\u0442\u043e\u043c, \u043b\u044d\u0439\u0430\u0443\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432\u043d\u0443\u0442\u0440\u044c \u0441\u0435\u043a\u0446\u0438\u0438 <code>main<\/code> \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442, \u0438\u043b\u0438 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0448\u0430\u0431\u043b\u043e\u043d. \u0414\u0432\u043e\u0439\u043d\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 <b>{{ $var }}<\/b> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u043c <b>&lt;?php echo $var; ?&gt;<\/b>. \u041a\u043b\u0430\u0441\u0441 <a href=\"http:\/\/laravel.com\/docs\/session\">Session<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c, \u0438 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u043e\u043f\u0430\u0434\u0435\u0442. \u0415\u0441\u043b\u0438 \u043c\u044b \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d <i>app\/views\/roles\/index.blade.php<\/i><\/p>\n<pre><code class=\"html\">\/\/ app\/views\/roles\/index.blade.php @extends('layouts.scaffold')  @section('main')  &lt;h1&gt;All Roles&lt;\/h1&gt;  &lt;p&gt;{{ link_to_route('roles.create', 'Add new role') }}&lt;\/p&gt;  @if ($roles-&gt;count()) \t&lt;table class=&quot;table table-striped table-bordered&quot;&gt; \t\t&lt;thead&gt; \t\t\t&lt;tr&gt; \t\t\t\t&lt;th&gt;Role&lt;\/th&gt; \t\t\t&lt;\/tr&gt; \t\t&lt;\/thead&gt;  \t\t&lt;tbody&gt; \t\t\t@foreach ($roles as $role) \t\t\t\t&lt;tr&gt; \t\t\t\t\t&lt;td&gt;{{{ $role-&gt;role }}}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt;{{ link_to_route('roles.edit', 'Edit', array($role-&gt;id), array('class' =&gt; 'btn btn-info')) }}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt; \t\t\t\t\t\t{{ Form::open(array('method' =&gt; 'DELETE', 'route' =&gt; array('roles.destroy', $role-&gt;id))) }} \t\t\t\t\t\t\t{{ Form::submit('Delete', array('class' =&gt; 'btn btn-danger')) }} \t\t\t\t\t\t{{ Form::close() }} \t\t\t\t\t&lt;\/td&gt; \t\t\t\t&lt;\/tr&gt; \t\t\t@endforeach \t\t&lt;\/tbody&gt; \t&lt;\/table&gt; @else \tThere are no roles @endif  @stop <\/code><\/pre>\n<p>  \u0422\u043e \u043d\u0430\u043c \u0441\u0442\u0430\u043d\u0435\u0442 \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d <i>app\/views\/layouts\/scaffold.blade.php<\/i>, \u0437\u0430 \u044d\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043a\u043e\u0434 <code>@extends('layouts.scaffold')<\/code>. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0442\u0443\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u0430\u043f\u043a\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u0430, \u0445\u043e\u0442\u044f \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 <b>\/<\/b>.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0432 \u0441\u0435\u043a\u0446\u0438\u044e <code>main<\/code> \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u0441\u0435 \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f <code>@stop<\/code>. \u0422\u0430\u043a \u0436\u0435 \u0442\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u043d\u0430\u043c <code>if - else - endif<\/code> \u0438 <code>foreach - endforeach<\/code>, \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>link_to_route<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 Laravel (Helper Functions) \u0438 \u043a\u043b\u0430\u0441\u0441 <code>Form<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c (\u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c, \u0445\u043e\u0442\u044f \u0431\u044b Form::open(), \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442 \u0444\u043e\u0440\u043c\u044b <a href=\"http:\/\/laravel.com\/docs\/html#csrf-protection\">_token<\/a> \u2014 \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u043f\u043e\u0434\u0434\u0435\u043b\u043a\u0438 \u043a\u0440\u043e\u0441\u0441 \u0441\u0430\u0439\u0442\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 <a href=\"http:\/\/laravel.com\/docs\/html#opening-a-form\">_method<\/a> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 PUT \/ PATCH \u0438\u043b\u0438 DELETE).<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u043c \u043e \u0437\u0430\u0449\u0438\u0442\u0435 \u0432\u0441\u0435\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 <code>LoginContoller<\/code> \u0432 \u043f\u0430\u043f\u043a\u0435 <i>app\/controllers<\/i><\/p>\n<pre><code class=\"bash\">php artisan generate:controller LoginController <\/code><\/pre>\n<p>  \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432<\/p>\n<pre><code class=\"bash\">mkdir app\/views\/login php artisan generate:view index --path=&quot;app\/views\/login&quot; php artisan generate:view register --path=&quot;app\/views\/login&quot; php artisan generate:view dashboard --path=&quot;app\/views\/login&quot; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u0430\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u044b 5 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:   <\/p>\n<ul>\n<li>index \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0444\u043e\u0440\u043c\u044b \u0432\u0445\u043e\u0434\u0430<\/li>\n<li>register \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0444\u043e\u0440\u043c\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438<\/li>\n<li>store \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/li>\n<li>login \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0430\u0439\u0442<\/li>\n<li>logout \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u044b\u0445\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/li>\n<\/ul>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 LoginController \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/LoginController.php class LoginController extends BaseController {  \t\/** \t * Login Form. \t * \t * @return Response \t *\/ \tpublic function index() \t{ \t\treturn View::make('login.index'); \t}  \t\/** \t * Registration form. \t * \t * @return Response \t *\/ \tpublic function create() \t{ \t\treturn View::make('login.register'); \t}  \t\/** \t * Registring new user and storing him to DB. \t * \t * @return Response \t *\/ \tpublic function store() \t{ \t\t$rules = array( \t\t\t'email' \t=&gt; 'required|email|unique:users,email', \t\t\t'password' \t=&gt; 'required|alpha_num|between:4,50', \t\t\t'username'\t=&gt; 'required|alpha_num|between:2,20|unique:users,username' \t\t);  \t\t$validator = Validator::make(Input::all(), $rules);  \t\tif($validator-&gt;fails()){ \t\t\treturn Redirect::back()-&gt;withInput()-&gt;withErrors($validator); \t\t}  \t\t$user = new User; \t\t$user-&gt;email = Input::get('email'); \t\t$user-&gt;username = Input::get('username'); \t\t$user-&gt;password = Hash::make(Input::get('password')); \t\t$user-&gt;save();  \t\tAuth::loginUsingId($user-&gt;id);  \t\treturn Redirect::home()-&gt;with('message', 'Thank you for registration, now you can comment on offers!'); \t}   \t\/** \t * Log in to site. \t * \t * @return Response \t *\/ \tpublic function login() \t{ \t\tif (Auth::attempt(array('email' =&gt; Input::get('email'), 'password' =&gt; Input::get('password')), true) || \t\t\tAuth::attempt(array('username' =&gt; Input::get('email'), 'password' =&gt; Input::get('password')), true)) { \t\t\treturn Redirect::intended('dashboard'); \t\t}  \t\treturn Redirect::back()-&gt;withInput(Input::except('password'))-&gt;with('message', 'Wrong creadentials!'); \t}   \t\/** \t * Log out from site. \t * \t * @return Response \t *\/ \tpublic function logout() \t{ \t\tAuth::logout();  \t\treturn Redirect::home()-&gt;with('message', 'See you again!'); \t}  } <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 HTML. <br \/>  \u041c\u0435\u0442\u043e\u0434 store \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432 \u043d\u0430\u0448\u0443 \u0411\u0414 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u0432\u0441\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <code>POST<\/code> \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442 <code>Input::all()<\/code>. (<a href=\"http:\/\/laravel.com\/docs\/requests\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/a>). <br \/>  \u0412 \u043a\u043b\u0430\u0441\u0441\u0435 <code>Input<\/code> \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u0440\u0438 POST \u0437\u0430\u043f\u0440\u043e\u0441\u0435. \u041e\u043d \u0438\u043c\u0435\u0435\u0442 \u0440\u044f\u0434 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a <code>all()<\/code>, <code>get()<\/code>, <code>has()<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 (<a href=\"http:\/\/laravel.com\/docs\/requests#basic-input\">Basic Input<\/a>).<\/p>\n<p>  <code>Hash<\/code> \u2014 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/Bcrypt\">bcrypt<\/a>, \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u043e\u043b\u0438 \u0432 \u0411\u0414 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0441\u044c \u0432 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043e\u043c \u0432\u0438\u0434\u0435 (<a href=\"http:\/\/laravel.com\/docs\/security#storing-passwords\">Laravel Security<\/a>).<\/p>\n<p>  \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. <br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 <code>Laravel<\/code> \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <a href=\"http:\/\/laravel.com\/docs\/validation\">Validator<\/a>. \u041c\u0435\u0442\u043e\u0434 <code>Validation::make<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 2 \u0438\u043b\u0438 3 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430:  <\/p>\n<ol>\n<li><code>$input<\/code> \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c<\/li>\n<li><code>$rules<\/code> \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u043a \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c<\/li>\n<li><code>$messages<\/code> \u2014 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439, \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445<\/li>\n<\/ol>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442 <a href=\"http:\/\/laravel.com\/docs\/validation#available-validation-rules\">Available Validation Rules<\/a>.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>fails()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <b>true<\/b> \u0438\u043b\u0438 <b>false<\/b> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043f\u0440\u043e\u0448\u043b\u0438 \u043b\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 <code>make<\/code>.<\/p>\n<p>  \u041a\u043b\u0430\u0441\u0441 <a href=\"http:\/\/laravel.com\/docs\/responses#redirects\">Redirect<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0415\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b:  <\/p>\n<ul>\n<li>back() \u2014 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u044b\u043b \u043f\u043e\u0441\u043b\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441<\/li>\n<li>intended(&#8216;fallback&#8217;) \u2014 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043f\u0430\u043b \u043f\u043e\u0434 \u0444\u0438\u043b\u044c\u0442\u0440 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u043d\u0435 \u0431\u044b\u043b\u043e, \u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u043d\u0430 URL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u0432 <code>fallback<\/code><\/li>\n<li>withInput() \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 Input<\/li>\n<li>withErrors($validator) \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <b>$errors<\/b> \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 <code>$validator<\/code> (! \u0412\u0430\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <b>$errors<\/b> \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u043f\u0440\u0438 GET \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445).<\/li>\n<li>with(&#8216;variable&#8217;, &#8216;Your message here&#8217;) \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e &#8216;variable&#8217; \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u0443\u043a\u0430\u0436\u0435\u0442\u0435<\/li>\n<\/ul>\n<p>  \u041a\u043b\u0430\u0441\u0441 <code>Auth<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0443 \u043d\u0435\u0433\u043e \u0438\u043c\u0435\u0442\u0441\u044f \u0440\u044f\u0434 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 <code>loginUsingId($id)<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u0438\u0437 \u0411\u0414 (<a href=\"http:\/\/laravel.com\/docs\/security#authenticating-users\">Authenticating Users<\/a>). \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0442\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0438\u043c.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 \u043d\u0430\u0448\u0435\u0433\u043e \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 <code>login()<\/code> \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e <code>email<\/code> \u0438\u043b\u0438 <code>username<\/code> \u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u043f\u043e\u043f\u0430\u043b \u043f\u043e\u0434 \u0444\u0438\u043b\u044c\u0442\u0440 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u043e \u043e\u0448\u0438\u0431\u043a\u0435, \u043d\u043e \u0431\u0435\u0437 \u043f\u0430\u0440\u043e\u043b\u044f.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e. <\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0434\u043b\u044f \u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0432\u0441\u0435\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 <i>app\/routes.php<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"php\">\/\/ app\/routes.php ... Route::get('\/', array('as' =&gt; 'home', function() { \treturn View::make('hello'); }));  Route::get('logout', array('as' =&gt; 'login.logout', 'uses' =&gt; 'LoginController@logout'));  Route::group(array('before' =&gt; 'un_auth'), function() { \tRoute::get('login', array('as' =&gt; 'login.index', 'uses' =&gt; 'LoginController@index')); \tRoute::get('register', array('as' =&gt; 'login.register', 'uses' =&gt; 'LoginController@register')); \tRoute::post('login', array('uses' =&gt; 'LoginController@login')); \tRoute::post('register', array('uses' =&gt; 'LoginController@store')); });  Route::group(array('before' =&gt; 'admin.auth'), function() { \tRoute::get('dashboard', function() \t{ \t\treturn View::make('login.dashboard'); \t});  \tRoute::resource('roles', 'RolesController');  \tRoute::resource('cities', 'CitiesController');  \tRoute::resource('companies', 'CompaniesController');  \tRoute::resource('tags', 'TagsController');  \tRoute::resource('offers', 'OffersController');  \tRoute::resource('comments', 'CommentsController');  });  Route::filter('admin.auth', function()  { \tif (Auth::guest()) { \t\treturn Redirect::to('login'); \t} });  Route::filter('un_auth', function()  { \tif (!Auth::guest()) { \t\tAuth::logout(); \t} });  <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \/roles \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \/login, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043a\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u00abindex.blade.php\u00bb.<\/p>\n<p>  \u041a\u043e \u0432\u0441\u0435\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430\u043c, \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u0432 <code>Route::group(array('before' =&gt; 'admin.auth'))<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u0444\u0438\u043b\u044c\u0442\u0440 <b>admin.auth<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0433\u043e\u0441\u0442\u0435\u043c, \u0438\u043b\u0438 \u043d\u0435\u0442, \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0435\u0433\u043e \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432\u0445\u043e\u0434\u0430. \u041f\u0440\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/laravel.com\/docs\/routing#route-filters\">\u0442\u0443\u0442<\/a>, \u0430 \u043f\u0440\u043e \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0443 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 <a href=\"http:\/\/laravel.com\/docs\/routing#route-groups\">\u0442\u0443\u0442<\/a>. \u0414\u0440\u0443\u0433\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 <code>Route::group(array('before' =&gt; 'un_auth'))<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0430\u0448\u0435\u0434\u0448\u0438\u043c \u043d\u0430 \u0441\u0430\u0439\u0442, \u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u2014 \u0442\u043e \u043e\u043d \u0435\u0433\u043e \u0440\u0430\u0437\u043b\u043e\u0433\u0438\u043d\u0438\u0432\u0430\u0435\u0442.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0444\u0430\u0439\u043b\u044b \u043b\u043e\u0433\u0438\u043d\u0430 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/login\/index.blade.php @extends('layouts.scaffold')  @section('main')  &lt;h1&gt;Login&lt;\/h1&gt;  &lt;p&gt;{{ link_to_route('login.register', 'Register') }}&lt;\/p&gt;  {{ Form::open(array('route' =&gt; 'login.index')) }} \t&lt;ul&gt; \t\t&lt;li&gt; \t\t\t{{ Form::label('email', 'Email or Username:') }} \t\t\t{{ Form::text('email') }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('password', 'Password:') }} \t\t\t{{ Form::password('password') }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::submit('Submit', array('class' =&gt; 'btn btn-info')) }} \t\t&lt;\/li&gt; \t&lt;\/ul&gt; {{ Form::close() }}  @include('partials.errors', $errors)  @stop  \/\/ app\/views\/login\/register.blade.php @extends('layouts.scaffold')  @section('main')  &lt;h1&gt;Register&lt;\/h1&gt;  &lt;p&gt;{{ link_to_route('login.index', 'Login') }}&lt;\/p&gt;  {{ Form::open(array('route' =&gt; 'login.register')) }} \t&lt;ul&gt; \t\t&lt;li&gt; \t\t\t{{ Form::label('email', 'Email:') }} \t\t\t{{ Form::text('email') }} \t\t&lt;\/li&gt; \t\t \t\t&lt;li&gt; \t\t\t{{ Form::label('username', 'Username:') }} \t\t\t{{ Form::text('username') }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('password', 'Password:') }} \t\t\t{{ Form::password('password') }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::submit('Submit', array('class' =&gt; 'btn btn-info')) }} \t\t&lt;\/li&gt; \t&lt;\/ul&gt; {{ Form::close() }}  @include('partials.errors', $errors)  @stop \/\/ app\/views\/login\/dashboard.blade.php @extends('layouts.scaffold')  @section('main')  &lt;h1&gt;Administrative Dashboard&lt;\/h1&gt;  &lt;p&gt;Nice to see you, &lt;b&gt;{{{ Auth::user()-&gt;username }}}&lt;\/b&gt;&lt;\/p&gt;  @stop  \/\/ app\/views\/partials\/errors.blade.php @if ($errors-&gt;any()) \t&lt;ul&gt; \t\t{{ implode('', $errors-&gt;all('&lt;li class=&quot;error&quot;&gt;:message&lt;\/li&gt;')) }} \t&lt;\/ul&gt; @endif <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0442\u0443\u0442 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u0435\u043c \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u0435 <code>@include('view', $variable)<\/code>. \u0412 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043e\u043d \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442 \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 2 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430:  <\/p>\n<ol>\n<li>view \u2014 \u0448\u0430\u0431\u043b\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d<\/li>\n<li>$variable \u2014 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430<\/li>\n<\/ol>\n<p>  \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0430\u0439\u0442\u0443.<\/p>\n<p>  \u0427\u0442\u043e \u0436\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u0430 \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0433\u043e\u0440\u043e\u0434\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0432 \u041c\u043e\u0434\u0435\u043b\u0438 <code>City<\/code> \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/City.php class City extends Eloquent { \tprotected $guarded = array();  \tpublic static $rules = array( \t\t'name' =&gt; 'required|alpha|min:2|max:200|unique:cities,name' \t); } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0442\u0430\u043a \u0436\u0435 \u0438 \u0443 \u041c\u043e\u0434\u0435\u043b\u0435\u0439 <code>Company<\/code>, <code>Role<\/code> \u0438 <code>Tag<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/Company.php \t... \tpublic static $rules = array( \t\t'name' =&gt; 'required|alpha|min:2|max:200|unique:companies,name' \t); \t... \/\/ app\/models\/Role.php \t... \tpublic static $rules = array( \t\t'role' =&gt; 'required|alpha|min:2|max:200|unique:roles,role' \t); \t... \/\/ app\/models\/Tag.php \t... \tpublic static $rules = array( \t\t'name' =&gt; 'required|min:2|max:200|unique:tags,name' \t); \t... <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u043d\u044e \u0432 <i>app\/views\/layouts\/scaffold.blade.php<\/i>, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c jQuery \u0438 jQuery-UI \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u044e\u0449\u0438\u0445 \u043d\u0443\u0436\u0434<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/layouts\/scaffold.blade.php &lt;!doctype html&gt; &lt;html&gt; \t&lt;head&gt; \t\t&lt;meta charset=&quot;utf-8&quot;&gt; \t\t&lt;link href=&quot;\/\/netdna.bootstrapcdn.com\/twitter-bootstrap\/2.3.1\/css\/bootstrap-combined.min.css&quot; rel=&quot;stylesheet&quot;&gt; \t\t&lt;link href=&quot;\/\/code.jquery.com\/ui\/1.10.3\/themes\/smoothness\/jquery-ui.css&quot; rel=&quot;stylesheet&quot;&gt; \t\t&lt;style&gt; \t\t\ttable form { margin-bottom: 0; } \t\t\tform ul { margin-left: 0; list-style: none; } \t\t\t.error { color: red; font-style: italic; } \t\t\tbody { padding-top: 20px; } \t\t\tinput, textarea, .uneditable-input {width: 50%; min-width: 200px;} \t\t&lt;\/style&gt; \t\t@yield('styles') \t&lt;\/head&gt;  \t&lt;body&gt;  \t\t&lt;div class=&quot;container&quot;&gt;  \t\t\t&lt;ul class=&quot;nav nav-pills&quot;&gt; \t\t\t\t&lt;li&gt;{{ link_to_route('offers.index', 'Offers') }}&lt;\/li&gt; \t\t\t\t&lt;li&gt;{{ link_to_route('tags.index', 'Tags') }}&lt;\/li&gt; \t\t\t\t&lt;li&gt;{{ link_to_route('roles.index', 'Roles') }}&lt;\/li&gt; \t\t\t\t&lt;li&gt;{{ link_to_route('cities.index', 'Cities') }}&lt;\/li&gt; \t\t\t\t&lt;li&gt;{{ link_to_route('comments.index', 'Comments') }}&lt;\/li&gt; \t\t\t\t&lt;li&gt;{{ link_to_route('companies.index', 'Companies') }}&lt;\/li&gt; \t\t\t\t&lt;li class=&quot;pull-right&quot;&gt;{{ link_to_route('login.logout', 'Logout') }}&lt;\/li&gt; \t\t\t&lt;\/ul&gt;  \t\t\t@if (Session::has('message')) \t\t\t\t&lt;div class=&quot;flash alert&quot;&gt; \t\t\t\t\t&lt;p&gt;{{ Session::get('message') }}&lt;\/p&gt; \t\t\t\t&lt;\/div&gt; \t\t\t@endif  \t\t\t@yield('main') \t\t&lt;\/div&gt;  \t\t&lt;script type=&quot;text\/javascript&quot; src=&quot;\/\/code.jquery.com\/jquery.min.js&quot;&gt;&lt;\/script&gt; \t\t&lt;script type=&quot;text\/javascript&quot; src=&quot;\/\/code.jquery.com\/ui\/1.10.3\/jquery-ui.min.js&quot;&gt;&lt;\/script&gt; \t\t@yield('scripts')  \t&lt;\/body&gt;  &lt;\/html&gt; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u0430\u0432\u0438\u043b \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432 \u041c\u043e\u0434\u0435\u043b\u0438 <code>Offer<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/Offer.php \t... \tpublic static $rules = array( \t\t'title' =&gt; 'required|between:5,200', \t\t'description' =&gt; 'required|min:10', \t\t'city_id' =&gt; 'required|exists:cities,id', \t\t'company_id' =&gt; 'required|exists:companies,id', \t\t'off' =&gt; 'required|numeric|min:1|max:100', \t\t'image' =&gt; 'required|regex:\/\\\/images\\\/\\d{4}\\\/\\d{2}\\\/\\d{2}\\\/([A-z0-9]){30}\\.jpg\/',  \t\t\/\/ matches \/images\/2012\/12\/21\/ThisIsTheEndOfTheWorldMaya2112.jpg \t\t'expires' =&gt; 'required|date' \t); <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u044f <code>image<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u0445\u043e\u0447\u0443 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 <code>AJAX<\/code> \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a, \u0438 \u0432 \u0441\u0430\u043c\u0443 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0442\u044c \u043a \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0417\u043d\u0430\u0447\u0438\u0442 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 <i>app\/views\/offers\/create.blade.php<\/i> \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432.<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/offers\/create.blade.php ... {{ Form::label('file', 'Image:') }} {{ Form::file('file')}} &lt;img src=&quot;{{Input::old('image')}}&quot; id=&quot;thumb&quot; style=&quot;max-width:300px; max-height: 200px; display: block;&quot;&gt; {{ Form::hidden('image') }} &lt;div class=&quot;error&quot;&gt;&lt;\/div&gt; ... @section('scripts') @include('offers.scripts') @stop  \/\/ app\/views\/offers\/scripts.blade.php &lt;script&gt; $(document).ready(function(){  \t\/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u0430\u0442\u044b \t$('#expires').datepicker({dateFormat: &quot;yy-mm-dd&quot;});  \tvar uploadInput = $('#file'), \/\/ \u0418\u043d\u043f\u0443\u0442 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c \t\timageInput = $('[name=&quot;image&quot;]'), \/\/ \u0418\u043d\u043f\u0443\u0442 \u0441 URL \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \t\tthumb = document.getElementById('thumb'), \/\/ \u041f\u0440\u0435\u0432\u044c\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \t\terror = $('div.error'); \/\/ \u0412\u044b\u0432\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0444\u0430\u0439\u043b\u0430  \tuploadInput.on('change', function(){ \t\t\/\/ \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 FormData \t\tvar data = new FormData(); \t\t\/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u043e\u0432\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u0444\u0430\u0439\u043b \t\tdata.append('file', uploadInput[0].files[0]);  \t\t\/\/ \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \t\t$.ajax({ \t\t\t\/\/ \u041d\u0430 \u043a\u0430\u043a\u043e\u0439 URL \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \t\t\turl: '\/upload', \t\t\t\/\/ \u0422\u0438\u043f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \t\t\ttype: 'POST', \t\t\t\/\/ \u041a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \t\t\tdata: data, \t\t\t\/\/ \u042d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 jQuery \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \t\t\tprocessData: false,\t\t \t\t\t\/\/ \u042d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 jQuery \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \t\t\tcontentType: false,\t\t \t\t\t\/\/ \u0424\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \t\t\tdataType: 'json', \t\t\t\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0434\u0430\u0447\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \t\t\tsuccess: function(result) { \t \t\t\t\t\/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (\u043e\u0442\u0432\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 result) \t\t\t\t\/\/ \u0415\u0441\u043b\u0438 \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 filelink \t\t\t\tif (result.filelink) {\t\t \t\t\t\t\t\/\/ \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u044e\u0449\u0438\u0439 URL \u043d\u0430\u0448\u0435\u043c\u0443 \u043c\u0438\u043d\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \t\t\t\t\tthumb.setAttribute('src', result.filelink);  \t\t\t\t\t\/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 input'\u0435 \t\t\t\t\timageInput.val(result.filelink); \t\t\t\t\t\/\/ \u0421\u043a\u0440\u043e\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \t\t\t\t\terror.hide(); \t\t\t\t} else { \t\t\t\t\t\/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \t\t\t\t\terror.text(result.message); \t\t\t\t\terror.show(); \t\t\t\t} \t\t\t}, \t\t\t\/\/ \u0427\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a \t\t\terror: function (result) { \t\t\t\t\/\/ \u041e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \t\t\t\terror.text(&quot;Upload impossible&quot;); \t\t\t\terror.show(); \t\t\t} \t\t}); \t});  }); &lt;\/script&gt; <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043d\u0430 <code>input[name=&quot;file&quot;]<\/code> \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>AJAX<\/code> \u043f\u043e <code>URL<\/code> \/upload. \u041e\u0442\u0432\u0435\u0442\u043e\u043c \u0441 \u044d\u0442\u043e\u0433\u043e URL \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u042d\u0442\u0443 \u0441\u0441\u044b\u043b\u043a\u0443 \u043c\u044b \u0432\u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 src \u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 #thumb \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0432 \u0441\u043a\u0440\u044b\u0442\u043e\u043c \u0438\u043d\u043f\u0443\u0442\u0435 <code>image<\/code>. \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 <i>app\/routes.php<\/i> \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0430\u0440\u0448\u0443\u0442 <code>upload<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/routes.php ... Route::group(array('before' =&gt; 'admin.auth'), function(){ \t...  \tRoute::resource('comments', 'CommentsController');  \tRoute::post('upload', array('uses' =&gt; 'HomeController@uploadOfferImage')); } ... <\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, URL \u043c\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 <code>HomeController<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 <i>app\/controllers\/HomeController.php<\/i> \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>uploadOfferImage<\/code><br \/>  min:  <\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/HomeController.php class HomeController extends BaseController { \t... \tpublic function uploadOfferImage() \t{ \t\t$rules = array('file' =&gt; 'mimes:jpeg,png');  \t\t$validator = Validator::make(Input::all(), $rules);  \t\tif ($validator-&gt;fails()) { \t\t\treturn Response::json(array('message' =&gt; $validator-&gt;messages()-&gt;first('file'))); \t\t}  \t\t$dir = '\/images'.date('\/Y\/m\/d\/'); \t\t \t\tdo { \t\t\t$filename = str_random(30).'.jpg'; \t\t} while (File::exists(public_path().$dir.$filename));  \t\tInput::file('file')-&gt;move(public_path().$dir, $filename);  \t\treturn Response::json(array('filelink' =&gt; $dir.$filename)); \t} } <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f, \u043e\u0448\u0438\u0431\u043a\u0438, \u043e\u0442\u0432\u0435\u0442. \u0427\u0442\u043e \u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u0435\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u2014 \u044d\u0442\u043e <i>public_path()\/images\/\u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0433\u043e\u0434\/\u043c\u0435\u0441\u044f\u0446\/\u0434\u0430\u0442\u0430\/<\/i> (<code>public_path()<\/code> \u2014 \u044d\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>Laravel<\/code> \u0434\u043b\u044f \u043f\u0443\u0442\u0438 \u043a \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u0430\u043c), \u0434\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 <code>str_random(30)<\/code> \u0434\u043b\u0438\u043d\u043e\u044e 30 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c <code>jpg<\/code>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c <code>Input<\/code> \u0438 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>file('file')-&gt;move('destination_path', 'filename')<\/code>, \u0433\u0434\u0435: &#8216;file&#8217; \u2014 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0444\u0430\u0439\u043b, &#8216;destination_path&#8217; \u2014 \u043f\u0430\u043f\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0444\u0430\u0439\u043b, &#8216;filename&#8217; \u2014 \u0438\u043c\u044f \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d.<br \/>  <code>Response::json<\/code> \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>json<\/code>.<br \/>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0424\u0430\u0439\u043b\u044b \u0443 \u043d\u0430\u0441 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>AJAX<\/code>.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/2fe\/f0c\/1eb\/2fef0c1ebde41db6eeea4a62dc59f945.png\" alt=\"AJAX upload Laravel\"\/><br \/>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 <code>Form::input('number', 'city_id')<\/code> \u0438 <code>Form::input('number', 'company_id')<\/code> \u043d\u0430 \u0441\u0435\u043b\u0435\u043a\u0442\u044b \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"php\">\/\/ app\/views\/offers\/create.blade.php \t... \t&lt;?php $cities = array(0 =&gt; 'Choose city'); \tforeach (City::get(array('id', 'name')) as $city) { \t\t$cities[$city-&gt;id] = $city-&gt;name; \t} ?&gt;  \t&lt;li&gt; \t\t{{ Form::label('city_id', 'City_id:') }} \t\t{{ Form::select('city_id', $cities) }} \t&lt;\/li&gt;  \t&lt;?php $companies = array(0 =&gt; 'Choose company'); \tforeach (Company::get(array('id', 'name')) as $company) { \t\t$companies[$company-&gt;id] = $company-&gt;name; \t} ?&gt;  \t&lt;li&gt; \t\t{{ Form::label('company_id', 'Company_id:') }} \t\t{{ Form::select('company_id', $companies) }} \t&lt;\/li&gt; \t... <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441\u0435\u043b\u0435\u043a\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0442\u0443\u0442 <a href=\"http:\/\/laravel.com\/docs\/html#drop-down-lists\">Forms &#038; Html (Dropdown Lists)<\/a>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0433\u043e\u0440\u043e\u0434\u043e\u0432 \u0438 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 \u0432 \u0411\u0414.<\/p>\n<p>  \u0427\u0435\u0433\u043e \u043d\u0430\u043c \u0435\u0449\u0435 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u2014 \u0442\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u043e\u0432 \u043a \u0441\u043a\u0438\u0434\u043a\u0430\u043c. \u0422\u0443\u0442 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <a href=\"http:\/\/jqueryui.com\/autocomplete\/#multiple-remote\">jquery-ui \u0441 autocomplete<\/a> \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043c \u0444\u0430\u0439\u043b \u0441 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438 <i>app\/views\/offers\/create.blade.php<\/i>:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/offers\/scripts.blade.php &lt;script&gt; $(document).ready(function(){  \t... \tfunction split( val ) { \t\treturn val.split( \/,\\s*\/ ); \t} \tfunction extractLast( term ) { \t\treturn split( term ).pop(); \t}   \t$( &quot;#tags&quot; ) \t\/\/ don't navigate away from the field on tab when selecting an item \t.bind( &quot;keydown&quot;, function( event ) { \t\tif ( event.keyCode === $.ui.keyCode.TAB && \t\t\t$( this ).data( &quot;ui-autocomplete&quot; ).menu.active ) { \t\t\tevent.preventDefault(); \t\t} \t}) \t.autocomplete({ \t\tsource: function( request, response ) { \t\t\t$.getJSON( &quot;\/tags&quot;, { \t\t\t\t\tterm: extractLast( request.term ), \t\t\t\t},  \t\t\t\tfunction( data ) { \t\t\t\t\tresponse($.map(data, function(item) { \t\t\t\t\t\treturn { \t\t\t\t\t\t\tvalue: item.name \t\t\t\t\t\t} \t\t\t\t\t})) \t\t\t\t} \t\t\t); \t\t}, \t\tsearch: function() { \t\t\t\/\/ custom minLength \t\t\tvar term = extractLast( this.value ); \t\t\tif ( term.length &lt; 2 ) { \t\t\treturn false; \t\t\t} \t\t}, \t\tfocus: function() { \t\t\t\/\/ prevent value inserted on focus \t\t\treturn false; \t\t}, \t\tselect: function( event, ui ) { \t\t\tconsole.log(ui); \t\t\tconsole.log(this); \t\t\tvar terms = split( this.value ); \t\t\t\/\/ remove the current input \t\t\tterms.pop(); \t\t\t\/\/ add the selected item \t\t\tterms.push( ui.item.value ); \t\t\t\/\/ add placeholder to get the comma-and-space at the end \t\t\tterms.push( &quot;&quot; ); \t\t\tthis.value = terms.join( &quot;, &quot; ); \t\t\treturn false; \t\t} \t}); }); &lt;\/script&gt; <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0441\u0430\u0439\u0442\u0430 <a href=\"http:\/\/jqueryui.com\/autocomplete\/#multiple\">jqueryui.com<\/a>, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 \u0442\u043e\u0447\u043a\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0438\u0434\u0435\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>\/tags<\/code>. \u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 <code>AJAX<\/code> \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 <code>URL<\/code>.<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/TagController.php class TagsController extends BaseController { \t... \t\/** \t * Display a listing of the resource. \t * \t * @return Response \t *\/ \tpublic function index() \t{ \t\t$tags = $this-&gt;tag-&gt;all();  \t\t\/\/ \u0417\u0430\u043f\u0440\u043e\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f AJAX \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \t\tif (Request::ajax()) { \t\t\t\/\/ \u0412\u044b\u0431\u0435\u0440\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0442\u0435\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043f\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \t\t\t$tags = Tag::where('name', 'like', '%'.Input::get('term', '').'%')-&gt;get(array('name')); \t\t\t\/\/ \u0412\u0435\u0440\u043d\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 json \t\t\treturn $tags; \t\t}  \t\treturn View::make('tags.index', compact('tags')); \t} \t... <\/code><\/pre>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0442\u043e, \u0447\u0442\u043e <code>Eloquent<\/code> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 <code>json<\/code>, \u0435\u0441\u043b\u0438 \u043c\u044b \u0435\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Response::json()<\/code>. \u0418 \u0432\u043e\u0442 \u0443 \u043d\u0430\u0441 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u0435\u0433\u0438.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u2014 \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043a\u0438\u0434\u043e\u043a.  <\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/OffersController.php class OffersController extends BaseController { \t... \t\/** \t * Store a newly created resource in storage. \t * \t * @return Response \t *\/ \tpublic function store() \t{ \t\t$rules = Offer::$rules; \t\t$rules['expires'] .= '|after:'.date('Y-m-d', strtotime('+1 day')).'|before:'.date('Y-m-d', strtotime('+1 month'));  \t\t$validation = Validator::make(Input::all(), $rules);  \t\tif ($validation-&gt;passes()) \t\t{ \t\t\t$tags = array(); \t\t\t \t\t\tforeach (explode(', ', Input::get('tags')) as $tag_name) { \t\t\t\tif ($tag = Tag::where('name', '=', $tag_name)-&gt;first()) { \t\t\t\t\t$tags[] = $tag-&gt;id; \t\t\t\t} \t\t\t}  \t\t\tif (count($tags) == 0) { \t\t\t\treturn Redirect::route('offers.create') \t\t\t\t\t-&gt;withInput() \t\t\t\t\t-&gt;with('message', 'Insert at least one tag.'); \t\t\t} \t\t\t \t\t\t$offer = $this-&gt;offer-&gt;create(Input::except('tags', 'file')); \t\t\t$offer-&gt;tags()-&gt;sync($tags);  \t\t\treturn Redirect::route('offers.index'); \t\t}  \t\treturn Redirect::route('offers.create') \t\t\t-&gt;withInput() \t\t\t-&gt;withErrors($validation) \t\t\t-&gt;with('message', 'There were validation errors.'); \t} \t... <\/code><\/pre>\n<p>  \u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445, \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e <i>expires<\/i>, \u0447\u0442\u043e \u0431\u044b \u0441\u043a\u0438\u0434\u043a\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0435 \u0440\u0430\u043d\u044c\u0448\u0435 \u0437\u0430\u0432\u0442\u0440\u0430\u0448\u043d\u0435\u0433\u043e \u0434\u043d\u044f, \u0438 \u043d\u0435 \u043f\u043e\u0437\u0436\u0435, \u0447\u0435\u043c \u0447\u0435\u0440\u0435\u0437 1 \u043c\u0435\u0441\u044f\u0446. \u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u0432\u0441\u0435 <code>id<\/code> \u0442\u0435\u0433\u043e\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0432 \u0438\u0445 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432 \u0411\u0414. \u041f\u043e\u0441\u043b\u0435 \u0438\u0434\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0432\u0432\u0435\u0434\u0435\u043d\u044b \u043b\u0438 \u0442\u0435\u0433\u0438. \u0410 \u043f\u043e\u0434 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043f\u0440\u0438\u0435\u043c: \u0432 Eloquent \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446 \u043c\u043e\u0436\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f (<a href=\"http:\/\/laravel.com\/docs\/eloquent#relationships\">Eloquent Relationships<\/a>), \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0443 \u041c\u043e\u0434\u0435\u043b\u0438 Offers \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0435\u0433\u043e\u0432, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u044d\u0442\u043e \u0432 \u041c\u043e\u0434\u0435\u043b\u0438<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/Offer.php \t... \tpublic function tags() \t{ \t\treturn $this-&gt;belongsToMany('Tag'); \t} \t... <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <b>offers<\/b> \u0438 \u043c\u043d\u043e\u0433\u0438\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <b>tags<\/b>. \u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043c\u0435\u0442\u043e\u0434\u0443 <code>$offer-&gt;tags()<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u0435\u0433\u0438, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f \u0441\u043a\u0438\u0434\u043a\u0430. \u041d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 <code>sync(array(1, 2, 3))<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0448\u0435\u0442 \u0432 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043a <code>offer_id<\/code> \u043d\u0443\u0436\u043d\u044b\u0435 <code>tag_id<\/code>. \u0422\u0430\u0431\u043b\u0438\u0446\u0430 <b>offer_tag<\/b>:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/f7a\/082\/4b6\/f7a0824b66074b81fea961d909ab280a.png\" alt=\"Pivot table offer to tag\"\/><br \/>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <b>offers<\/b> \u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 <b>cities<\/b> \u0438 <b>companies<\/b>:<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/Offer.php \t... \tpublic function city() \t{ \t\treturn $this-&gt;belongsTo('City'); \t}  \tpublic function company() \t{ \t\treturn $this-&gt;belongsTo('Company'); \t}  \tpublic function tags() \t{ \t\treturn $this-&gt;belongsToMany('Tag'); \t}  \t\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0446\u0435\u043b\u043e\u0441\u043d\u043e\u0441\u0442\u0438 \u0441\u043b\u043e\u0432 + \u0432\u044b\u0432\u043e\u0434 \u0441 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \tpublic function webDescription($options = array()) \t{ \t\t$str = $this-&gt;description;  \t\tif (isset($options['shorten'])) { \t\t\t$length = isset($options['length']) ? (int) $options['length'] : 250; \t\t\t$end = isset($options['end']) ? : '&#8230;'; \t\t\tif (mb_strlen($str) &gt; $length) { \t\t\t\t$str = mb_substr(trim($str), 0, $length); \t\t\t\t$str = mb_substr($str, 0, mb_strlen($str) - mb_strpos(strrev($str), ' ')); \t\t\t\t$str = trim($str.$end); \t\t\t} \t\t} \t\t \t\t$str = str_replace(&quot;\\r\\n&quot;, '&lt;br&gt;', e($str)); \t\treturn $str; \t} } <\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b <i>app\/views\/offers\/index.blade.php<\/i><\/p>\n<pre><code class=\"html\">\/\/ app\/views\/offers\/index.blade.php @if ($offers-&gt;count()) \t&lt;table class=&quot;table table-striped table-bordered&quot;&gt; \t\t&lt;thead&gt; \t\t\t&lt;tr&gt; \t\t\t\t&lt;th&gt;Title&lt;\/th&gt; \t\t\t\t&lt;th&gt;Description&lt;\/th&gt; \t\t\t\t&lt;th&gt;City&lt;\/th&gt; \t\t\t\t&lt;th&gt;Company&lt;\/th&gt; \t\t\t\t&lt;th&gt;Off&lt;\/th&gt; \t\t\t\t&lt;th&gt;Image&lt;\/th&gt; \t\t\t\t&lt;th&gt;Tags&lt;\/th&gt; \t\t\t\t&lt;th&gt;Expires&lt;\/th&gt; \t\t\t&lt;\/tr&gt; \t\t&lt;\/thead&gt;  \t\t&lt;tbody&gt; \t\t\t@foreach ($offers as $offer) \t\t\t\t&lt;tr&gt; \t\t\t\t\t&lt;td&gt;{{{ $offer-&gt;title }}}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt;{{ $offer-&gt;webDescription(array('shorten' =&gt; true, 'length' =&gt; 60)) }}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt;{{{ $offer-&gt;city-&gt;name }}}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt;{{{ $offer-&gt;company-&gt;name }}}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt;{{{ $offer-&gt;off }}}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt;&lt;img src=&quot;{{{ $offer-&gt;image }}}&quot; style=&quot;max-width: 200px; max-height:150px;&quot;&gt;&lt;\/td&gt; \t\t\t\t\t&lt;td&gt; \t\t\t\t\t\t@foreach($offer-&gt;tags as $tag) \t\t\t\t\t\t\t&lt;span class=&quot;badge&quot;&gt;{{{$tag-&gt;name}}}&lt;\/span&gt; \t\t\t\t\t\t@endforeach \t\t\t\t\t&lt;\/td&gt; \t\t\t\t\t&lt;td&gt;{{{ $offer-&gt;expires }}}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt; \t\t\t\t\t\t{{ link_to_route('offers.edit', 'Edit', array($offer-&gt;id), array('class' =&gt; 'btn btn-info')) }} \t\t\t\t\t&lt;\/td&gt; \t\t\t\t\t&lt;td&gt; \t\t\t\t\t\t{{ Form::open(array('method' =&gt; 'DELETE', 'route' =&gt; array('offers.destroy', $offer-&gt;id))) }} \t\t\t\t\t\t\t{{ Form::submit('Delete', array('class' =&gt; 'btn btn-danger')) }} \t\t\t\t\t\t{{ Form::close() }} \t\t\t\t\t&lt;\/td&gt; \t\t\t\t&lt;\/tr&gt; \t\t\t@endforeach \t\t&lt;\/tbody&gt; \t&lt;\/table&gt; @else \tThere are no offers @endif <\/code><\/pre>\n<p>  \u0418 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043e\u0442\u043b\u0438\u0447\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u043a\u0438\u0434\u043a\u0438:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/891\/73f\/2a3\/89173f2a3833c05a25e70ca9b8626f00.png\" alt=\"All offers\"\/>   <\/p>\n<blockquote><p> <b>{{{ $string }}}<\/b> \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <b>$string<\/b>, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0433\u043d\u0430\u0432 \u0447\u0435\u0440\u0435\u0437 <code>htmlentities<\/code>, \u0442\u043e \u0431\u0438\u0448\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0447\u0442\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043e\u0442 XSS. \u0410\u043d\u0430\u043b\u043e\u0433\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>&lt;?php echo htmlentities($string); ?&gt;<\/code> \u0438\u043b\u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>Laravel<\/code> <code>e($string)<\/code><\/p><\/blockquote>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <i>app\/views\/offers\/edit.blade.php<\/i>, <i>app\/views\/offers\/show.blade.php<\/i> \u0438 \u043c\u0435\u0442\u043e\u0434 <code>update<\/code> \u0432 <i>app\/controllers\/OfferController.php<\/i>.<\/p>\n<p>  \u041a\u043e\u0434 \u0434\u043b\u044f <i>app\/views\/edit.blade.php<\/i>  <\/p>\n<pre><code class=\"html\">\/\/ app\/views\/offers\/edit.blade.php @extends('layouts.scaffold')  @section('main')  &lt;h1&gt;Edit Offer&lt;\/h1&gt; {{ Form::model($offer, array('method' =&gt; 'PATCH', 'route' =&gt; array('offers.update', $offer-&gt;id))) }} \t&lt;ul&gt; \t\t&lt;li&gt; \t\t\t{{ Form::label('title', 'Title:') }} \t\t\t{{ Form::text('title') }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('description', 'Description:') }} \t\t\t{{ Form::textarea('description') }} \t\t&lt;\/li&gt;  \t\t&lt;?php $cities = array(0 =&gt; 'Choose city'); \t\tforeach (City::get(array('id', 'name')) as $city) { \t\t\t$cities[$city-&gt;id] = $city-&gt;name; \t\t} ?&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('city_id', 'City_id:') }} \t\t\t{{ Form::select('city_id', $cities) }} \t\t&lt;\/li&gt;  \t\t&lt;?php $companies = array(0 =&gt; 'Choose company'); \t\tforeach (Company::get(array('id', 'name')) as $company) { \t\t\t$companies[$company-&gt;id] = $company-&gt;name; \t\t} ?&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('company_id', 'Company_id:') }} \t\t\t{{ Form::select('company_id', $companies) }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('off', 'Off:') }} \t\t\t{{ Form::input('number', 'off') }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('file', 'Image:') }} \t\t\t{{ Form::file('file')}} \t\t\t&lt;img src=&quot;{{Input::old('image', $offer-&gt;image)}}&quot; id=&quot;thumb&quot; style=&quot;max-width:300px; max-height: 200px; display:block; &quot;&gt; \t\t\t{{ Form::hidden('image') }} \t\t\t&lt;div class=&quot;error&quot;&gt;&lt;\/div&gt; \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('expires', 'Expires:') }} \t\t\t{{ Form::text('expires') }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('tags', 'Tags:') }} \t\t\t{{ Form::text('tags', Input::old('tags', implode(', ', array_fetch($offer-&gt;tags()-&gt;get(array('name'))-&gt;toArray(), 'name')))) }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::submit('Update', array('class' =&gt; 'btn btn-info')) }} \t\t\t{{ link_to_route('offers.show', 'Cancel', $offer-&gt;id, array('class' =&gt; 'btn')) }} \t\t&lt;\/li&gt; \t&lt;\/ul&gt; {{ Form::close() }}  @if ($errors-&gt;any()) \t&lt;ul&gt; \t\t{{ implode('', $errors-&gt;all('&lt;li class=&quot;error&quot;&gt;:message&lt;\/li&gt;')) }} \t&lt;\/ul&gt; @endif  @stop  @section('scripts') @include('offers.scripts') @stop <\/code><\/pre>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u0441\u0445\u043e\u0436\u044b \u0441 <i>app\/views\/offers\/create.blade.php<\/i>, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 <code>&lt;img src=&quot;{{Input::old('image', $offer-&gt;image)}}&quot;&gt;<\/code> \u0438 <code>{{ Form::text('tags', ... }}<\/code>. \u0421 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439 \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e: \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0438\u043d\u043f\u0443\u0442 \u2014 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442 \u2014 \u0442\u043e \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>image<\/code> \u043d\u0430\u0448\u0435\u0439 \u0441\u043a\u0438\u0434\u043a\u0438. \u0412 <code>Form::text('tags', ... )<\/code> \u043c\u044b, \u0432\u043e \u043f\u0435\u0440\u0432\u044b\u0445, \u0432\u0437\u044f\u043b\u0438 \u0432\u0441\u0435 \u0442\u0435\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u043a\u0438\u0434\u043a\u0435 <code>$offer-&gt;tags()<\/code> \u0438 \u0432\u044b\u043d\u044f\u043b\u0438 \u0438\u0437 \u0411\u0414 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044f <code>name<\/code>. \u0414\u0430\u043b\u0435\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043e\u0442 <code>Laravel<\/code> <a href=\"http:\/\/laravel.com\/docs\/helpers#arrays\">array_fetch<\/a>, \u0447\u0442\u043e \u0431\u044b \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b\u0438 \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443, \u0432\u0441\u0442\u0430\u0432\u0438\u0432 \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u0438 \u043f\u0440\u043e\u0431\u0435\u043b \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438.<\/p>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>update<\/code> \u0432 <code>OfferController<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/OfferController.php class OffersController extends BaseController { \t... \tpublic function update($id) \t{ \t\t$offer = $this-&gt;offer-&gt;findOrFail($id);  \t\t$rules = Offer::$rules; \t\t$rules['expires'] .= '|after:'.date('Y-m-d', strtotime('+1 day')).'|before:'.date('Y-m-d', strtotime('+1 month'));  \t\t$validation = Validator::make(Input::all(), $rules);  \t\tif ($validation-&gt;passes()) \t\t{ \t\t\t$tags = array();  \t\t\tforeach (explode(', ', Input::get('tags')) as $tag_name) { \t\t\t\tif ($tag = Tag::where('name', '=', $tag_name)-&gt;first()) { \t\t\t\t\t$tags[] = $tag-&gt;id; \t\t\t\t} \t\t\t}  \t\t\tif (count($tags) == 0) { \t\t\t\treturn Redirect::route('offers.create') \t\t\t\t\t-&gt;withInput() \t\t\t\t\t-&gt;withErrors($validation) \t\t\t\t\t-&gt;with('message', 'Insert at least one tag.'); \t\t\t} \t\t\t \t\t\t$offer-&gt;update(Input::except('tags', 'file', '_method')); \t\t\t$offer-&gt;tags()-&gt;sync($tags);  \t\t\treturn Redirect::route('offers.show', $id); \t\t}  \t\treturn Redirect::route('offers.edit', $id) \t\t\t-&gt;withInput() \t\t\t-&gt;withErrors($validation) \t\t\t-&gt;with('message', 'There were validation errors.'); \t} \t... <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b. \u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445, \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u043c 404 \u043e\u0448\u0438\u0431\u043a\u0443, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u043d \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 <code>id<\/code>, \u0432\u043e \u0432\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>update($id)<\/code>. \u0412\u043e\u0442 \u0438 \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0444\u0430\u0439\u043b <i>app\/views\/offers\/show.blade.php<\/i>:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/offers\/show.blade.php ... &lt;thead&gt; \t&lt;tr&gt; \t\t&lt;th&gt;Title&lt;\/th&gt; \t\t&lt;th&gt;Description&lt;\/th&gt; \t\t&lt;th&gt;City_id&lt;\/th&gt; \t\t&lt;th&gt;Company_id&lt;\/th&gt; \t\t&lt;th&gt;Off&lt;\/th&gt; \t\t&lt;th&gt;Image&lt;\/th&gt; \t\t&lt;th&gt;Tags&lt;\/th&gt; \t\t&lt;th&gt;Expires&lt;\/th&gt; \t&lt;\/tr&gt; &lt;\/thead&gt;  &lt;tbody&gt; \t&lt;tr&gt; \t\t&lt;td&gt;{{{ $offer-&gt;title }}}&lt;\/td&gt; \t\t&lt;td&gt;{{ $offer-&gt;webDescription(array('shorten' =&gt; true, 'length' =&gt; 60)) }}&lt;\/td&gt; \t\t&lt;td&gt;{{{ $offer-&gt;city-&gt;name }}}&lt;\/td&gt; \t\t&lt;td&gt;{{{ $offer-&gt;company-&gt;name }}}&lt;\/td&gt; \t\t&lt;td&gt;{{{ $offer-&gt;off }}}&lt;\/td&gt; \t\t&lt;td&gt;&lt;img src=&quot;{{{ $offer-&gt;image }}}&quot; style=&quot;max-width: 200px; max-height:150px;&quot;\/&gt;&lt;\/td&gt; \t\t&lt;td&gt; \t\t\t@foreach($offer-&gt;tags as $tag) \t\t\t\t&lt;span class=&quot;badge&quot;&gt;{{{ $tag-&gt;name }}}&lt;\/span&gt; \t\t\t@endforeach \t\t&lt;\/td&gt; \t\t&lt;td&gt;{{{ $offer-&gt;expires }}}&lt;\/td&gt; \t\t... <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438 \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043a\u0438\u0434\u043a\u0438 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0435\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0432\u0441\u0435\u043c\u0438 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<h5>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u0430\u0439\u0442\u0430<\/h5>\n<p>  \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0442\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u0430\u0439\u0442\u0430.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 <code>layout<\/code>:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/layouts\/main.blade.php &lt;!doctype html&gt; &lt;html&gt; \t&lt;head&gt; \t\t&lt;meta charset=&quot;utf-8&quot;&gt; \t\t&lt;link href=&quot;\/\/netdna.bootstrapcdn.com\/twitter-bootstrap\/2.3.1\/css\/bootstrap-combined.min.css&quot; rel=&quot;stylesheet&quot;&gt; \t\t&lt;link rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; href=&quot;{{ asset('css\/main.css') }}&quot;&gt; \t\t@yield('styles') \t&lt;\/head&gt;  \t&lt;body&gt;  \t\t&lt;div class=&quot;navbar navbar-fixed-top&quot;&gt; \t\t\t&lt;div class=&quot;navbar-inner&quot;&gt; \t\t\t\t&lt;div class=&quot;container&quot;&gt; \t\t\t\t\t&lt;a class=&quot;brand&quot; href=&quot;{{ route('home') }}&quot;&gt;Habr Offers&lt;\/a&gt; \t\t\t\t\t&lt;ul class=&quot;nav&quot;&gt; \t\t\t\t\t\t&lt;li&gt;&lt;a href=&quot;{{ route('home') }}&quot;&gt;Home&lt;\/a&gt;&lt;\/li&gt; \t\t\t\t\t&lt;\/ul&gt; \t\t\t\t&lt;\/div&gt; \t\t\t&lt;\/div&gt; \t\t&lt;\/div&gt;  \t\t&lt;div class=&quot;container&quot;&gt;  \t\t\t@if (Session::has('message')) \t\t\t\t&lt;div class=&quot;flash alert&quot;&gt; \t\t\t\t\t&lt;p&gt;{{ Session::get('message') }}&lt;\/p&gt; \t\t\t\t&lt;\/div&gt; \t\t\t@endif  \t\t\t@yield('main') \t\t&lt;\/div&gt;  \t\t&lt;script type=&quot;text\/javascript&quot; src=&quot;\/\/code.jquery.com\/jquery.min.js&quot;&gt;&lt;\/script&gt; \t\t&lt;script type=&quot;text\/javascript&quot; src=&quot;\/\/netdna.bootstrapcdn.com\/twitter-bootstrap\/2.3.1\/js\/bootstrap.min.js&quot;&gt;&lt;\/script&gt; \t\t@yield('scripts')  \t&lt;\/body&gt;  &lt;\/html&gt; <\/code><\/pre>\n<p>  \u0410 \u0442\u0430\u043a \u0436\u0435 \u0444\u0430\u0439\u043b \u0441\u0442\u0438\u043b\u0435\u0439:<\/p>\n<pre><code class=\"css\">\/\/ public\/css\/main.css \/* \u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u0435 \u0432\u0435\u0440\u0445\u043d\u0435\u0435 \u043c\u0435\u043d\u044e - \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0442\u0441\u0442\u0443\u043f \u043e\u0442 \u0432\u0435\u0440\u0445\u0430 *\/ body {padding-top: 60px;}  \/* \u0414\u043b\u044f \u0441\u0441\u044b\u043b\u043e\u043a, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435 *\/ .no_decoration:hover, .no_decoration:focus {text-decoration: none;}   \/* \u0412\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u0432\u044b\u0441\u043e\u0442\u0435 \u0432\u0441\u0435\u0445 \u0441\u043a\u0438\u0434\u043e\u043a \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \/ \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f *\/ .thumbnail .image-container {width: 100%; max-height: 200px; overflow: hidden;} .thumbnail .image-container img {min-width: 100%; min-height: 100%;} .thumbnail h3 {height: 40px; overflow: hidden;} .thumbnail .description {height: 100px; overflow: hidden;} <\/code><\/pre>\n<p>  \u041f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"php\">\/\/ app\/routes.php Route::get('\/', array('as' =&gt; 'home', 'uses' =&gt; 'HomeController@index')); <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HomeController<\/code> \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <code>index<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/HomeController.php \t... \t\/** \t * Display a listing of offers. \t * \t * @return Response \t *\/ \tpublic function index() \t{ \t\t$offers = Offer::orderBy('created_at', 'desc')-&gt;get();  \t\treturn View::make('home.index', compact('offers')); \t} \t... <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <i>app\/views\/home<\/i>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0443\u0434\u0430 \u0444\u0430\u0439\u043b <i>index.blade.php<\/i>, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <i>_preview.blade.php<\/i> \u0432 \u043f\u0430\u043f\u043a\u0435 <i>app\/views\/offers<\/i><\/p>\n<pre><code class=\"html\">\/\/ app\/views\/home\/index.blade.php @extends('layouts.main')  @section('main')  &lt;h1&gt;{{ $title }}&lt;\/h1&gt;  @if ($offers-&gt;count()) \t@foreach ($offers as $key =&gt; $offer) \t\t@if($key % 3 == 0) \t\t\t&lt;div class=&quot;row-fluid&quot;&gt; \t\t\t\t&lt;ul class=&quot;thumbnails&quot;&gt; \t\t@endif  \t\t&lt;li class=&quot;span4&quot;&gt; \t\t\t&lt;div class=&quot;thumbnail&quot;&gt; \t\t\t\t@include('offers._preview', $offer) \t\t\t&lt;\/div&gt; \t\t&lt;\/li&gt; \t\t\t \t\t@if($key % 3 == 2 || $key == count($offers) - 1) \t\t\t\t&lt;\/ul&gt; \t\t\t&lt;\/div&gt; \t\t@endif \t@endforeach @else \tThere are no offers @endif  @stop  \/\/ app\/views\/offers\/_preview.blade.php &lt;div class=&quot;image-container&quot;&gt; \t&lt;img src=&quot;{{{ $offer-&gt;image }}}&quot;&gt; &lt;\/div&gt; &lt;div class=&quot;caption&quot;&gt; \t&lt;h3&gt;{{{ $offer-&gt;title }}}&lt;\/h3&gt; \t&lt;hr&gt; \t&lt;p class=&quot;description&quot;&gt;{{ $offer-&gt;webDescription() }}&lt;\/p&gt; \t&lt;hr&gt; \t&lt;p&gt;&lt;span class=&quot;label label-important&quot;&gt;{{{ $offer-&gt;off }}} % off&lt;\/span&gt;&lt;\/p&gt; \t&lt;p&gt;Location: {{{ $offer-&gt;city-&gt;name }}}&lt;\/p&gt; \t&lt;p&gt;Offer by: {{{ $offer-&gt;company-&gt;name }}}&lt;\/p&gt; \t&lt;p&gt;Expires on: &lt;span class=&quot;label label-warning&quot;&gt;{{{ $offer-&gt;expires }}}&lt;\/span&gt;&lt;\/p&gt; \t&lt;p&gt;Tags: \t\t@foreach($offer-&gt;tags as $tag) \t\t\t&lt;span class=&quot;badge&quot;&gt;{{{$tag-&gt;name}}}&lt;\/span&gt; \t\t@endforeach \t&lt;\/p&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0441\u043a\u0438\u0434\u043e\u043a \u043f\u043e \u0442\u0435\u0433\u0430\u043c, \u0433\u043e\u0440\u043e\u0434\u0430\u043c \u0438 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c 3 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0432 \u0444\u0430\u0439\u043b <i>app\/routes.php<\/i> \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0437\u0430 <code>home<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/routes.php ... Route::get('by_tag\/{name}', array('as' =&gt; 'home.by_tag', 'uses' =&gt; 'HomeController@byTag'))-&gt;where('name', '[A-Za-z0-9 -_]+'); Route::get('by_city\/{name}', array('as' =&gt; 'home.by_city', 'uses' =&gt; 'HomeController@byCity'))-&gt;where('name', '[A-Za-z0-9 -_]+'); Route::get('by_company\/{name}', array('as' =&gt; 'home.by_company', 'uses' =&gt; 'HomeController@byCompany'))-&gt;where('name', '[A-Za-z0-9 -_]+'); ... <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 <code>HomeController<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/HomeController.php \t... \t\/** \t * Display a listing of offers that belongs to tag. \t * \t * @param  string  $name \t * @return Response \t *\/ \tpublic function byTag($name) \t{ \t\t$tag = Tag::whereName($name)-&gt;firstOrFail();  \t\t$offers = $tag-&gt;offers; \t\t$title = &quot;Offers tagged as: &quot; . $tag-&gt;name;  \t\treturn View::make('home.index', compact('offers', 'title')); \t}  \t\/** \t * Display a listing of offers that belongs to city. \t * \t * @param  string  $name \t * @return Response \t *\/ \tpublic function byCity($name) \t{ \t\t$city = City::whereName($name)-&gt;firstOrFail();  \t\t$offers = $city-&gt;offers; \t\t$title = &quot;Offers in: &quot; . $city-&gt;name;  \t\treturn View::make('home.index', compact('offers', 'title')); \t}  \t\/** \t * Display a listing of offers that belongs to company. \t * \t * @param  string  $name \t * @return Response \t *\/ \tpublic function byCompany($name) \t{ \t\t$company = Company::whereName($name)-&gt;firstOrFail();  \t\t$offers = $company-&gt;offers; \t\t$title = &quot;Offers by: &quot; . $company-&gt;name;  \t\treturn View::make('home.index', compact('offers', 'title')); \t} \t... <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u0438 \u0432 \u041c\u043e\u0434\u0435\u043b\u044f\u0445 <code>City<\/code>, <code>Company<\/code> \u0438 <code>Tag<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/City.php \t... \tpublic function offers() \t{ \t\treturn $this-&gt;hasMany('Offer'); \t}  \/\/ app\/models\/Company.php \t... \tpublic function offers() \t{ \t\treturn $this-&gt;hasMany('Offer'); \t}  \/\/ app\/models\/Tag.php \t... \tpublic function offers() \t{ \t\treturn $this-&gt;belongsToMany('Offer'); \t} <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0431\u044b \u0432\u0441\u0435 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0437\u0430\u0438\u0433\u0440\u0430\u043b\u043e, \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0444\u0430\u0439\u043b <i>app\/views\/offers\/_preview.blade.php<\/i>, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0441\u0441\u044b\u043b\u043e\u043a:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/offers\/_preview.blade.php &lt;a class=&quot;image-container&quot; href=&quot;{{ route('home.offer', $offer-&gt;id) }}&quot;&gt; \t&lt;img src=&quot;{{{ $offer-&gt;image }}}&quot;&gt; &lt;\/a&gt; &lt;div class=&quot;caption&quot;&gt; \t&lt;h3&gt;{{{ $offer-&gt;title }}}&lt;\/h3&gt; \t&lt;hr&gt; \t&lt;p class=&quot;description&quot;&gt;{{ $offer-&gt;webDescription() }}&lt;\/p&gt; \t&lt;hr&gt; \t&lt;p&gt;&lt;span class=&quot;label label-important&quot;&gt;{{{ $offer-&gt;off }}} % off&lt;\/span&gt;&lt;\/p&gt; \t&lt;p&gt;Location: &lt;a href=&quot;{{ route('home.by_city', $offer-&gt;city-&gt;name) }}&quot;&gt;{{{ $offer-&gt;city-&gt;name }}}&lt;\/a&gt;&lt;\/p&gt; \t&lt;p&gt;Offer by: &lt;a href=&quot;{{ route('home.by_company', $offer-&gt;company-&gt;name) }}&quot;&gt;{{{ $offer-&gt;company-&gt;name }}}&lt;\/a&gt;&lt;\/p&gt; \t&lt;p&gt;Expires on: &lt;span class=&quot;label label-warning&quot;&gt;{{{ $offer-&gt;expires }}}&lt;\/span&gt;&lt;\/p&gt; \t&lt;p&gt;Tags: \t\t@foreach($offer-&gt;tags as $tag) \t\t\t&lt;a class=&quot;no_decoration&quot; href=&quot;{{ route('home.by_tag', $tag-&gt;name) }}&quot;&gt; \t\t\t\t&lt;span class=&quot;badge&quot;&gt;{{{$tag-&gt;name}}}&lt;\/span&gt; \t\t\t&lt;\/a&gt; \t\t@endforeach \t&lt;\/p&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  \u041a\u043b\u0438\u043a\u0430\u0435\u043c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c, \u0441\u043a\u0438\u0434\u043a\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043a\u0438\u0434\u043a\u0438:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/offers\/_show.blade.php @extends('layouts.main')  @section('main')  &lt;div class=&quot;page-header&quot;&gt; \t&lt;h1&gt; \t\t&lt;span class=&quot;label label-important label-big&quot;&gt;{{{ $offer-&gt;off }}}%&lt;\/span&gt; \t\t{{{ $offer-&gt;title }}}  \t\t&lt;small&gt; by \t\t\t&lt;a href=&quot;{{{ route('home.by_company', $offer-&gt;company-&gt;name) }}}&quot;&gt;{{{ $offer-&gt;company-&gt;name }}}&lt;\/a&gt; \t\t&lt;\/small&gt; \t&lt;\/h1&gt; &lt;\/div&gt;  &lt;div class=&quot;pull-left image-container-big&quot;&gt; \t&lt;img class=&quot;img-rounded&quot; src=&quot;{{{ $offer-&gt;image }}}&quot; alt=&quot;{{{ $offer-&gt;title }}}&quot;&gt; &lt;\/div&gt;  &lt;div class=&quot;description&quot;&gt; \t&lt;p&gt;{{ $offer-&gt;webDescription() }}&lt;\/p&gt; &lt;\/div&gt;  &lt;div class=&quot;clearfix&quot;&gt;&lt;\/div&gt; &lt;hr&gt; &lt;p&gt;Location:  \t&lt;a href=&quot;{{ route('home.by_city', $offer-&gt;city-&gt;name) }}&quot;&gt;{{{ $offer-&gt;city-&gt;name }}}&lt;\/a&gt; &lt;\/p&gt; &lt;p&gt;Tags:  \t@foreach($offer-&gt;tags as $tag) \t\t&lt;a class=&quot;no_decoration&quot; href=&quot;{{ route('home.by_tag', $tag-&gt;name) }}&quot;&gt; \t\t\t&lt;span class=&quot;badge&quot;&gt;{{{$tag-&gt;name}}}&lt;\/span&gt; \t\t&lt;\/a&gt; \t@endforeach &lt;\/p&gt;  &lt;hr&gt;  &lt;div class=&quot;page-header&quot;&gt;   &lt;h3&gt;User's comments &lt;small&gt;leave and yours one&lt;\/small&gt;&lt;\/h3&gt; &lt;\/div&gt;  {{ Form::open() }} {{ Form::textarea('body', Input::old('body'), array('class' =&gt; 'input-block-level', 'style' =&gt; 'resize: vertical;'))}}  &lt;div class=&quot;input-append&quot;&gt; {{ Form::select('mark', array(0 =&gt; 5, 1 =&gt; 4, 2 =&gt; 3, 3 =&gt; 2, 4 =&gt; 1), Input::old('mark', 0)) }} {{ Form::submit('Comment', array('class' =&gt; 'btn btn-success', 'style' =&gt; 'clear: both;')) }} &lt;\/div&gt; {{ Form::close() }} @include('partials.errors', $errors) @stop \/\/ public\/css\/main.css \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a body {padding-top: 60px;} .error {color: red;} .no_decoration:hover, .no_decoration:focus {text-decoration: none;} .thumbnail .image-container {width: 100%; max-height: 200px; overflow: hidden; display: block;} .thumbnail .image-container img {min-width: 100%; min-height: 100%;} .thumbnail h3 {height: 40px; overflow: hidden;} .thumbnail .description {height: 100px; overflow: hidden;}  .image-container-big {width: 500px; height: 300px; margin: 0 20px 20px 0; text-align: center;} .image-container-big img {max-height: 300px; margin: 0 auto;}  .label.label-big {font-size: 32px; line-height: 1.5em; padding: 0 15px; margin-bottom: 5px;} <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0441\u043a\u0438\u0434\u043a\u0443 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0438 \u043c\u0435\u0442\u043e\u0434, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432. \u0414\u043b\u044f \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0438 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435:<\/p>\n<pre><code class=\"php\">\/\/ app\/routes.php ... Route::get('offer_{id}', array('as' =&gt; 'home.offer', 'uses' =&gt; 'HomeController@showOffer'))-&gt;where('id', '[0-9]+'); Route::post('offer_{id}', array('before' =&gt; 'not_guest', 'uses' =&gt; 'HomeController@commentOnOffer'))-&gt;where('id', '[0-9]+'); ... Route::filter('not_guest', function(){ \tif (Auth::guest()) { \t\treturn Redirect::back()-&gt;withInput()-&gt;with('message', 'You should be logged in to provide this action.'); \t} }); \/\/ app\/controllers\/HomeController.php \t... \t\/** \t * Display an offer. \t * \t * @param  int  $id \t * @return Response \t *\/ \tpublic function showOffer($id) \t{ \t\t$offer = Offer::findOrFail($id);  \t\treturn View::make('offers._show', compact('offer')); \t} \t \t\/** \t * Storing comment on offer. \t * \t * @param  int  $id \t * @return Response \t *\/ \tpublic function commentOnOffer($id) \t{ \t\t$offer = Offer::findOrFail($id);  \t\tif ($offer-&gt;usersComments-&gt;contains(Auth::user()-&gt;id)) { \t\t\treturn Redirect::back()-&gt;withInput()-&gt;with('message', 'You have already commented on this Offer'); \t\t}  \t\t$rules = array('body' =&gt; 'required|alpha|min:10|max:500', 'mark' =&gt; 'required|numeric|between:1,5'); \t\t$validator = Validator::make(Input::all(), $rules);  \t\tif ($validator-&gt;passes()) { \t\t\t$offer-&gt;usersComments()-&gt;attach(Auth::user()-&gt;id, array('body' =&gt; Input::get('body'), 'mark' =&gt; Input::get('mark'))); \t\t\treturn Redirect::back(); \t\t}  \t\treturn Redirect::back()-&gt;withInput()-&gt;withErrors($validator); \t} \t... <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441\u043e \u0432\u0441\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443:  <\/p>\n<ul>\n<li>\u0421 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u043a\u0438\u0434\u043a\u0438, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442 \u2014 \u044d\u0442\u043e \u0432\u0441\u0435 \u0442\u0430 \u0436\u0435 \u0432\u0435\u0440\u0441\u0442\u043a\u0430 + \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440.<\/li>\n<li>\u0412 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430\u0445 \u0442\u043e\u0436\u0435 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e, \u0432\u0441\u0435 \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u043a\u0430\u043a \u0438 \u0440\u0430\u043d\u044c\u0448\u0435: \u0441\u0441\u044b\u043b\u043a\u0430 \u2014 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440@\u043c\u0435\u0442\u043e\u0434, \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e <code>Route::post('\/offer_{id}'...)<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0437 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0434\u0430\u0435\u0442 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/li>\n<li><code>showOffer($id)<\/code> \u0442\u043e\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442.<\/li>\n<li>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0441\u0430\u043c \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432. \u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043b\u0438 <code>id<\/code> \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438.\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 <code>offers<\/code> \u0434\u043b\u044f \u0441\u043a\u0438\u0434\u043a\u0438 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u042d\u0442\u0443 \u0441\u0432\u044f\u0437\u044c \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u041c\u043e\u0434\u0435\u043b\u0438 <code>Offer<\/code><\/p>\n<pre><code class=\"php\">\/\/ app\/models\/Offer.php \t... \tpublic function usersComments() \t{ \t\treturn $this-&gt;belongsToMany('User', 'comments')-&gt;withPivot('body', 'mark')-&gt;withTimestamps(); \t} \t... <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043c\u044b \u0442\u0443\u0442 \u044f\u0432\u043d\u043e \u0437\u0430\u0434\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <code>comments<\/code> \u043a\u0430\u043a \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0443\u044e, \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u0432 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 <code>body<\/code> \u0438 <code>mark<\/code> + \u0432 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0448\u0442\u0430\u043c\u043f\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f).<\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443, \u0435\u0441\u0442\u044c \u043b\u0438 \u0443\u0436\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u043a\u0438\u0434\u043a\u0435 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u043c\u0435\u0442\u043e\u0434 <a href=\"http:\/\/laravel.com\/docs\/eloquent#collections\">contains()<\/a>), \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442 \u2014 \u0442\u043e \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a \u0441\u043a\u0438\u0434\u043a\u0435 \u0441 \u0435\u0433\u043e \u043e\u0446\u0435\u043d\u043a\u043e\u0439 \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u043c.   <\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u043a\u0438\u0434\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b <i>app\/views\/offers\/_show.blade.php<\/i><\/p>\n<pre><code class=\"html\">\/\/ app\/views\/offers\/_show.blade.php ... @if(!$offer-&gt;usersComments-&gt;count()) &lt;div class=&quot;well&quot;&gt;You can be first to comment on this offer!&lt;\/div&gt; @endif  @if(Auth::guest() || (!Auth::guest() && !$offer-&gt;usersComments-&gt;contains(Auth::user()-&gt;id))) {{ Form::open() }} {{ Form::textarea('body', Input::old('body'), array('class' =&gt; 'input-block-level', 'style' =&gt; 'resize: vertical;'))}}  &lt;div class=&quot;input-append&quot;&gt; {{ Form::select('mark', array(5 =&gt; 5, 4 =&gt; 4, 3 =&gt; 3, 2 =&gt; 2, 1 =&gt; 1), Input::old('mark', 5)) }} {{ Form::submit('Comment', array('class' =&gt; 'btn btn-success', 'style' =&gt; 'clear: both;')) }} &lt;\/div&gt; {{ Form::close() }} @include('partials.errors', $errors) @endif  @foreach($offer-&gt;usersComments as $user) &lt;div class=&quot;media&quot;&gt; \t&lt;a class=&quot;pull-left&quot; href=&quot;#&quot;&gt; \t\t&lt;img class=&quot;media-object&quot; data-src=&quot;holder.js\/64x64&quot;&gt; \t&lt;\/a&gt; \t&lt;div class=&quot;media-body&quot;&gt; \t\t&lt;h4 class=&quot;media-heading&quot;&gt;{{{ $user-&gt;username }}} &lt;span class=&quot;label label-success&quot;&gt;mark: {{{ $user-&gt;pivot-&gt;mark }}}&lt;\/span&gt;&lt;\/h4&gt; \t&lt;p class=&quot;muted&quot;&gt;{{ str_replace(&quot;\\r\\n&quot;, '&lt;br&gt;', e($user-&gt;pivot-&gt;body)) }}&lt;\/p&gt; \t&lt;\/div&gt; &lt;\/div&gt; @endforeach @stop <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434 \u0441\u043a\u0438\u0434\u043a\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443, \u0438 \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0443\u0436\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u2014 \u0442\u043e \u0444\u043e\u0440\u043c\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0430\u0439\u0442\u0443. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u043a\u0430\u0436\u0435\u043c \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u0440\u043e\u043b\u044f\u043c\u0438:<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/User.php \t... \tpublic function roles() \t{ \t\treturn $this-&gt;belongsToMany('Role'); \t} \t... <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u043e\u043b\u044f\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439:<\/p>\n<pre><code class=\"php\">\/\/ app\/routes.php ... Route::group(array('before' =&gt; 'admin.auth'), function() { \t... \tRoute::resource('users', 'UsersController');  \tRoute::post('upload', array('uses' =&gt; 'HomeController@uploadOfferImage')); }); ... \/\/ app\/views\/layouts\/scaffold.blade.php ... &lt;li&gt;{{ link_to_route('users.index', 'Users') }}&lt;\/li&gt; &lt;li class=&quot;pull-right&quot;&gt;{{ link_to_route('login.logout', 'Logout') }}&lt;\/li&gt; ... <\/code><\/pre>\n<p>  \u041f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0432 \u041c\u043e\u0434\u0435\u043b\u044c <code>User<\/code> \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u0441 \u0440\u043e\u043b\u044f\u043c\u0438:<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/User.php \t... \tpublic function roles() \t{ \t\treturn $this-&gt;belongsToMany('Role'); \t} \t... <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 <code>UserController<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/UsersController.php class UsersController extends BaseController {  \t\/** \t * User Repository \t * \t * @var User \t *\/ \tprotected $user;  \tpublic function __construct(User $user) \t{ \t\t$this-&gt;user = $user; \t}  \t\/** \t * Display a listing of the resource. \t * \t * @return Response \t *\/ \tpublic function index() \t{ \t\t$users = $this-&gt;user-&gt;all();  \t\treturn View::make('users.index', compact('users')); \t}  \t\/** \t * Display the specified resource. \t * \t * @param  int  $id \t * @return Response \t *\/ \tpublic function show($id) \t{ \t\t$user = $this-&gt;user-&gt;findOrFail($id);  \t\treturn View::make('users.show', compact('user')); \t}  \t\/** \t * Show the form for editing the specified resource. \t * \t * @param  int  $id \t * @return Response \t *\/ \tpublic function edit($id) \t{ \t\t$user = $this-&gt;user-&gt;findOrFail($id);  \t\treturn View::make('users.edit', compact('user')); \t}  \t\/** \t * Update the specified resource in storage. \t * \t * @param  int  $id \t * @return Response \t *\/ \tpublic function update($id) \t{ \t\t$user = $this-&gt;user-&gt;findOrFail($id);  \t\t$roles = array();  \t\tforeach (explode(', ', Input::get('roles')) as $role_name) { \t\t\tif ($role = Role::where('role', '=', $role_name)-&gt;first()) { \t\t\t\t$roles[] = $role-&gt;id; \t\t\t} \t\t}  \t\t$user-&gt;roles()-&gt;sync($roles);  \t\treturn Redirect::route('users.show', $id); \t}  \t\/** \t * Remove the specified resource from storage. \t * \t * @param  int  $id \t * @return Response \t *\/ \tpublic function destroy($id) \t{ \t\t$this-&gt;user-&gt;findOrFail($id)-&gt;delete();  \t\treturn Redirect::route('users.index'); \t}  } <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <i>app\/views\/users<\/i> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0443\u0434\u0430 3 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/users\/index.blade.php @extends('layouts.scaffold')  @section('main')  &lt;h1&gt;All Users&lt;\/h1&gt;  @if ($users-&gt;count()) \t&lt;table class=&quot;table table-striped table-bordered&quot;&gt; \t\t&lt;thead&gt; \t\t\t&lt;tr&gt; \t\t\t\t&lt;th&gt;Username&lt;\/th&gt; \t\t\t\t&lt;th&gt;Email&lt;\/th&gt; \t\t\t\t&lt;th&gt;Roles&lt;\/th&gt; \t\t\t&lt;\/tr&gt; \t\t&lt;\/thead&gt;  \t\t&lt;tbody&gt; \t\t\t@foreach ($users as $user) \t\t\t\t&lt;tr&gt; \t\t\t\t\t&lt;td&gt;{{{ $user-&gt;username }}}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt;{{{ $user-&gt;email }}}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt; \t\t\t\t\t\t@foreach($user-&gt;roles as $role) \t\t\t\t\t\t\t&lt;span class=&quot;badge&quot;&gt;{{{$role-&gt;role}}}&lt;\/span&gt; \t\t\t\t\t\t@endforeach \t\t\t\t\t&lt;\/td&gt; \t\t\t\t\t&lt;td&gt;{{ link_to_route('users.edit', 'Edit', array($user-&gt;id), array('class' =&gt; 'btn btn-info')) }}&lt;\/td&gt; \t\t\t\t\t&lt;td&gt; \t\t\t\t\t\t{{ Form::open(array('method' =&gt; 'DELETE', 'route' =&gt; array('users.destroy', $user-&gt;id))) }} \t\t\t\t\t\t\t{{ Form::submit('Delete', array('class' =&gt; 'btn btn-danger')) }} \t\t\t\t\t\t{{ Form::close() }} \t\t\t\t\t&lt;\/td&gt; \t\t\t\t&lt;\/tr&gt; \t\t\t@endforeach \t\t&lt;\/tbody&gt; \t&lt;\/table&gt; @else \tThere are no users @endif  @stop \/\/ app\/views\/users\/show.blade.php @extends('layouts.scaffold')  @section('main')  &lt;h1&gt;Show User&lt;\/h1&gt;  &lt;p&gt;{{ link_to_route('users.index', 'Return to all users') }}&lt;\/p&gt;  &lt;table class=&quot;table table-striped table-bordered&quot;&gt; \t&lt;thead&gt; \t\t&lt;tr&gt; \t\t\t&lt;th&gt;Username&lt;\/th&gt; \t\t\t&lt;th&gt;Email&lt;\/th&gt; \t\t\t&lt;th&gt;Roles&lt;\/th&gt; \t\t&lt;\/tr&gt; \t&lt;\/thead&gt;  \t&lt;tbody&gt; \t\t&lt;tr&gt; \t\t\t&lt;td&gt;{{{ $user-&gt;username }}}&lt;\/td&gt; \t\t\t&lt;td&gt;{{{ $user-&gt;email }}}&lt;\/td&gt; \t\t\t&lt;td&gt; \t\t\t\t@foreach($user-&gt;roles as $role) \t\t\t\t\t&lt;span class=&quot;badge&quot;&gt;{{{ $role-&gt;role }}}&lt;\/span&gt; \t\t\t\t@endforeach \t\t\t&lt;\/td&gt; \t\t\t&lt;td&gt;{{ link_to_route('users.edit', 'Edit', array($user-&gt;id), array('class' =&gt; 'btn btn-info')) }}&lt;\/td&gt; \t\t\t&lt;td&gt; \t\t\t\t{{ Form::open(array('method' =&gt; 'DELETE', 'route' =&gt; array('users.destroy', $user-&gt;id))) }} \t\t\t\t\t{{ Form::submit('Delete', array('class' =&gt; 'btn btn-danger')) }} \t\t\t\t{{ Form::close() }} \t\t\t&lt;\/td&gt; \t\t&lt;\/tr&gt; \t&lt;\/tbody&gt; &lt;\/table&gt;  @stop \/\/ app\/views\/users\/edit.blade.php @extends('layouts.scaffold')  @section('main')  &lt;h1&gt;Edit User&lt;\/h1&gt; {{ Form::model($user, array('method' =&gt; 'PATCH', 'route' =&gt; array('users.update', $user-&gt;id))) }} \t&lt;ul&gt; \t\t&lt;li&gt; \t\t\t{{ Form::label('username', 'Username:') }} \t\t\t{{ Form::text('username', $user-&gt;username, array('disabled')) }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('email', 'Email:') }} \t\t\t{{ Form::text('email', $user-&gt;email, array('disabled')) }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::label('roles', 'Roles:') }} \t\t\t{{ Form::text('roles', Input::old('roles', implode(', ', array_fetch($user-&gt;roles()-&gt;get(array('role'))-&gt;toArray(), 'role')))) }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{ Form::submit('Update', array('class' =&gt; 'btn btn-info')) }} \t\t\t{{ link_to_route('users.show', 'Cancel', $user-&gt;id, array('class' =&gt; 'btn')) }} \t\t&lt;\/li&gt; \t&lt;\/ul&gt; {{ Form::close() }}  @if ($errors-&gt;any()) \t&lt;ul&gt; \t\t{{ implode('', $errors-&gt;all('&lt;li class=&quot;error&quot;&gt;:message&lt;\/li&gt;')) }} \t&lt;\/ul&gt; @endif  @stop  @section('scripts') &lt;script&gt; $(document).ready(function(){  \tfunction split( val ) { \t\treturn val.split( \/,\\s*\/ ); \t} \tfunction extractLast( term ) { \t\treturn split( term ).pop(); \t}  \t$( &quot;#roles&quot; ) \t\/\/ don't navigate away from the field on tab when selecting an item \t.bind( &quot;keydown&quot;, function( event ) { \t\tif ( event.keyCode === $.ui.keyCode.TAB && \t\t\t$( this ).data( &quot;ui-autocomplete&quot; ).menu.active ) { \t\t\tevent.preventDefault(); \t\t} \t}) \t.autocomplete({ \t\tsource: function( request, response ) { \t\t\t$.getJSON( &quot;\/roles&quot;, { \t\t\t\t\tterm: extractLast( request.term ), \t\t\t\t},  \t\t\t\tfunction( data ) { \t\t\t\t\tresponse($.map(data, function(item) { \t\t\t\t\t\treturn { \t\t\t\t\t\t\tvalue: item.role \t\t\t\t\t\t} \t\t\t\t\t})) \t\t\t\t} \t\t\t); \t\t}, \t\tsearch: function() { \t\t\t\/\/ custom minLength \t\t\tvar term = extractLast( this.value ); \t\t\tif ( term.length &lt; 2 ) { \t\t\treturn false; \t\t\t} \t\t}, \t\tfocus: function() { \t\t\t\/\/ prevent value inserted on focus \t\t\treturn false; \t\t}, \t\tselect: function( event, ui ) { \t\t\tconsole.log(ui); \t\t\tconsole.log(this); \t\t\tvar terms = split( this.value ); \t\t\t\/\/ remove the current input \t\t\tterms.pop(); \t\t\t\/\/ add the selected item \t\t\tterms.push( ui.item.value ); \t\t\t\/\/ add placeholder to get the comma-and-space at the end \t\t\tterms.push( &quot;&quot; ); \t\t\tthis.value = terms.join( &quot;, &quot; ); \t\t\treturn false; \t\t} \t}); }); &lt;\/script&gt; @stop <\/code><\/pre>\n<p>  \u0410 \u0442\u0430\u043a \u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u0434 <code>index<\/code> \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 <code>RolesController<\/code><\/p>\n<pre><code class=\"php\">\t... \tpublic function index() \t{ \t\t$roles = $this-&gt;role-&gt;all();  \t\tif (Request::ajax()) { \t\t\t$roles = Role::where('role', 'like', '%'.Input::get('term', '').'%')-&gt;get(array('id', 'role')); \t\t\treturn $roles; \t\t}  \t\treturn View::make('roles.index', compact('roles')); \t} \t... <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0443 \u043d\u0430\u0441 \u0441 \u0432\u0430\u043c\u0438 \u043d\u0435 \u0431\u044b\u043b\u043e \u0440\u0430\u0437\u0431\u0435\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u043e\u0442\u043a\u0430\u0442\u0438\u043c \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <code>Laravel<\/code> \u2014 \u044d\u0442\u043e <a href=\"http:\/\/laravel.com\/docs\/migrations#database-seeding\">DatabaseSeeder<\/a>. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u0411\u0414 \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438, \u0438\u043b\u0438 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u043c\u0438 \/ \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>UsersTableSeeder<\/code> \u0432 \u043f\u0430\u043f\u043a\u0435 <i>app\/database\/seeds<\/i>:<\/p>\n<pre><code class=\"php\">\/\/ app\/database\/seeds\/UsersTableSeeder.php class UsersTableSeeder extends Seeder {  \tpublic function run() \t{ \t\t$users = array( \t\t\tarray( \t\t\t\t'username' =&gt; 'habrahabr', \t\t\t\t'email'\t=&gt; 'habrahabr@habr.com', \t\t\t\t'password' =&gt; Hash::make('habr'), \t\t\t\t'updated_at' =&gt; DB::raw('NOW()'), \t\t\t\t'created_at' =&gt; DB::raw('NOW()'), \t\t\t\t) \t\t);  \t\tDB::table('users')-&gt;insert($users); \t}  } <\/code><\/pre>\n<p>  \u041b\u043e\u0433\u0438\u043a\u0430 \u0442\u0430\u043a\u043e\u0432\u0430: \u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0411\u0414. <\/p>\n<p>  \u041f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 <code>RolesTableSeeder<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/database\/seeds\/RolesTableSeeder.php class RolesTableSeeder extends Seeder {  \tpublic function run() \t{ \t\t$roles = array( \t\t\tarray( \t\t\t\t'role' =&gt; 'admin',  \t\t\t\t'updated_at' =&gt; DB::raw('NOW()'), \t\t\t\t'created_at' =&gt; DB::raw('NOW()') \t\t\t\t), \t\t\tarray( \t\t\t\t'role' =&gt; 'manager',  \t\t\t\t'updated_at' =&gt; DB::raw('NOW()'), \t\t\t\t'created_at' =&gt; DB::raw('NOW()') \t\t\t\t), \t\t\tarray( \t\t\t\t'role' =&gt; 'moderator',  \t\t\t\t'updated_at' =&gt; DB::raw('NOW()'), \t\t\t\t'created_at' =&gt; DB::raw('NOW()') \t\t\t\t)  \t\t);  \t\tDB::table('roles')-&gt;insert($roles); \t}  } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u044f \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0440\u043e\u043b\u0438 <code>manager<\/code> \u0438 <code>moderator<\/code>, \u0447\u0442\u043e \u0431\u044b \u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0441 \u044d\u0442\u0438\u043c\u0438 \u0440\u043e\u043b\u044f\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0432 \u0430\u0434\u043c\u0438\u043d \u043f\u0430\u043d\u0435\u043b\u0438.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 <code>Seeder<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/database\/seeds\/RoleUserTableSeeder.php class RoleUserTableSeeder extends Seeder {  \tpublic function run() \t{ \t\t\/\/ Uncomment the below to wipe the table clean before populating \t\tDB::table('role_user')-&gt;truncate();  \t\t$role_user = array( \t\t\tarray('user_id' =&gt; 1, 'role_id' =&gt; 1) \t\t);  \t\t\/\/ Uncomment the below to run the seeder \t\tDB::table('role_user')-&gt;insert($role_user); \t}  } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0440\u043e\u043b\u044c <code>admin<\/code> \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0411\u0414 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0435 \u043d\u0430\u0448\u0438\u043c\u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0444\u0430\u0439\u043b <i>app\/database\/seeds\/DatabaseSeeder.php<\/i> \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">\/\/ app\/database\/seeds\/DatabaseSeeder class DatabaseSeeder extends Seeder {  \t\/** \t * Run the database seeds. \t * \t * @return void \t *\/ \tpublic function run() \t{ \t\tEloquent::unguard();  \t\t\/\/ \u0412\u044b\u0437\u043e\u0432\u044b \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0411\u0414 \t\t$this-&gt;call('UsersTableSeeder'); \t\t$this-&gt;call('RolesTableSeeder'); \t\t$this-&gt;call('RoleUserTableSeeder'); \t}  } <\/code><\/pre>\n<p>  \u0418 \u0434\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f \u0432\u0441\u0435\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 (\u043d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 <i>\/workspace\/php\/habr\/<\/i>):<\/p>\n<pre><code class=\"bash\">php artisan migrate:refresh --seed <\/code><\/pre>\n<p>  <code>migrate:refresh<\/code> \u043e\u0442\u043a\u0430\u0442\u0438\u0442 \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438\u0445 \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442, \u0430 \u043e\u043f\u0446\u0438\u044f <code>--seed<\/code> \u0443\u043a\u0430\u0436\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <code>DatabaseSeeder<\/code>.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u0441\u0442\u0440\u043e\u0438\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430 \u043f\u0440\u0430\u0432\u0430. \u0412\u043d\u0435\u0441\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u041c\u043e\u0434\u0435\u043b\u044c <code>User<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/User.php \t... \tpublic function isAdmin() \t{ \t\t$admin_role = Role::whereRole('admin')-&gt;first(); \t\treturn $this-&gt;roles-&gt;contains($admin_role-&gt;id); \t} \t... \tpublic function isManager() \t{ \t\t$manager_role = Role::whereRole('manager')-&gt;first(); \t\treturn $this-&gt;roles-&gt;contains($manager_role-&gt;id) || $this-&gt;isAdmin(); \t} \t... \tpublic function isModerator() \t{ \t\t$admin_role = Role::whereRole('admin')-&gt;first(); \t\treturn $this-&gt;roles-&gt;contains($admin_role-&gt;id) || $this-&gt;isAdmin(); \t} \t... \tpublic function isRegular() \t{ \t\t$roles = array_filter($this-&gt;roles-&gt;toArray()); \t\treturn empty($roles); \t} } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0444\u0430\u0439\u043b \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432, \u0447\u0442\u043e \u0431\u044b \u043e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u043f\u0440\u0430\u0432\u0430\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0430\u0439\u0442\u043e\u043c:<\/p>\n<pre><code class=\"php\">\/\/ app\/routes.php ... Route::post('offer_{id}', array('before' =&gt; 'not_guest|regular_user', 'uses' =&gt; 'HomeController@commentOnOffer'))-&gt;where('id', '[0-9]+'); ... Route::group(array('before' =&gt; 'admin.auth'), function() { \tRoute::get('dashboard', function() \t{ \t\treturn View::make('dasboard'); \t});  \tRoute::group(array('before' =&gt; 'manager_role_only'), function() \t{ \t\tRoute::resource('cities', 'CitiesController');  \t\tRoute::resource('companies', 'CompaniesController');  \t\tRoute::resource('tags', 'TagsController');  \t\tRoute::resource('offers', 'OffersController'); \t\t \t\tRoute::post('upload', array('uses' =&gt; 'HomeController@uploadOfferImage')); \t});  \tRoute::resource('comments', 'CommentsController');  \tRoute::group(array('before' =&gt; 'manager_role_only'), function() \t{ \t\tRoute::resource('roles', 'RolesController');  \t\tRoute::resource('users', 'UsersController');\t \t}); });  Route::when('comments*', 'moderator_role_only');  Route::filter('admin_role_only', function() { \tif (Auth::user()-&gt;isAdmin()) { \t\treturn Redirect::intended('\/')-&gt;withMessage('You don\\'t have enough permissions to do that.'); \t} });  Route::filter('manager_role_only', function()  { \tif (!Auth::user()-&gt;isManager()) { \t\treturn Redirect::intended('\/')-&gt;withMessage('You don\\'t have enough permissions to do that.'); \t} });  Route::filter('moderator_role_only', function()  { \tif (!Auth::user()-&gt;isModerator()) { \t\treturn Redirect::intended('\/')-&gt;withMessage('YYou don\\'t have enough permissions to do that.'); \t} });  Route::filter('admin.auth', function()  { \tif (Auth::guest()) { \t\treturn Redirect::to('login'); \t} });  Route::filter('un_auth', function() { \tif (!Auth::guest()) { \t\tAuth::logout(); \t} });  Route::filter('not_guest', function(){ \tif (Auth::guest()) { \t\treturn Redirect::intended('\/')-&gt;withInput()-&gt;with('message', 'You should be logged in to provide this action.'); \t} });  Route::filter('regular_user', function(){ \tif (!Auth::guest()) { \t\tif (!Auth::user()-&gt;isRegular()) { \t\t\treturn Redirect::back()-&gt;with('message', 'You cannot do that due to your role.'); \t\t} \t} }); <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043a \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442. \u0422\u0430\u043a\u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0438\u043a\u0442\u043e, \u043a\u0440\u043e\u043c\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u0430\u0439\u0442\u0430 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a \u0441\u043a\u0438\u0434\u043a\u0430\u043c.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0442\u0443\u0442 \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043c\u0430\u0440\u0448\u0440\u0443\u0442 <code>Route::when()<\/code> \u2014 \u044d\u0442\u043e \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 (<a href=\"http:\/\/laravel.com\/docs\/routing#route-filters\">Pattern Filter<\/a>). \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d <code>URL<\/code>, \u0432\u0442\u043e\u0440\u044b\u043c \u2014 \u0441\u0430\u043c \u0444\u0438\u043b\u044c\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c, \u0430 \u0442\u0440\u0435\u0442\u044c\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 <code>HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/code>, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440.<\/p>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>login()<\/code> \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 <code>LoginController<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/LoginController.php \t... \tpublic function login() \t{ \t\tif (Auth::attempt(array('email' =&gt; Input::get('email'), 'password' =&gt; Input::get('password')), true) \t\t\t|| Auth::attempt(array('username' =&gt; Input::get('email'), 'password' =&gt; Input::get('password')), true))\t{ \t\t\t \t\t\tif (!Auth::user()-&gt;isRegular()) { \t\t\t\treturn Redirect::to('dashboard'); \t\t\t} \t\t\t \t\t\treturn Redirect::intended('\/'); \t\t}  \t\treturn Redirect::back()-&gt;withInput(Input::except('password'))-&gt;with('message', 'Wrong creadentials!'); \t} <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u0445\u043e\u0434\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u044b, \u043c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u0432 \u0430\u0434\u043c\u0438\u043d\u043f\u0430\u043d\u0435\u043b\u044c.<\/p>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u043c\u0435\u043d\u044e \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/layouts\/scaffold.blade.php @if(!Auth::guest()) \t&lt;ul class=&quot;nav nav-pills&quot;&gt; \t\t@if(Auth::user()-&gt;isManager()) \t\t&lt;li&gt;{{ link_to_route('offers.index', 'Offers') }}&lt;\/li&gt; \t\t&lt;li&gt;{{ link_to_route('companies.index', 'Companies') }}&lt;\/li&gt; \t\t&lt;li&gt;{{ link_to_route('tags.index', 'Tags') }}&lt;\/li&gt; \t\t&lt;li&gt;{{ link_to_route('cities.index', 'Cities') }}&lt;\/li&gt; \t\t@endif \t\t@if(Auth::user()-&gt;isModerator()) \t\t&lt;li&gt;{{ link_to_route('comments.index', 'Comments') }}&lt;\/li&gt; \t\t@endif \t\t@if(Auth::user()-&gt;isAdmin()) \t\t&lt;li&gt;{{ link_to_route('roles.index', 'Roles') }}&lt;\/li&gt; \t\t&lt;li&gt;{{ link_to_route('users.index', 'Users') }}&lt;\/li&gt; \t\t@endif \t\t&lt;li class=&quot;pull-right&quot;&gt;{{ link_to_route('login.logout', 'Logout') }}&lt;\/li&gt; \t&lt;\/ul&gt; @endif <\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u043e\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u043d\u044b \u0442\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f.<\/p>\n<h5>Emails<\/h5>\n<p>  \u0412\u0430\u0436\u043d\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c \u0434\u043b\u044f web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u043e\u0447\u0442\u044b.<\/p>\n<p>  <code>Laravel<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>SwiftMailer<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0438\u0441\u0435\u043c (<a href=\"http:\/\/laravel.com\/docs\/mail\">Laravel Mail<\/a>).<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u0447\u0442\u044b. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u0438\u0441\u0435\u043c \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043d\u0430 <code>gmail<\/code>, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0443\u0442\u0438 \u043b\u044e\u0431\u044b\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u0447\u0442\u044b \u0441 \u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 (\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 <a href=\"https:\/\/postmarkapp.com\/\">Postmarkapp<\/a>).<\/p>\n<p>  \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u043e\u0447\u0442\u044b:<\/p>\n<pre><code class=\"php\">\/\/ app\/config\/mail.php ... return array( \t... \t'driver' =&gt; 'smtp', \t... \t'host' =&gt; 'smtp.gmail.com', \t... \t'port' =&gt; 587, \t... \t'from' =&gt; array('address' =&gt; 'habrahabr@habr.com', 'name' =&gt; 'Habra Offers'), \t... \t'encryption' =&gt; 'tls', \t... \t'username' =&gt; 'mygmailaccount@gmail.com', \t... \t'password' =&gt; 'mypassword', \t... \t'pretend' =&gt; false ); <\/code><\/pre>\n<p>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>pretend<\/code> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0442\u043e, \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0438\u0441\u044c\u043c\u0430. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 <b>true<\/b>, \u0442\u043e \u043e\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u0438\u0441\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u043d\u043e \u0432 \u043b\u043e\u0433\u0430\u0445 \u0441\u0430\u0439\u0442\u0430 (<i>app\/storage\/logs<\/i>) \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0442\u0447\u0435\u0442\u044b \u043e\u0431 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u0445\u043e\u0447\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u044c\u043c\u043e \u0441 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435\u043c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043c \u0448\u0430\u0431\u043b\u043e\u043d \u0432 \u043f\u0430\u043f\u043a\u0435 <i>app\/views\/emails<\/i>:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/emails\/welcome.blade.php &lt;!DOCTYPE html&gt; &lt;html lang=&quot;en-US&quot;&gt; \t&lt;head&gt; \t\t&lt;meta charset=&quot;utf-8&quot;&gt; \t&lt;\/head&gt; \t&lt;body&gt; \t\t&lt;h1&gt;Welcome to Habra Offers!&lt;\/h1&gt;  \t\t&lt;div&gt; \t\t\tWe are glad that you are interested in us, {{{ $username }}}! \t\t&lt;\/div&gt; \t&lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>store()<\/code> \u043d\u0430\u0448\u0435\u0433\u043e <code>LoginController<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/LoginController.php ... $user-&gt;save();  Mail::send('emails.welcome', array('username' =&gt; $user-&gt;username), function($message) use ($user) { \t$message-&gt;to($user-&gt;email, $user-&gt;username)-&gt;subject('Welcome to Habra Offers!'); });  Auth::loginUsingId($user-&gt;id); ... <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 <a href=\"http:\/\/laravel.com\/docs\/mail#basic-usage\">Mail<\/a> \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u0447\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>send()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0440\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430:  <\/p>\n<ul>\n<li><b>$view<\/b> \u2014 \u0448\u0430\u0431\u043b\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c (\u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u043f\u0435\u0440\u0432\u044b\u0439 \u2014 html \u0448\u0430\u0431\u043b\u043e\u043d, \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 plaintext)<\/li>\n<li><b>$data<\/b> \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043b\u044e\u0447\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435<\/li>\n<li><b>$callback<\/b> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0438\u0441\u044c\u043c\u0430<\/li>\n<\/ul>\n<p>  \u041d\u043e \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043f\u0438\u0441\u044c\u043c\u043e \u2014 \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u043f\u0438\u0441\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d. \u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0431\u044b\u043b \u0441\u0432\u043e\u0439 \u043f\u0430\u0440\u043e\u043b\u044c \u0438 \u0445\u043e\u0447\u0435\u0442 \u0435\u0433\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e <code>Laravel<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <a href=\"http:\/\/laravel.com\/docs\/security#password-reminders-and-reset\">Password Reminders &#038; Reset<\/a>.<br \/>  \u0427\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<pre><code class=\"bash\">cd \/workspace\/php\/habr php artisan auth:reminders php artisan migrate <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u043e\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>Password::remind(array('email' =&gt; $email))<\/code> \u0438 \u043f\u0438\u0441\u044c\u043c\u043e \u0441 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u043e\u043b\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e.<\/p>\n<p>  \u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c 2 \u0448\u0430\u0431\u043b\u043e\u043d\u0430:  <\/p>\n<ul>\n<li><i>app\/views\/auth\/remind.blade.php<\/i> \u2014 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 email \u043d\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u043e\u043b\u044f<br \/> \n<pre><code class=\"html\">\/\/ app\/views\/auth\/remind.blade.php @extends('layouts.scaffold')  @section('main')  @if (Session::has('error')) \t&lt;div class=&quot;alert alert-error&quot;&gt; \t\t{{ trans(Session::get('reason')) }} \t&lt;\/div&gt; @elseif (Session::has('success')) \t&lt;div class=&quot;alert alert-success&quot;&gt; \t\tAn e-mail with the password reset has been sent. \t&lt;\/div&gt; @endif  &lt;h1&gt;Forgot your password?&lt;\/h1&gt;  &lt;p&gt;{{ link_to_route('login.index', 'No') }}&lt;\/p&gt;  {{ Form::open() }} \t&lt;ul&gt; \t\t&lt;li&gt; \t\t\t{{ Form::label('email', 'Your email')}} \t\t\t{{ Form::email('email') }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t{{ Form::submit('Send reminder', array('class' =&gt; 'btn')) }} \t\t&lt;\/li&gt; \t&lt;\/ul&gt; {{ Form::close() }}  @stop <\/code><\/pre>\n<p>   <\/li>\n<li><i>app\/views\/auth\/reset.blade.php<\/i> \u2014 \u0444\u043e\u0440\u043c\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u043e\u043b\u044f<br \/> \n<pre><code class=\"html\">\/\/ app\/views\/auth\/reset.blade.php @extends('layouts.scaffold')  @section('main')  @if (Session::has('error')) \t&lt;div class=&quot;alert alert-error&quot;&gt;     \t{{ trans(Session::get('reason')) }} \t&lt;\/div&gt; @endif  &lt;h1&gt;Reset your password&lt;\/h1&gt;  {{ Form::open() }} {{ Form::hidden('token', $token) }} \t&lt;ul&gt; \t\t&lt;li&gt; \t\t\t{{ Form::label('email', 'Email')}} \t\t\t{{ Form::email('email', Input::old('email')) }} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{Form::label('password', 'New password')}} \t\t\t{{ Form::password('password')}} \t\t&lt;\/li&gt;  \t\t&lt;li&gt; \t\t\t{{Form::label('password', 'New password confirmation')}} \t\t\t{{ Form::password('password_confirmation')}} \t\t&lt;\/li&gt;  \t&lt;\/ul&gt; {{ Form::submit('Reset', array('class' =&gt; 'btn'))}} {{ Form::close() }} @stop <\/code><\/pre>\n<p>   <\/li>\n<\/ul>\n<p>  <\/p>\n<blockquote><p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>trans()<\/code> \u2014 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u041c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0443 <i>app\/lang\/en\/reminders.php<\/i> \u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f. \u0414\u043b\u044f \u0441\u043c\u0435\u043d\u044b \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 <i>app\/config\/app.php<\/i> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <b>locale<\/b> \u0441 <b>en<\/b> \u043d\u0430 <b>ru<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u043f\u043a\u0443 <i>app\/lang\/ru<\/i>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043a\u0430\u043a \u0432 \u043f\u0430\u043f\u043a\u0435 <i>app\/lang\/en<\/i>.  <\/p><\/blockquote>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c 4 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430:<\/p>\n<pre><code class=\"php\">\/\/ app\/routes.php ... Route::group(array('before' =&gt; 'un_auth'), function() { \t... \tRoute::get('password\/remind', array('as' =&gt; 'password.remind', 'uses' =&gt; 'LoginController@showReminderForm')); \tRoute::post('password\/remind', array('uses' =&gt; 'LoginController@sendReminder')); \tRoute::get('password\/reset\/{token}', array('as' =&gt; 'password.reset', 'uses' =&gt; 'LoginController@showResetForm')); \tRoute::post('password\/reset\/{token}', array('uses' =&gt; 'LoginController@resetPassword')); }); ... <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043b\u043e\u0433\u0438\u043d\u0430:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/login\/index.blade.php ... {{ Form::close() }}  &lt;p&gt;{{ link_to_route('password.remind', 'Forgot password?') }}&lt;\/p&gt; ... <\/code><\/pre>\n<p>  \u0410 \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 <code>LoginController<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/LoginController.php \t... \t\/** \t * Show reminder form. \t * \t * @return Response \t *\/ \tpublic function showReminderForm() \t{ \t\treturn View::make('auth.remind'); \t}   \t\/** \t * Send reminder email. \t * \t * @return Response \t *\/ \tpublic function sendReminder() \t{ \t\t$credentials = array('email' =&gt; Input::get('email'));  \t\treturn Password::remind($credentials, function($message, $user) \t\t{ \t\t    $message-&gt;subject('Password Reminder on Habra Offers'); \t\t}); \t}   \t\/** \t * Show reset password form. \t * \t * @return Response \t *\/ \tpublic function showResetForm($token) \t{ \t\treturn View::make('auth.reset')-&gt;with('token', $token); \t}   \t\/** \t * Reset password. \t * \t * @return Response \t *\/ \tpublic function resetPassword($token) \t{ \t\t$credentials = array('email' =&gt; Input::get('email'));  \t\treturn Password::reset($credentials, function($user, $password) \t\t{ \t\t\t$user-&gt;password = Hash::make($password);  \t\t\t$user-&gt;save();  \t\t\tAuth::loginUsingId($user-&gt;id);  \t\t\treturn Redirect::home()-&gt;with('message', 'Your password has been successfully reseted.'); \t    }); \t} <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0430\u0440\u043e\u043b\u044c.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435:  <\/p>\n<pre><code class=\"html\">\/\/ app\/views\/layouts\/main.blade.php ... &lt;a class=&quot;brand&quot; href=&quot;{{ route('home') }}&quot;&gt;Habr Offers&lt;\/a&gt; &lt;ul class=&quot;nav&quot;&gt; \t&lt;li&gt;&lt;a href=&quot;{{ route('home') }}&quot;&gt;Home&lt;\/a&gt;&lt;\/li&gt; &lt;\/ul&gt; &lt;div class=&quot;btn-group pull-right&quot;&gt; \t@if(Auth::guest()) \t\t&lt;a href=&quot;{{ route('login.index') }}&quot; class=&quot;btn&quot;&gt;Login&lt;\/a&gt; \t\t&lt;a href=&quot;{{ route('login.register') }}&quot; class=&quot;btn&quot;&gt;Register&lt;\/a&gt; \t@else \t\t&lt;a href=&quot;{{ route('login.logout') }}&quot; class=&quot;btn&quot;&gt;Logout&lt;\/a&gt; \t@endif &lt;\/div&gt; ... <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 \u0441\u043a\u0438\u0434\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438\u0441\u044c \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u0432 \u041c\u043e\u0434\u0435\u043b\u044c <code>Offer<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/Offer.php \t... \tpublic function scopeActive($query) \t{ \t\treturn $query-&gt;where('expires', '&gt;', DB::raw('NOW()')); \t} \tpublic function scopeSortLatest($query, $desc = true) \t{ \t\t$order = $desc ? 'desc' : 'asc'; \t\treturn $query-&gt;orderBy('created_at', $order); \t} \t... <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>HomeController@index<\/code> \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <code>Offer::orderBy('created_at', 'desc')-&gt;get()<\/code> \u043d\u0430 <code>Offer::active()-&gt;sortLatest()-&gt;get()<\/code>. \u041d\u0430\u0448 \u043d\u043e\u0432\u043e\u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a \u0436\u0435 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e \u0442\u0435\u0433\u0430\u043c, \u0433\u043e\u0440\u043e\u0434\u0430\u043c \u0438 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f\u043c.<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/HomeController.php \t... \tpublic function byTag($name) \t{ \t\t... \t\t$offers = $tag-&gt;offers()-&gt;active()-&gt;sortLatest()-&gt;get(); \t\t... \t} <\/code><\/pre>\n<h5>\u041f\u0430\u0433\u0438\u043d\u0430\u0446\u0438\u044f<\/h5>\n<p>  \u041d\u0435\u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0433\u0438\u043d\u0430\u0446\u0438\u044f. \u0414\u0430, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0411\u0414, \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0442\u044b\u0441\u044f\u0447\u0438 \u0441\u0442\u0440\u043e\u043a \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u0438 \u043f\u043e\u0442\u043e\u043c \u0438\u0445 \u0432\u0441\u0435 \u043f\u0438\u0445\u0430\u0442\u044c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. \u041d\u043e \u044d\u0442\u043e \u0432\u0440\u044f\u0434 \u043b\u0438 \u0447\u0435\u0439 \u043b\u0438\u0431\u043e \u043f\u043e\u0434\u0445\u043e\u0434. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0438\u0437 \u0411\u0414 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>paginate()<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>get()<\/code>, \u0438\u043b\u0438 <code>all()<\/code>. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/HomeController.php \t... \tpublic function index() \t{ \t\t$offers = Offer::active()-&gt;sortLatest()-&gt;paginate(); \t\t... \t} \t... \/\/ app\/views\/home\/index.blade.php ... @if ($offers-&gt;count()) \t{{ $offers-&gt;links() }} \t... \t{{ $offers-&gt;links() }} @else \tThere are no offers @endif ... <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e 15 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u0438 \u0432\u043d\u0438\u0437\u0443 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043f\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e \u2014 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043c\u0435\u0442\u043e\u0434, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>paginate(1)<\/code> \u0434\u0430\u0441\u0442 1 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/HomeController.php \t... \tpublic function byTag($name) \t{ \t\t$tag = Tag::whereName($name)-&gt;firstOrFail();  \t\t$offers = $tag-&gt;offers()-&gt;active()-&gt;sortLatest()-&gt;paginate();  \t\t$title = &quot;Offers tagged as: &quot; . $tag-&gt;name;  \t\treturn View::make('home.index', compact('offers', 'title')); \t} \t... \tpublic function byCity($name) \t{ \t\t$city = City::whereName($name)-&gt;firstOrFail();  \t\t$offers = $city-&gt;offersr()-&gt;active()-&gt;sortLatest()-&gt;paginate();  \t\t$title = &quot;Offers in: &quot; . $city-&gt;name;  \t\treturn View::make('home.index', compact('offers', 'title')); \t} \t... \tpublic function byCompany($name) \t{ \t\t$company = Company::whereName($name)-&gt;firstOrFail();  \t\t$offers = $company-&gt;offers()-&gt;active()-&gt;sortLatest()-&gt;paginate();  \t\t$title = &quot;Offers by: &quot; . $company-&gt;name;  \t\treturn View::make('home.index', compact('offers', 'title')); \t} \t... <\/code><\/pre>\n<p>  \u041d\u0438\u0447\u0435\u0433\u043e \u0432\u0440\u043e\u0434\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442.<\/p>\n<p>  \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0442\u0430\u043a \u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0438 \u0432 \u0430\u0434\u043c\u0438\u043d \u043f\u0430\u043d\u0435\u043b\u0438.<\/p>\n<pre><code class=\"php\">\/\/ app\/controllers\/OffersController \t... \t\/** \t * Display a listing of the resource. \t * \t * @return Response \t *\/ \tpublic function index() \t{ \t\t$offers = $this-&gt;offer-&gt;sortLatest()-&gt;paginate();  \t\treturn View::make('offers.index', compact('offers')); \t} \t... <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0447\u0442\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0441\u0430\u0439\u0442\u0443 \u2014 \u0442\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0432\u043e\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u0438 \u0437\u0430\u043a\u043b\u0430\u0434\u043a\u0438 \u0438\u0437 \u0441\u043a\u0438\u0434\u043e\u043a, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0432 \u043a\u0430\u0440\u043a\u0430\u0441\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/layouts\/main.blade.php &lt;div class=&quot;container&quot;&gt;  \t@if (Session::has('message')) \t\t&lt;div class=&quot;flash alert&quot;&gt; \t\t\t{{ Session::get('message') }} \t\t&lt;\/div&gt; \t@endif \t \t&lt;div class=&quot;row-fluid&quot;&gt; \t\t&lt;div class=&quot;span3&quot;&gt; \t\t\t&lt;h2&gt;Last Comments&lt;\/h2&gt; \t\t \t\t\t@if (count($comments = Comment::take(5)-&gt;get()) &gt; 0) \t\t\t\t@foreach ($comments as $comment) \t\t\t\t\t@include('partials.comment', $comment) \t\t\t\t@endforeach \t\t\t@else \t\t\t\tThere are no comments yet \t\t\t@endif \t\t&lt;\/div&gt;  \t\t&lt;div class=&quot;span9&quot;&gt; \t\t\t@yield('main') \t\t&lt;\/div&gt; \t&lt;\/div&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  \u0410 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0430\u043c \u0448\u0430\u0431\u043b\u043e\u043d <code>comment<\/code>:<\/p>\n<pre><code class=\"html\">\/\/ app\/views\/partials\/comment.blade.php &lt;div class=&quot;well&quot;&gt; \t&lt;a href=&quot;{{ route('home.offer', $comment-&gt;offer_id) }}&quot;&gt; \t\t{{ $comment-&gt;user-&gt;username }}  \t\t&lt;span class=&quot;label label-success pull-right&quot;&gt;mark: {{ $comment-&gt;mark }}&lt;\/span&gt; \t&lt;\/a&gt; \t&lt;div&gt;{{ $comment-&gt;webBody() }}&lt;\/div&gt;\t &lt;\/div&gt; <\/code><\/pre>\n<p>  \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u041c\u043e\u0434\u0435\u043b\u044c\u044e <code>Comment<\/code> <code>User<\/code> \u0438 <code>Offer<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ app\/models\/Comment.php \t... \tpublic function user() \t{ \t\treturn $this-&gt;belongsTo('User'); \t}  \tpublic function offer() \t{ \t\treturn $this-&gt;belongsTo('Offer'); \t}  \tpublic function webBody($options = array()) \t{ \t\t$str = $this-&gt;body;  \t\tif (isset($options['shorten'])) { \t\t\t$length = isset($options['length']) ? (int) $options['length'] : 50; \t\t\t$end = isset($options['end']) ? : '&#8230;'; \t\t\tif (mb_strlen($str) &gt; $length) { \t\t\t\t$str = mb_substr(trim($str), 0, $length); \t\t\t\t$str = mb_substr($str, 0, mb_strlen($str) - mb_strpos(strrev($str), ' ')); \t\t\t\t$str = trim($str.$end); \t\t\t} \t\t} \t\t \t\t$str = str_replace(&quot;\\r\\n&quot;, '&lt;br&gt;', e($str)); \t\treturn $str; \t} \t... <\/code><\/pre>\n<p>  \u0410 \u0442\u0430\u043a \u0436\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043e\u0442 <code>html-\u0442\u0435\u0433\u043e\u0432<\/code> \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f.<\/p>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043a\u043b\u0430\u0434\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code class=\"php\">\/\/ app\/routes.php Route::get('\/', array('as' =&gt; 'home', 'uses' =&gt; 'HomeController@index')); Route::get('bookmarks', array('before' =&gt; 'auth', 'as' =&gt; 'home.bookmarks', 'uses' =&gt; 'HomeController@bookmarks')); ... \/\/ app\/views\/layouts\/main.blade.php ... @if(Auth::guest()) \t&lt;a href=&quot;{{ route('login.index') }}&quot; class=&quot;btn&quot;&gt;Login&lt;\/a&gt; \t&lt;a href=&quot;{{ route('login.register') }}&quot; class=&quot;btn&quot;&gt;Register&lt;\/a&gt; @else \t&lt;a href=&quot;{{ route('home.bookmarks') }}&quot; class=&quot;btn&quot;&gt;My Bookmarks&lt;\/a&gt; \t&lt;a href=&quot;{{ route('login.logout') }}&quot; class=&quot;btn&quot;&gt;Logout&lt;\/a&gt; @endif ... \/\/ app\/models\/User.php \t... \tpublic function usersOffers() \t{ \t\treturn $this-&gt;belongsToMany('Offer', 'comments')-&gt;withPivot('body', 'mark')-&gt;withTimestamps(); \t} \t... \/\/ app\/controllers\/HomeController.php \t... \t\/** \t * Display a listing of bookmarked offers. \t * \t * @return Response \t *\/ \tpublic function bookmarks() \t{ \t\t$offers = Auth::user()-&gt;usersOffers()-&gt;paginate();  \t\t$title = &quot;My Bookmarked Offers&quot;; \t\t \t\treturn View::make('home.index', compact('offers', 'title')); \t} \t... <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0432 <i>app\/route.php<\/i>, \u043f\u043e\u0442\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0435\u0433\u043e \u0432 <i>app\/views\/layouts\/main.blade.php<\/i>, \u0437\u0430\u0434\u0430\u043b\u0438 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u041c\u043e\u0434\u0435\u043b\u044c\u044e <code>User<\/code> \u0438 <code>Offer<\/code>, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 <code>bookmarks<\/code> \u0432 <code>HomeController<\/code>.<\/p>\n<h4>\u0414\u0435\u043f\u043b\u043e\u0439<\/h4>\n<p>  \u041d\u0430\u0441\u0442\u0430\u043b \u0447\u0430\u0441 \u0434\u0435\u043f\u043b\u043e\u044f! \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u044b\u0431\u0440\u0430\u043b <a href=\"http:\/\/fortrabbit.com\">fortrabbit.com<\/a> \u2014 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 <code>PHP<\/code>. \u041e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <code>Git<\/code>, <code>SSH<\/code>, <code>Memcached<\/code>, <code>Composer<\/code>, <code>MySQL<\/code> \u0438 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>  \u041f\u0440\u043e\u0446\u0435\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0430\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/35d\/123\/121\/35d123121dce15cdfafcb5b74f11cc79.png\"\/><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/9c1\/611\/a85\/9c1611a853b3dced97f8dc911c7e3066.png\"\/><\/p>\n<p>  \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <code>habr<\/code>. \u0418\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043d\u0435\u0433\u043e <a href=\"http:\/\/habr.eu1.frbit.net\/\">habr.eu1.frbit.net\/<\/a>. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u043c\u0435\u0442\u043a\u0443 (Habra Offers), \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c <code>ssh<\/code> \u043a\u043b\u044e\u0447 \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0432\u043e\u0439 <code>ssh<\/code> \u043a\u043b\u044e\u0447 \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435:<\/p>\n<pre><code class=\"bash\">cat ~\/.ssh\/id_rsa.pub <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/05f\/b93\/8f0\/05fb938f0b408266c4d8367ec9733e45.png\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f. \u0412\u0430\u043c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e <code>Git<\/code>, <code>SSH<\/code> \u0438 <code>SFTP<\/code>, <code>MySQL<\/code> \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 <code>ReSync<\/code> \u0434\u043e\u0441\u0442\u0443\u043f.<\/p>\n<p>  \u041e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/c1d\/01c\/d1c\/c1d01cd1c29ac516bccbae7bd0965ced.png\"\/><\/p>\n<p>  <code>fortrabbit<\/code> \u0437\u0430\u043c\u043e\u0440\u0430\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u043e, \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u043e\u0440\u043e\u0437\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/fortrabbit.com\/docs\/essentials\/freeze\">\u0442\u0443\u0442<\/a>.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043b\u0438\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 <code>fortrabbit<\/code> \u0438\u0434\u0435\u043c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b:<\/p>\n<pre><code class=\"bash\">cd && cd workspace\/php\/ git clone git@git1.eu1.frbit.com:habr.git fort_habr <\/code><\/pre>\n<p>  \u0411\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043a\u043b\u043e\u043d \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0441 <code>fortrabbit<\/code>&#8216;a. \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043f\u0430\u043f\u043a\u0438 <i>workspace\/php\/habr<\/i> \u0432 \u043f\u0430\u043f\u043a\u0443 <i>workspace\/php\/fort_habr<\/i>. \u0417\u0430\u0439\u0434\u0435\u043c \u0432 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0411\u0414 \u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 <code>MySQL<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">cd fort_habr git add . git commit -am &quot;Initial Commit&quot; git push -u origin master <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0433\u043e, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 <code>ssh<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \u0418\u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">ssh u-habr@ssh1.eu1.frbit.com <\/code><\/pre>\n<p>  \u041f\u043e\u0442\u043e\u043c \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u0432\u043e\u0439 \u043f\u0430\u0440\u043e\u043b\u044c \u0438 \u0432\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<br \/>  \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <i>htdocs<\/i> \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435:<\/p>\n<pre><code class=\"bash\">cd htdocs php artisan migrate:install php artisan migrate --seed <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0411\u0414 \u0431\u044b\u043b\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u2014 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 <code>Composer<\/code> \u043d\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>ssh<\/code> \u2014 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432 \u043a\u043e\u043c\u043c\u0438\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0442\u0440\u0438\u0433\u0433\u0435\u0440:<\/p>\n<pre><code class=\"bash\">git commit --allow-empty -am &quot;Update dependencies [trigger:composer:update]&quot; git push -u origin master <\/code><\/pre>\n<p>  \u041e\u043f\u0446\u0438\u044f <code>--allow-empty<\/code> \u0437\u0434\u0435\u0441\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043c\u043c\u0438\u0442, \u043d\u0435 \u0432\u043d\u043e\u0441\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445. \u041a\u0430\u043a \u0431\u044b \u043f\u0443\u0441\u0442\u043e\u0439 \u043a\u043e\u043c\u043c\u0438\u0442. \u041d\u043e \u0443\u0432\u0438\u0434\u0435\u0432 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 <code>[trigger:composer:update]<\/code>, \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>composer update<\/code>, \u0438 \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u044b.<\/p>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u0432 \u0441\u0432\u043e\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/andrewdacenko\/habrahabr\">GitHub<\/a> \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0435\u0449\u0435 <code>seeds<\/code> \u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u0441\u043a\u0438\u0434\u043e\u043a.<\/p>\n<p>  \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435: \u043f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0430\u0439\u0442 \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0432 <code>Domains<\/code> \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 <code>Root Path<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e <code>public<\/code>. \u0422\u0430\u043a \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0443\u0441\u0442\u0440\u043e\u0435\u043d <code>Laravel<\/code>.<\/p>\n<p>  \u041f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0436\u043d\u043e \u0442\u0443\u0442: <a href=\"http:\/\/habr.eu1.frbit.net\/\">Habra Offers<\/a>.<\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0432\u0430\u043c \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u044d\u0442\u043e \u0447\u0438\u0442\u0430\u0442\u044c, \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c. <code>Laravel<\/code> \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0440\u0430\u0437\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435, \u0438 \u0434\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c. \u0418 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u0434\u0430\u043c \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043c\u0435\u043d\u044e \u0441\u0441\u044b\u043b\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u0442\u0435\u043a\u0430\u044e\u0442 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u043d\u0435\u0434\u0435\u043b\u0438\/\u0434\u043d\u044f.<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0443 <b>\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443<\/b> \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0441\u043a\u0440\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432.<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043e\u0446\u0435\u043d\u043e\u043a \u0434\u043b\u044f \u0441\u043a\u0438\u0434\u043a\u0438 (\u0441\u0440\u0435\u0434\u043d\u044f\u044f \u043e\u0446\u0435\u043d\u043a\u0430).<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0430\u043a\u0435\u0442 \u043f\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0443.<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <code>WYSIWYG<\/code> \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435.<\/li>\n<\/ul>\n<p>  \u041f\u043e\u0436\u0430\u043b\u0443\u0439 \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u0435 \u0442\u0430\u0441\u043a\u0438, \u043a\u0430\u043a \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0435?<\/p>\n<h6>\u041e\u0431 \u0430\u0432\u0442\u043e\u0440\u0435<\/h6>\n<p>  <\/p>\n<ul>\n<li>\u041c\u043d\u0435 24 \u0433\u043e\u0434\u0430, \u0436\u0435\u043d\u0430\u0442.<\/li>\n<li>\u041f\u0435\u0440\u0432\u043e\u0435 \u0432\u044b\u0441\u0448\u0435\u0435: \u0423\u042d\u041f \u00ab\u041a\u0420\u041e\u041a\u00bb. \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c: \u041c\u0435\u0436\u0434\u0443\u043d\u0430\u0440\u043e\u0434\u043d\u0430\u044f \u042d\u043a\u043e\u043d\u043e\u043c\u0438\u043a\u0430, \u043c\u0430\u0433\u0438\u0441\u0442\u0440.<\/li>\n<li>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0442\u0443\u0434\u0435\u043d\u0442 3 \u043a\u0443\u0440\u0441\u0430 \u041d\u0422\u0423\u0423 \u041a\u041f\u0418, \u0424\u0430\u043a\u0443\u043b\u044c\u0442\u0435\u0442 \u041f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438. \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c: \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u0430\u044f \u0418\u043d\u0436\u0435\u043d\u0435\u0440\u0438\u044f.<\/li>\n<li>\u0420\u0430\u0431\u043e\u0442\u0430\u044e \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c 15 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430 \u043f\u043e\u043b \u0441\u0442\u0430\u0432\u043a\u0438.<\/li>\n<li>\u0418\u0437\u0443\u0447\u0430\u044e <code>Laravel<\/code> \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 3.<\/li>\n<\/ul>\n<h6>\u0421\u0431\u043e\u0440 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438<\/h6>\n<p>  <\/p>\n<ul>\n<li>\u041d\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0443\u0448\u043b\u043e \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0434\u0435\u043b\u0438.<\/li>\n<li>\u0421\u0442\u0430\u0442\u044c\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 <b>3040<\/b> \u0441\u0442\u0440\u043e\u043a (\u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435).<\/li>\n<li>\u0421\u0442\u0430\u0442\u044c\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 <b>100500<\/b> \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435).<\/li>\n<\/ul>\n<p>  \u0412\u0441\u0435 \u0433\u0440\u0430\u043c\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0438\u0448\u0438\u0442\u0435, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430 \u0432 \u043b\u0438\u0447\u043a\u0443.<\/p>\n<p>  Haters gonna die (\u041f\u043e\u0441\u043f\u043e\u0440\u0438\u043b, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0448\u0443 \u044d\u0442\u043e). \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/197454\/\"> http:\/\/habrahabr.ru\/post\/197454\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0418\u0442\u0430\u043a, \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 <a href=\"http:\/\/laravel.com\/\">Laravel<\/a>. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0444\u0430\u043c\u0438\u043b\u044c\u044f\u0440\u043d\u044b \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 <code>PHP<\/code> \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438 \u2014 \u0434\u043b\u044f \u0432\u0430\u0441 \u044d\u0442\u043e \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0442\u0440\u0443\u0434\u0430, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442 \u2014 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/968\/4ff\/aee\/9684ffaeefd3b2c70d00bb5a196ed8aa.png\" alt=\"Laravel - PHP framework for artisans!\"\/><\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0430\u044f. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445.<\/p>\n<p>  \u0414\u043b\u044f \u043b\u0435\u043d\u0438\u0432\u044b\u0445: <br \/>  <a href=\"https:\/\/github.com\/andrewdacenko\/habrahabr\">GitHub<\/a><br \/>  <a href=\"http:\/\/habr.eu1.frbit.net\/\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-197454","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=197454"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197454\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=197454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=197454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=197454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}