Commit 62bc088e authored by gxx's avatar gxx

修改模糊查询分页bug

parent bb2bfb71
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\SMS;
use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class SMSController extends Controller class SMSController extends Controller
{ {
...@@ -10,6 +13,17 @@ class SMSController extends Controller ...@@ -10,6 +13,17 @@ class SMSController extends Controller
public function surplus() public function surplus()
{ {
$sid = SMS::max('id');
$sms = SMS::find($sid);
if($sms->created_at->isToday()){
}else{
echo "插入记录";
}
dd("aa");
$account = env('FEIGE_ACCOUNT'); $account = env('FEIGE_ACCOUNT');
$pwd = env('FEIGE_PWD'); $pwd = env('FEIGE_PWD');
......
...@@ -100,13 +100,14 @@ class UserController extends Controller ...@@ -100,13 +100,14 @@ class UserController extends Controller
public function simpleSearch(Request $request) public function simpleSearch(Request $request)
{ {
$search_content = $request->search;
if ($request->search == null){
return Message::makeError('没有参数');
}
$search_content = $request->search;
$page = 1; $page = 1;
$result = $this->mUser->simpleSearch($search_content,$page); $result = $this->mUser->simpleSearch($search_content,$page);
return view('admin/usertables',['result'=>$result,'params'=>$search_content]);
return view('admin/usertables',compact('result'));
} }
} }
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SMS extends Model
{
protected $table = 'sms';
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
...@@ -13,7 +14,7 @@ class AppServiceProvider extends ServiceProvider ...@@ -13,7 +14,7 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
// Schema::defaultStringLength(191);
} }
/** /**
......
...@@ -20,21 +20,14 @@ class UserService implements UserServiceContract ...@@ -20,21 +20,14 @@ class UserService implements UserServiceContract
public function simpleSearch($search_content,$page) public function simpleSearch($search_content,$page)
{ {
$user_name = User::where('user_name','like','%'.$search_content.'%')->paginate($page); $users = User::where('user_name','like','%'.$search_content.'%')
$phone = User::where('phone','like','%'.$search_content.'%')->paginate($page); ->orWhere('phone','like','%'.$search_content.'%')
$email = User::where('email','like','%'.$search_content.'%')->paginate($page); ->orWhere('email','like','%'.$search_content.'%')
// ->get();
->paginate($page);
if (count($user_name) > 0){
return $user_name; return $users;
}
if (count($phone) > 0){
return $phone;
}
if (count($email) > 0){
return $email;
}
$result = null;
return $result;
} }
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}
...@@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema; ...@@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration class CreateSMSTable extends Migration
{ {
/** /**
* Run the migrations. * Run the migrations.
...@@ -13,12 +13,9 @@ class CreateUsersTable extends Migration ...@@ -13,12 +13,9 @@ class CreateUsersTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::create('users', function (Blueprint $table) { Schema::create('sms', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('name'); $table->unsignedInteger('sms_surplus');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps(); $table->timestamps();
}); });
} }
...@@ -30,6 +27,6 @@ class CreateUsersTable extends Migration ...@@ -30,6 +27,6 @@ class CreateUsersTable extends Migration
*/ */
public function down() public function down()
{ {
Schema::dropIfExists('users'); Schema::dropIfExists('s_m_s');
} }
} }
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
@endforeach @endforeach
</table> </table>
{{ $result->links() }} {{ $result->appends(['search' => $params])->links() }}
</div> </div>
<!-- /.box-body --> <!-- /.box-body -->
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment