laravel-4

Duplicate entry '' for key 'users_email_unique' empty field

梦想与她 提交于 2019-12-14 04:19:37
问题 I have two types of users - real and fake. Fake users are employees, that don't use the system. Real users use their email address to login. So my users migration has $table->string('email')->unique(); . The problem is that fake users may not have an email address. I can add first fake user no problem, but the second one generates error SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'users_email_unique' . What should I do? 回答1: Sounds like users_email_unique

Call to a member function fill() on a non-object

白昼怎懂夜的黑 提交于 2019-12-14 04:18:46
问题 Trying to add information to an empty profile and redirect back. $user = User::whereUsername($username)->firstOrFail(); // Selects correct user $input = Input::all(); // a dd($input) at this point confirms input present $this->profileForm->validate($input); // Passes $user->profile->fill($input)->save(); return Redirect::route('profile.edit', $user->username); If $user->profile is null then this gives the error: Call to a member function fill() on a non-object . I tried to remedy this with:

Laravel requires the Mcrypt PHP extension. Not working for cron jobs

会有一股神秘感。 提交于 2019-12-14 04:07:32
问题 So I am plagued with this issue like many others have been but with no solution. The Issue : commands issued by a cron task do not run and give the message: Laravel requires the Mcrypt PHP extension. I can run commands through artisan and they work fine. I am using MAMP on OSX 10.8. I've quadrupal checked my .bash_profile to ensure the correct PATH is set which is: export PATH=/Applications/MAMP/bin/php/php5.4.4/bin:$PATH . Confirmed by which php in terminal. php -v confirms PHP 5.4.4 is

Laravel - Eloquent: Polymorphic relations with namespace

ε祈祈猫儿з 提交于 2019-12-14 03:59:54
问题 My situation is: a Calendar belongs to a Customer or Salesman Because I also have classes like Event and File, I used the namespace App\Models for all my model classes. so I set up the polymorphic relation: in Calender.php public function user() { return $this->morphTo(); } in Customer.php and Salesman.php public function calendars() { return $this->morphMany('App\Models\Calendar', 'user'); } Now when i do $calendar= Calendar::find(1); //calendar from a salesman $calendar->user; //error here

how to use paginator::make() in laravel to show resultset in view?

耗尽温柔 提交于 2019-12-14 03:45:59
问题 I have used Paginator::make to paginate the records in the table. In the view, I am getting the pagination links, but every link has all the records in it. How to restrict it to perPage items? $datas = Paginator::make($paginator, count($paginator), $perPage); return $datas; The code outputs: {"total":10,"per_page":5,"current_page":1,"last_page":2,"from":1,"to":5,"data": [{"id":"10","languages":"ds","created_at":"2014-05-23 11:59:02.000","created_by":"1","updated_at":"2014-05-23 11:59:02.000",

Array to string conversion - Project Crash [Laravel]

烂漫一生 提交于 2019-12-14 03:35:45
问题 I am getting an error like this: Array to string conversion Inside /var/.../vendor/cartalyst/sentry/src/Cartalyst/Sentry/SentryServiceProvider.php Code snippet where the error was thrown: throw new \InvalidArgumentException("Invalid hasher [$hasher] chosen for Sentry."); I was doing ordianry work in one of my controllers and this error occured when I clicked on one of the buttons inside my blade. I have commented the code out but the error still is being displayed, not only on this one page

Displaying feeds and blogs according to the created time

大憨熊 提交于 2019-12-14 03:20:55
问题 I'm having a home page where all the feeds along with comments and blogs are being displayed. Right now it is showing first all the feeds and then the blog. But I want it should be displayed according to the created time, mixer of feeds and blog not like first feed will come and then the blog. Can anyone tell me how to acheive that. This is my index.blade.php @extends('layouts/default') {{-- Page title --}} @section('title') Home @parent @stop {{-- page level styles --}} @section('header

laravel how to specifiy the input columns

余生长醉 提交于 2019-12-14 03:12:06
问题 I have a form in html that has an input with name restaurantName , but my column in the database is name . I am not able to use this in the controller Restaurant::create(Input::only('restaurantName')); Because there is no column with restaurantName so my question is how to tell laravel that restaurantName is maped to name ? many thanks Edit the html form has these fields: restaurantName website username password mobileNumber firstName lastName The database has two tables which are Admin and

How to call a PHP variable from JavaScript in laravel?

☆樱花仙子☆ 提交于 2019-12-14 03:10:38
问题 I'm trying to pass the longitude and latitude of a service to script that generates a google maps. This is my code: Blade <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false"> </script> <script> function initialize() { var mapOptions = { scaleControl: true, center: new google.maps.LatLng({{$servicio->Longitud}}}, {{$servicio->Latitud}}}, zoom:18 }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var

Polymorphic many-to-many relation

折月煮酒 提交于 2019-12-14 02:58:22
问题 I couldn't get related models in many-to-many polymorphic relation saved into database. $photo = Photo::find(1); $photo->articles()->attach(2); something like this wouldn't work and gives error: Call to undefined method Illuminate\Database\Query\Builder::articles()' How to do it the right way? Models class Tag extends Eloquent { public function articles() { return $this->morphedByMany('Article', 'taggable'); } public function photos() { return $this->morphedByMany('Photo', 'taggable'); } }