laravel-4

Using the Remember me feature with Sentry in Laravel 4

蓝咒 提交于 2019-12-08 06:09:08
问题 I'm trying to get a login form to 'remember' the user logging in and I just can't work out how to do it. Here's my controller public function getLogin() { // Return the view with the data return View::make('users.login'); } public function postLogin() { // Gather Sanitized Input $input = array( 'email' => Binput::get('email'), 'password' => Binput::get('password'), 'rememberMe' => Binput::get('rememberMe') ); // Set Validation Rules $rules = array ( 'email' => 'required|min:4|max:64|email',

Laravel 4: custom login and check password

家住魔仙堡 提交于 2019-12-08 06:07:17
问题 I would like to customize my login in laravel 4 where username is either his username or email so what I did is: public static function custom_login($uname,$pwd) { $res = DB::select("select * from users where (username = ? or email = ?) and password = ? and active = 1",array($uname,$uname,$pwd)); return $res; } Now, we all know that password are hashed so you cant use password = ? . how can I check the password if it's correct? 回答1: You can use $password = Hash::make($password); function to

Laravel - Change Database Connection for a specific URL?

隐身守侯 提交于 2019-12-08 05:48:28
I am fairly new to using laravel framework. I have the following requirement. I have a domain - example.com, and its entire code stack is running in laravel. Lets say in the config default database connection is - 'db1' Now, if the url becomes - example.com/country - I want the default database connection to become - 'db2' And also I want the base URL to be changed to example.com/country, since all the modules are going to be the same. Only the database connection is going to change here. Could someone help me out here? I would do it the following way: Put the list of allowed countries into

laravel insert a new row that has a key from another table and a null columns

爱⌒轻易说出口 提交于 2019-12-08 05:36:13
问题 This is my restaurant table: the restaurant table has a adminID field . and this is the admin table: I have a form that has the values of both the restaurant and the admin, This is Admin model: class Admin extends Eloquent implements UserInterface, RemindableInterface { use UserTrait, RemindableTrait; public function restaurant(){ return $this->belongsTo('Restaurant', 'ID'); } This is Restaurant model: class Restaurant extends Eloquent implements UserInterface, RemindableInterface { use

Export database (only data) with Laravel 4

ⅰ亾dé卋堺 提交于 2019-12-08 04:55:25
问题 I'm trying to find a package or method which allow me to export all the data from my database (SQL) in order to backup the database. The goal is to have a button to save the database in a SQL file and download it, so i need a method in a controller to export the data. I found nothing on http://packalyst.com/packages Is somebody knows a way to do that ? Thanks 回答1: You can use this package - which is an excellent backup manager: https://github.com/heybigname/backup-manager If you want it to be

Laravel & Couchdb-ODM - The annotation “@Doctrine\ODM\CouchDB\Mapping\Annotations\Document” does not exist, or could not be auto-loaded

雨燕双飞 提交于 2019-12-08 04:48:24
问题 I want to use couchdb-odm in Laravel 4.2 but I keep on getting errors. The last one is: [Semantical Error] The annotation "@Doctrine\ODM\CouchDB\Mapping\Annotations\Document" in class IO\Documents\Article does not exist, or could not be auto-loaded. I copied mostly the sandbox/bootstrap.php and tried a couple of recommendations from previous answers in the same problem. Here is currently what I have: My composer.json has: "require": { "laravel/framework": "4.2.*", "symfony/console": ">=2.0",

Rachet chat application - connection closed immediately after established when the app runs for a period of time

偶尔善良 提交于 2019-12-08 04:12:54
问题 We're using Laravel 4 together with Ratchet to create a chat application. Everything runs normally for about 14-20 hours. After a period of time the chat app stops to run. The connection gets established from the client to the server but right after that the server closes the connection. No errors get reported in our log files and the fact that we haven't been able to replicate the problem in our development environment doesn't help. Restarting the chat application on the server fixes the

Laravel 4 Auth works but does not stay logged in

随声附和 提交于 2019-12-08 04:07:44
问题 In my Laravel 4 App I use the Auth functionality. I submit my login form to: $data = array( 'email' => Input::get('email'), 'password' => Input::get('password') ); if (Auth::attempt($data)) { echo 'SUCCESS!'; } This outputs SUCCESS, hence everything works. But if I next call another method the user is not logged in: if (Auth::check()) { echo "logged in"; } else { echo "not logged in"; } This outputs 'not logged in'. I tried to add true to attempt to remember login but it does not make a

Laravel 4 - Sending the input back on a failed submission

心不动则不痛 提交于 2019-12-08 03:56:07
问题 I have this form @extends('index') @section('main') <h1>Create a new poll</h1> {{ Form::model(new Poll, ['route' => 'polls.store', 'class' => 'create-poll']) }} <div class="gray-box"> {{ Form::label("topic", "Write your poll question") }} {{ Form::text('topic', '', ['placeholder' => 'Example: What is the best number?', 'id' => 'topic']) }} </div> <div class="gray-box"> {{ Form::label(null, "Write the possible answers") }} {{ Form::text('option[]', null, ['class' => 'option', 'placeholder' =>

Laravel - Convert database integer to an associated string

老子叫甜甜 提交于 2019-12-08 03:47:42
问题 I have my users table with a column named status . In this column I just store a number, based off their status, 1 - admin, 2 - owner, etc. I know that I can display these values with {{ users->status }} , but only shows the stored number. How can I show the actual name instead of the stored number? 回答1: Use Eloquent Accessors & Mutators. Define an array of statuses and use the status number from your database as a key to change the value in the model so that in the view {{ $users->status }}