laravel-4

Heroku doesn't recognize my Laravel app as PHP app, and does not do composer install

本小妞迷上赌 提交于 2020-01-01 05:16:10
问题 I'm trying to publish my Laravel app on Heroku. I have excluded the composer.lock file from .gitignore, and created a Procfile containing web: vendor/bin/heroku-php-apache2 public I created my app with heroku create myapp; git push heroku master; Then I get the following output: git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags heroku master:master Pushing to https://git.heroku.com/myapp.git POST git-receive-pack (1914 bytes) remote:

Creating Image link with HTML Helper

孤人 提交于 2020-01-01 05:10:30
问题 I'm trying to create an image link with the HTML helper of Laravel 4. But it seems that isn't really working. I have this line of code {{ HTML::link("#", HTML::image("img/logo.png", "Logo") ) }} But that just outputs a strin like this: <img src="http://localhost/worker/public/img/logo" alt="Logo"> How come.?? 回答1: You probably will have to: <a href="#">{{ HTML::image("img/logo.png", "Logo") }}</a> Because, link() uses entities to escape the title: public function link($url, $title = null,

Laravel 4.1: Eloquent Offset & Limit

天涯浪子 提交于 2020-01-01 04:32:06
问题 How to limit returned data from Eloquent? I tried with this: $data = Product::all()->take(4)->skip(3); And it return the error message: Call to undefined method Illuminate\Database\Eloquent\Collection::skip() It seems like eloquent don't support skip() ? So, how can I offset & limit the data from eloquent? Thank you. 回答1: You may try this (get 4 items from offset 3/4th): Product::take(4)->offset(3)->get(); Or this (get 5 items from 3rd row): Product::take(5)->skip(2)->get(); 回答2: laravel have

Mcrypt PHP extension required on Mac OS X

半世苍凉 提交于 2020-01-01 04:05:22
问题 I keep getting this error Mcrypt PHP extension required at the bottom after I run a composer update : Since I am using Mac, I have tried running : brew search mcrypt brew install php56-mcrypt I still get the same error message. 回答1: Steps I solved this by running the following commands brew update brew upgrade brew tap homebrew/dupes brew tap josegonzalez/homebrew-php brew install php54-mcrypt php --version // To Test your php sudo composer update Result No more Mcrypt warning !! Loading

get file name without extension in laravel?

醉酒当歌 提交于 2020-01-01 03:52:06
问题 I have used Input::file('upfile')->getClientOriginalName() to retrieve name of uploaded file but gives name with extension like qwe.jpg .How do I get name without extension like qwe in laravel. 回答1: Laravel uses Symfony UploadedFile component that will be returned by Input::file() method. It hasn't got any method to retrive file name, so you can use php native function pathinfo() : pathinfo(Input::file('upfile')->getClientOriginalName(), PATHINFO_FILENAME); 回答2: You could try this $file =

Query for retrieving data records for a specific date range in Laravel 4

好久不见. 提交于 2020-01-01 03:44:28
问题 I have a table having record_date and corresponding amount field.I was trying to retrieve total amount grouping by the months of the date . I am new to laravel and in normal php i would have used the following mysql query --> SELECT MONTH(record_date),YEAR(record_date),SUM(amount) FROM table_name WHERE record_date > DATE_SUB(now(), INTERVAL 6 MONTH) GROUP BY YEAR(record_date), MONTH(record_date); This simply returns the total amount collected for last 6 months each grouped by the month and

mysql join ON and AND to laravel eloquent

北城以北 提交于 2020-01-01 02:43:48
问题 I've been able to get the query result I need using the following raw sql: select `person`.`id`, `full_name`, count(actions.user_id) as total from `persons` left join `actions` on `actions`.`person_id` = `persons`.`id` and `actions`.`user_id` = $user where `type` = 'mp' group by `persons`.`id` But I haven't been able to get it working in eloquent yet. Based on some similar answers, I'd tried functions within ->where() or leftJoin() , but the count of each person's actions isn't yet being

DB->count() returning different value from count(DB->get())

冷暖自知 提交于 2020-01-01 02:41:09
问题 I have the simplest of queries that I'm trying to run DB::table('user_visits')->groupBy('user_id')->count(); But it's returning the wrong number, 8. If I change it to this: count(DB::table('user_visits')->groupBy('user_id')->get()); Then it returns the correct number, 34. Why are these not the same value? Here's my table structure user_visits( user_id, date_visited, num_clicks ) 回答1: A note on debugging The queries generated by those two different approaches are completely different, and is

Laravel: array_merge(): Argument #2 is not an array error

依然范特西╮ 提交于 2020-01-01 01:16:14
问题 Exceptions started to appear in all views, and when I try to run composer update , it always ends up with {"error":{"type":"ErrorException","message":"array_merge(): Argument #2 is not an array","file":"\/laravel\/framework\/src\/Illuminate\/Foundation\/ProviderRepository.php","line":188}} 回答1: After a lot of searching and exploring each file in the 'app' folder, it appears that one file was corrupt Delete app/storage/meta/ services.json and re-run composer update and this should solve it.

Laravel User permission to access certain pages?

梦想的初衷 提交于 2020-01-01 00:45:08
问题 I have created a slug pages as followed : // Create pages table for dynamic pages id | slug | title | page_template 0 about about us about.blade 1 contact contact us contact.blade I am going to access them through the following rout: // could be page/{slug} or only slug inside routes.php Route::get('/{slug}', array('as' => 'page.show', 'uses' => 'PageController@show')); Where I have a PageController , so this allows me to create pages dynamically. referring to the solution here : Laravel