laravel-4

nginx configuration for Laravel 4

半世苍凉 提交于 2019-12-17 10:23:37
问题 I am trying to setup my Laravel 4 project using nginx . Here is my nginx server block for laravel : server { listen 80; root /home/prism/www/laravel/public; index index.php index.html index.htm; server_name example.com; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } But my problem

Eloquent push() and save() difference

眉间皱痕 提交于 2019-12-17 10:15:54
问题 I have read laravel 4 docs about eloquent and was quite intrigued by the push() part. It says, Sometimes you may wish to save not only a model, but also all of its relationships. To do so, you may use the push method: Saving A Model And Relationships $user->push(); See link here Sorry but it's a bit blurry on my part the difference between save() and push(). I am hoping someone can clear this one out for me. Thank you. 回答1: Heres the magic behind the scenes... /** * Save the model and all of

Laravel quick start guide route not working

瘦欲@ 提交于 2019-12-17 08:47:55
问题 Ok I'm new to Laravel so went straight to the documentation to get started. There are massive holes in the documentation so it took a lot of effort and googling to fill the gaps in order to get Laravel set-up. I now have it set up and moved on to the next step in the quick start guide.I created my route Route::get('users', function() { return 'Users!'; }); Now it says: Now, if you hit the /users route in your web browser, you should see Users! So I hit up: http://localhost/laravel/users but

How to Get the Current URL Inside @if Statement (Blade) in Laravel 4?

可紊 提交于 2019-12-17 08:04:50
问题 I am using Laravel 4. I would like to access the current URL inside an @if condition in a view using the Laravel's Blade templating engine but I don't know how to do it. I know that it can be done using something like <?php echo URL::current(); ?> but It's not possible inside an @if blade statement. Any suggestions? 回答1: You can use: Request::url() to obtain the current URL, here is an example: @if(Request::url() === 'your url here') // code @endif Laravel offers a method to find out, whether

How to Get the Current URL Inside @if Statement (Blade) in Laravel 4?

天大地大妈咪最大 提交于 2019-12-17 08:04:13
问题 I am using Laravel 4. I would like to access the current URL inside an @if condition in a view using the Laravel's Blade templating engine but I don't know how to do it. I know that it can be done using something like <?php echo URL::current(); ?> but It's not possible inside an @if blade statement. Any suggestions? 回答1: You can use: Request::url() to obtain the current URL, here is an example: @if(Request::url() === 'your url here') // code @endif Laravel offers a method to find out, whether

How to create a subquery using Laravel Eloquent?

偶尔善良 提交于 2019-12-17 07:31:29
问题 I have the following Eloquent query (This is a simplified version of a query which consists of of more where s and orWhere s hence the apparent roundabout way of going about this - the theory is what's important): $start_date = //some date; $prices = BenchmarkPrice::select('price_date', 'price') ->orderBy('price_date', 'ASC') ->where('ticker', $this->ticker) ->where(function($q) use ($start_date) { // some wheres... $q->orWhere(function($q2) use ($start_date){ $dateToCompare = BenchmarkPrice:

How to create a subquery using Laravel Eloquent?

落花浮王杯 提交于 2019-12-17 07:31:01
问题 I have the following Eloquent query (This is a simplified version of a query which consists of of more where s and orWhere s hence the apparent roundabout way of going about this - the theory is what's important): $start_date = //some date; $prices = BenchmarkPrice::select('price_date', 'price') ->orderBy('price_date', 'ASC') ->where('ticker', $this->ticker) ->where(function($q) use ($start_date) { // some wheres... $q->orWhere(function($q2) use ($start_date){ $dateToCompare = BenchmarkPrice:

Laravel - Forbidden You don't have permission to access / on this server

≯℡__Kan透↙ 提交于 2019-12-17 07:17:27
问题 My laravel installation was working fine yesterday but today I get the following error: Forbidden You don't have permission to access / on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request. Does anyone know where I am going wrong? 回答1: Create and put this .htaccess file in your laravel installation folder. <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L] <

Laravel mail: pass string instead of view

跟風遠走 提交于 2019-12-17 07:14:47
问题 I want to send a confirmation e-mail using laravel. The laravel Mail::send() function only seems to accept a path to a file on the system. The problem is that my mailtemplates are stored in the database and not in a file on the system. How can I pass plain content to the email? Example: $content = "Hi,welcome user!"; Mail::send($content,$data,function(){}); 回答1: update: In Laravel 5 you can use raw instead: Mail::raw('Hi, welcome user!', function ($message) { $message->to(..) ->subject(..); }

Where can I set headers in laravel

寵の児 提交于 2019-12-17 07:11:29
问题 I want to set headers as array('Cache-Control'=>'no-cache, no-store, max-age=0, must-revalidate','Pragma'=>'no-cache','Expires'=>'Fri, 01 Jan 1990 00:00:00 GMT'); for all my views, currently I'm doing this in all controllers while returning views, like $headers=array('Cache-Control'=>'no-cache, no-store, max-age=0, must-revalidate','Pragma'=>'no-cache','Expires'=>'Fri, 01 Jan 1990 00:00:00 GMT'); Redirect::to('/',301,$headers);` So instead of writing this for each and every route can it be