laravel – 青春部落,流年似水 http://www.youthtribe.com 青春是一场远行,总记不起来时的路。 Thu, 28 Dec 2017 09:11:17 +0000 zh-CN hourly 1 https://wordpress.org/?v=6.1.6 laravel – 青春部落,流年似水 http://www.youthtribe.com/archives/1727 http://www.youthtribe.com/archives/1727#respond Thu, 28 Dec 2017 09:11:17 +0000 http://www.youthtribe.com/?p=1727 public function payRollList($time) { $member_phone = Session::get(phone'); $engineer = Engineer::getEngineerByPhone($member_phone); $start=date('Y-m-01',strtotime($time));//获取指定月份的第一天 $end=date('Y-m-t',strtotime($time)); //获取指定月份的最后一天 $repair=DB::table('order') ->where('repair_user',$engineer['member_id']) ->where('order_status',1) ->whereBetween('create_time',[strtotime($start),strtotime($end)]) ->where('status',0) ->orderBy('create_time', 'desc') ->paginate($this->number); return view('home.engineer.payroll_order')->with('phone', $member_phone)->with('repair', $repair); }

主要是whereBetween这句。create_time 为mysql的timestamp类型

whereBetween('create_time',[strtotime($start),strtotime($end)])

原文地址:https://www.cnblogs.com/lamp01/p/6914089.html

 

]]>
http://www.youthtribe.com/archives/1727/feed 0
laravel – 青春部落,流年似水 http://www.youthtribe.com/archives/1457 http://www.youthtribe.com/archives/1457#comments Thu, 07 May 2015 09:27:26 +0000 http://www.youthtribe.com/?p=1457

不要看这个文章了。写的根本就不对!

不要看这个文章了。写的根本就不对!

不要看这个文章了。写的根本就不对!

研究一翻,竟然成了,不过是懵懵懂懂啊。。

目的是实现前后台用户的分别登录,这样就对应两个表了。。laravel5默认是对应users表,我再建立一个admins表,用来后台登录。
直接上吧,最主要就是有两个config设置:

	
	Config::set('auth.model', 'App\Model\admin\admin');
	Config::set('auth.table', 'admins');

一个是修改登录模型,一个是对应的认证表。


1.建立中间件 make:middleware AdminAuth

然后记得在你的路由组中添加这人过滤中间件

这是用来过滤的,没有登录就跳转到登录页面。

	public function handle($request, Closure $next)
	{
		//修改一下auth的默认登录表
		//echo Auth::getFacadeApplication()->config['auth']['table'];
		Config::set('auth.model', 'App\Model\admin\admin');
		Config::set('auth.table', 'admins');
		//dd(Auth::getFacadeApplication()->config['auth']['table']);
 		if(Auth::check()){
			//已经登录	
			//dd('s');	
		}
		else{
			//还没有登录
			//dd('not login');
			return redirect()->guest('admin/login');
		}
		
		return $next($request);
	}

修改Kernel文件中 $routeMiddleware的数组,添加命名我们的中间件

		//后台管理的中间件
		'adminauth' => 'App\Http\Middleware\AdminAuth'

2.实现登录验证操作

public function loginHandle()
	{
		//下边两个设置很重要
		Config::set('auth.model', 'App\Model\admin\admin');
		Config::set('auth.table', 'admins');
		//
		$username = Input::get('username');
		$password = Input::get('password');
		$rememberme = true;
		if (Input::get('rememberme')){
			$rememberme = true;
		}
		else{
			$rememberme = false;
		}
		if(Auth::attempt([
			'username' => $username,'password' => $password
		],$rememberme))				
		{
			//登录成功
			return redirect(action('admin\AdminController@index'));
		}
		else {
			//登录失败
			return redirect(action('admin\AdminController@login'))
			->withErrors("用户名或者密码不正确");
		}
		//
	}

3.建立并修改 admin模型。因为用artisan生成的默认模型其实是没有验证功能的,所以我们生成后,直接照搬 框架自带的 users 模型,然后修改一下

protected $table = 'admins';

附我的admin 模型

<?php namespace App\Model\admin;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class Admin extends Model implements AuthenticatableContract, CanResetPasswordContract {

	//
	use Authenticatable, CanResetPassword;
	
	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'admins';
	
	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected $fillable = ['name', 'email', 'password'];
	
	/**
	 * The attributes excluded from the model's JSON form.
	 *
	 * @var array
	 */
	protected $hidden = ['password', 'remember_token'];
	
}

就好了。。

好像就是这样吧,你们试试,有问题留言。我这是ok了的。

]]>
http://www.youthtribe.com/archives/1457/feed 7
laravel – 青春部落,流年似水 http://www.youthtribe.com/archives/1431 http://www.youthtribe.com/archives/1431#comments Wed, 11 Feb 2015 09:28:44 +0000 http://www.youthtribe.com/?p=1431 先是laravel官方网站:http://laravel.com/docs/5.0
laravel 最近更新了5.0版本。从今天起开始自学这个传说中的优雅php框架。

今天仔细用了下php依赖库管理利器 comPoser 进行了 laravel5.0的安装,对,是在windows下进行的。。我表示有了点头绪。
开始吧。
我的环境,win7 ,wamp 2.2,建了一个虚拟主机,绑定域名www.l.com,到 F:\wamp\www\laravel 这个文件夹。
1.安装composer
Composer-Setup

其中一步主要就是选对php.exe的执行文件就好。
安装完就会自动把 composer 加入到系统变量中了。
composer会安装到以下路径:

C:\Users\Administrator\AppData\Roaming\Composer

2.打开cmd命令行,输入命令

composer global require "laravel/installer=~1.1"

具体作用不详,但是会在compser文件夹下多出vendor文件夹
这其中就包含了laravel bin程序(就是可以执行cmd 命令,在bin文件夹下)
3.接下来是自动创建laravel项目工程文件了。
有两种方法,一种是什么

laravel new blog

,这个我没搞明白。。。
所以我用的是第二种

composer create-project laravel/laravel --prefer-dist

上边是官方默认的的方法,结果把laravel安装到c盘的一个文件夹下了,然后看了下命令帮助,改用下边的方法(在最后指定一下路径就好)

composer create-project laravel/laravel --prefer-dist F:\wamp\www\laravel

然后等上一些时间,较慢
laravel-ok

这样应该就可以了,然后访问一下绑定的域名,显示成功(不过页面感觉有点怪,主要是css,颜色,也可能是什么gg字体之类的吧)

laravel-ok2

再上一张结构图吧

laravel-files

您也可以下载,我安装好的laravel包,7Z压缩,竟然不到3M..
算了,程序上传最大2M,不上传了吧

]]>
http://www.youthtribe.com/archives/1431/feed 4