laravel-4

PHP Artisan Custom Command

限于喜欢 提交于 2020-01-16 04:12:27
问题 I need a custom command in my php artisan. I have created the command file via artisan shell. But when I execute it via php artisan it throws it as undefined. It is also confusing for me how to add arguments to my command. Here is my whole command file: <?php use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class createLibrarySet extends Command { /** * The console command name. * * @var string */ protected

PHP Artisan Custom Command

本秂侑毒 提交于 2020-01-16 04:12:14
问题 I need a custom command in my php artisan. I have created the command file via artisan shell. But when I execute it via php artisan it throws it as undefined. It is also confusing for me how to add arguments to my command. Here is my whole command file: <?php use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class createLibrarySet extends Command { /** * The console command name. * * @var string */ protected

Set and Check Cookie in the one response - Laravel

主宰稳场 提交于 2020-01-16 03:26:23
问题 I am attempting to set a cookie and then check to see if the cookie has been set. So in one function, I have it make the cookies: public function makeCookies(){ Cookie::queue('logged_in', $value, 15); Cookie::queue('user_id', 2); //return Response::make()->withCookie(Cookie::make('logged_in', $value, 15))->withCookie(Cookie::forever('user_id', 2)); } And in the other function, I try to check to see if the cookie has been set: public function checkCookies(){ $this->makeCookies(); if(Cookie:

Define Laravel Eloquent relations between 3 models in a messaging system

我只是一个虾纸丫 提交于 2020-01-16 00:47:31
问题 I'm trying to create multi-participant messaging system. Here's the database design I'v found here: Messaging system database schema Conversation ------------ id Messages -------- id conversation_id from_id subject message from_timestamp Participants ------------ conversation_id user_id last_read_timestamp Could you help me to describe Eloquent relations between these models? I mean this: http://laravel.com/docs/eloquent#relationships 回答1: class Conversation extends Eloquent { public function

Sentry2 user model extension

女生的网名这么多〃 提交于 2020-01-15 23:08:22
问题 I'm using Sentry2 package in my laravel 4 application (http://docs.cartalyst.com/sentry-2/). I create a new User model that extends Sentry2 User Model: <?php namespace App\Models; use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; class User extends \Cartalyst\Sentry\Users\Eloquent\User implements UserInterface, RemindableInterface { /** * The database table used by the model. * * @var string */ protected $table = 'users'; /** * The attributes excluded from

Sentry2 user model extension

我只是一个虾纸丫 提交于 2020-01-15 23:08:15
问题 I'm using Sentry2 package in my laravel 4 application (http://docs.cartalyst.com/sentry-2/). I create a new User model that extends Sentry2 User Model: <?php namespace App\Models; use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; class User extends \Cartalyst\Sentry\Users\Eloquent\User implements UserInterface, RemindableInterface { /** * The database table used by the model. * * @var string */ protected $table = 'users'; /** * The attributes excluded from

Calling controllers dynamically

怎甘沉沦 提交于 2020-01-15 12:30:08
问题 I'm attempting to create dynamic routing in Laravel for my controllers - I know this can be done in Kohana, but I've been unsuccessful trying to get it working with Laravel. This is what I have right now: Route::get('/{controller}/{action?}/{id?}'... So I would like to call controller/method($id) with that. Ideally this is what I would like to do: Route::get('/{controller}/{action?}/{id?}', $controller . '@' . $action); And have it dynamically call $controller::$action. I've tried doing this:

Laravel: URL::route() print only the route link without the website name

女生的网名这么多〃 提交于 2020-01-15 11:25:13
问题 I have this route Route::get('/dashboard', array( 'as' => 'dashboard-get', 'uses' => 'AppController@getDashboard' )); In the View if i write <a href="{{ URL::route('dashboard-get') }}">Dashboard</a> It will return me the entire link. http://192.168.0.1/dashboard How can get the route by name in the VIEW and only print the /dashboard Without the http://192.168.0.1/ part of the link 回答1: From the code source, route method generate an absolute URL by default, you may set it to false: <a href="{{

why .env file configuration in laravel is not working

旧城冷巷雨未停 提交于 2020-01-15 08:26:50
问题 DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE= DB_USERNAME=root DB_PASSWORD= this is my configuration for laravel 5.4 but php artisan migrate is not working and have error and the migrate error Users-MacBook-Pro: ATP Developers php artisan migrate In Connection.php line 664: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table schema = atp_db and table_name = migrations) In Connector.php

why .env file configuration in laravel is not working

早过忘川 提交于 2020-01-15 08:26:28
问题 DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE= DB_USERNAME=root DB_PASSWORD= this is my configuration for laravel 5.4 but php artisan migrate is not working and have error and the migrate error Users-MacBook-Pro: ATP Developers php artisan migrate In Connection.php line 664: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table schema = atp_db and table_name = migrations) In Connector.php