本文整理汇总了PHP中App\Http\Controllers\DB类的典型用法代码示例。如果您正苦于以下问题:PHP DB类的具体用法?PHP DB怎么用?PHP DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: record
public function record()
{
if (\Request::hasFile('image') && \Request::file('image')->isValid() && \Auth::user()->suspend == false) {
$file = \Request::file('image');
$input = \Request::all();
$date = new \DateTime();
if (isset($input['anon'])) {
$name = 'anon';
} else {
$name = \Auth::user()->name;
}
$validator = \Validator::make(array('image' => $file, 'category' => $input['category'], 'title' => $input['title'], 'caption' => $input['caption']), array('image' => 'required|max:1200|mimes:jpeg,jpg,gif', 'category' => 'required', 'title' => 'required|max:120', 'caption' => 'required|max:360'));
if ($validator->fails()) {
return redirect('/publish')->withErrors($validator);
} else {
$unique = str_random(10);
$fileName = $unique;
$destinationPath = 'database/pictures/stream_' . $input['category'] . '/';
\Request::file('image')->move($destinationPath, $fileName);
\DB::insert('insert into public.moderation (p_cat, p_ouser, p_title, p_caption, p_imgurl, p_status, p_reported, p_rating, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [$input['category'], $name, $input['title'], $input['caption'], $unique, 'available', 0, 0, $date, $date]);
$messages = 'Your content has been succesfully submitted. Going on moderation process.';
return redirect('/system/notification')->with('messages', $messages);
}
} else {
$messages = 'Your content data is invalid. The process is aborted.';
return redirect('/system/notification')->with('messages', $messages);
}
}
开发者ID:chandrairawan,项目名称:nosproject,代码行数:28,代码来源:PublicationController.php
示例2: getSensor
public function getSensor()
{
$id = $_SERVER['REMOTE_ADDR'];
if (\DB::select('select 1 from module_vanguard where id = ?', [$id])) {
if (\DB::select('select 1 from app_status where validity = true and sensor_register = true')) {
$results = \DB::select('select * from module_vanguard where id = ?', [$id]);
foreach ($results as $result) {
$alias = $result->alias;
$status = $result->status;
}
$timestamp = new \DateTime();
if ($status == 'active') {
$must_report = true;
}
if ($status == 'passive') {
$must_report = false;
}
$is_reported = false;
\DB::insert('insert into vanguard_log values (?, ?, ?, ?, ?)', [$id, $alias, $must_report, $is_reported, $timestamp]);
//open to adjustment.
exec("nodejs /var/www/topsus/nodejs/telegram_check.js");
return 'OK';
} else {
return 'NOT OK - APPLICATION IS NOT LISTENING';
}
} else {
return 'NOT OK - SENSOR IS INVALID';
}
}
开发者ID:taufiky1994,项目名称:BotAutomation,代码行数:29,代码来源:SensorController.php
示例3: test
public function test()
{
//return view('test');
$results = \DB::table('v_tickets')->where('user_id', 11)->get();
return ['ok' => true, 'code' => 200, 'data' => $results, 'error' => ['message' => 'no errors', 'code' => null]];
//App\VTicket::all();
}
开发者ID:extjac,项目名称:qops01,代码行数:7,代码来源:HomeController.php
示例4: index
public function index(Request $request)
{
/*
* session()->keep here is used to retain the lesson id even if the user refreshes the page
* this keeps the lesson id hidden to the user and inaccessible by anyone else
* the lesson id is not retained when navigating away from the page so the page will be inaccessible once done
*/
$lessonId = session('lessonId');
// If lesson id does not exist in the session, do not allow access to the page
if (!isset($lessonId)) {
return redirect('lessons');
}
$user = auth()->user();
$words = Word::orderBy(\DB::raw('RAND()'))->take(80)->get();
$questions = LessonWord::with('word')->where('lesson_id', $lessonId)->get();
session()->flash('maxQuestions', count($questions));
if (empty(session('questionIndex'))) {
session()->flash('questionIndex', 0);
// Start with index zero
} else {
session()->keep('questionIndex');
}
$generatedOptions = $this->generateOptions($questions, $words);
// Pass this to view
if ($generatedOptions == null) {
return redirect('lessons');
// Return users to lesson page if they try to go back to the finished exam
}
return view('lessons.exam', ['user' => $user, 'questions' => $questions, 'options' => $generatedOptions]);
}
开发者ID:jsnulla,项目名称:fels_rush,代码行数:30,代码来源:LessonWordController.php
示例5: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$status = Input::get('status');
if ($status == 'comment') {
$comment_new = User_App_Comment::join('apps', 'apps.id', '=', 'user__app__comments.a_id')->join('users', 'users.id', '=', 'user__app__comments.u_id')->select('user__app__comments.id', 'users.name as user_name', 'users.id as user_id', 'apps.name as app_name', 'apps.id as app_id', 'apps.img_url as app_img', 'comment', 'user__app__comments.created_at')->orderBy('user__app__comments.created_at', 'desc')->take(5)->get();
return $comment_new;
}
//multisearch
$app_list = App::leftjoin('user__app__favorite', 'user__app__favorite.a_id', '=', 'apps.id')->select('apps.id', 'apps.name', 'apps.img_url', 'apps.rating_users', 'apps.genre', 'apps.rating', \DB::raw('count(user__app__favorite.id) as favorite_count'))->groupBy('apps.id')->orderBy('apps.rating_users', 'desc')->orderBy('id', 'asc');
if (Input::has('name')) {
$name = Input::get('name');
$app_list->where('apps.name', 'LIKE', '%' . $name . '%');
}
if (Input::has('genre')) {
$genre = Input::get('genre');
$app_list->where('apps.genre', '=', $genre);
}
if (Input::has('skip')) {
$skip = Input::get('skip');
$app_list->skip($skip);
}
$apps = $app_list->take(10)->get();
if (empty($apps->first())) {
return Response::json(array('message' => 'Empty Query Man~', 'status' => 'error'));
} else {
foreach ($apps as $key => $value) {
$app_comment_counts = App::join('user__app__comments', 'user__app__comments.a_id', '=', 'apps.id')->where('apps.id', '=', $value['id'])->count();
//$value->suck_count = $app_suck_counts;
$value->app_comment = $app_comment_counts;
}
return $apps;
}
}
开发者ID:exile1205,项目名称:AppRecoBackend,代码行数:38,代码来源:AppController.php
示例6: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
try {
DB::table('dictionary')->where('id', $id)->update(array('word' => \Input::get('word')));
} catch (Exception $e) {
}
}
开发者ID:pumba3211,项目名称:PHP,代码行数:14,代码来源:DictionaryController.php
示例7: anyData
public function anyData(Request $req)
{
// $data = Jenissppd::all();
// $count = App\Flight::where('active', 1)->count();
$data = \DB::table('jenis_sppd');
if ($req->get('filter_skdp_id')) {
$result = $data->where('nama_jenis_sppd', '=', $req->get('filter_skdp_id'))->get();
// $['rows']=$result;
return $result;
}
if ($req->get('page')) {
// dd($req->get('page')-1);
if ($req->get('page') == 1) {
$offset = $req->get('page') - 1;
} else {
$offset = ($req->get('page') - 1) * $req->get('rows');
}
$data->skip($offset);
}
if ($req->get('rows')) {
$data->take($req->get('rows'));
}
$datax['rows'] = $data->get();
$total['total'] = \DB::table('jenis_sppd')->count();
// dd($data->get());
return $total + $datax;
//
}
开发者ID:acmadi,项目名称:sp2d,代码行数:28,代码来源:UploadController.php
示例8: inbox
public function inbox()
{
$name = \Auth::user()->name;
$results = \DB::select('select * from notification.inbox_' . $name . ' order by created_at desc limit 70 offset 0');
\DB::update('update notification.inbox_' . $name . ' set n_read = true');
return view('profile.inbox')->with('results', $results);
}
开发者ID:chandrairawan,项目名称:nosproject,代码行数:7,代码来源:ProfileController.php
示例9: getIndex
public function getIndex()
{
//Obtiene todo valores
$result = \DB::table('users')->get();
//Realizar un select a ciertos campos
$result = \DB::table('users')->select(['first_name', 'last_name'])->get();
//Realizar un select con un where
// where (campo,operacion,valor)
$result = \DB::table('users')->select(['first_name', 'last_name'])->where('first_name', '<>', 'Admin')->get();
//Realizar un select con un orderBY ASC
// order (campo,tipo)
$result = \DB::table('users')->select(['first_name', 'last_name'])->where('first_name', '<>', 'Admin')->orderBy('first_name', 'ASC')->get();
//Realizar un select con un join
//join (tablajoin,tabla1.campo_id,'=',table2.campo_id)
// Al comentar el select se encuentran diferentes ids
$result = \DB::table('users')->where('first_name', '<>', 'Admin')->orderBy('first_name', 'ASC')->join('user_profiles', 'users.id', '=', 'user_profiles.user_id')->get();
//Delimitar la consulta con el join para no tener errores de ids
$result = \DB::table('users')->select('users.id', 'first_name', 'last_name', 'user_profiles.id as profiles_id')->where('first_name', '<>', 'Admin')->orderBy('first_name', 'ASC')->join('user_profiles', 'users.id', '=', 'user_profiles.user_id')->get();
//Obetener todos los campos de una table y de otra ciertos campos
$result = \DB::table('users')->select('users.*', 'user_profiles.id as profiles_id_table', 'user_profiles.user_id as user_relation', 'user_profiles.twitter')->where('first_name', '<>', 'Admin')->orderBy('first_name', 'ASC')->join('user_profiles', 'users.id', '=', 'user_profiles.user_id')->get();
//Incluir a los usuarios que no tiene perfil (administrador)
$result = \DB::table('users')->select('users.*', 'user_profiles.id as profiles_id_table', 'user_profiles.user_id as user_relation', 'user_profiles.twitter')->orderBy('first_name', 'ASC')->leftJoin('user_profiles', 'users.id', '=', 'user_profiles.user_id')->get();
//Muestra contraida la informacion
dd($result);
return $result;
}
开发者ID:jorgenaranjo,项目名称:tallerutl50,代码行数:26,代码来源:UsersController.php
示例10: post_upload
public function post_upload()
{
// fetch input data
$input = \Input::all();
// create rules for validator
$rules = array('image' => 'required|image|max:5000', 'description' => 'required|max:100');
// validate the data with set rules
$v = \Validator::make($input, $rules);
if ($v->fails()) {
// if validation fails, redirect back with relevant error messages
return \Redirect::back()->withInput()->withErrors($v);
} else {
$image = \Input::file('image');
// URL::to('/') can be changed to public_path() on a public domain
$directory = \URL::to('/') . '/uploads/';
$mkdir = public_path() . '/uploads/';
// create directory if it doesn't exist
if (!file_exists($mkdir)) {
\File::makeDirectory($mkdir, 0775, true);
}
// save the filename with the path and a unique name for the file
$filename = uniqid() . '.' . $input['image']->getClientOriginalExtension();
// move the file to the correct path
$upload_success = $input['image']->move($mkdir, $filename);
$full_path = $directory . $filename;
// store image info in the database
\DB::table('images')->insert(['description' => \Input::get('description'), 'image' => $full_path, 'user_id' => \Auth::user()->id, 'approved' => 0, 'created_at' => \Carbon\Carbon::now()->toDateTimeString()]);
return \Redirect::back()->withInput()->withErrors('Upload Successful!');
}
}
开发者ID:slopedoo,项目名称:laravel-5,代码行数:30,代码来源:ImagesController.php
示例11: editTimeline
/**
* Edit timeline /
*/
public function editTimeline($timeline_id, Request $request)
{
$timeline = \App\Timeline::where('id', '=', $timeline_id)->first();
$timeline_events = $timeline->event()->orderBy('start_date')->get();
if ($request->input('showForm') == 'true') {
return view('timelines.editTimeline')->with('showForm', 'true')->with('timeline', $timeline)->with('timeline_events', $timeline_events);
} else {
// Else submit form
// Validate the request data
$this->validate($request, ['name' => 'required']);
$user = \Auth::user();
$timeline->name = $request->input('name');
$timeline->description = $request->input('description');
$timeline->last_modified_by = $user->id;
$timeline->save();
// Delete events
for ($e = 0; $e < count($timeline_events); $e++) {
if ($request->input('delete_event' . $e) == 'true') {
\DB::table('character_event')->where('event_id', '=', $timeline_events[$e]->id)->delete();
\DB::table('event_location')->where('event_id', '=', $timeline_events[$e]->id)->delete();
$event = \App\Event::where('id', '=', $timeline_events[$e]->id)->first();
if ($event) {
$event->delete();
}
}
}
// Return success message
return view('timelines.editTimeline')->with('showForm', 'false')->with('timeline', $timeline);
}
}
开发者ID:andrewkramer,项目名称:p4,代码行数:33,代码来源:TimelinesController.php
示例12: postFinishedtask
public function postFinishedtask()
{
$reservedhour = \App\ReservedHours::find(\Request::input('hour_id'));
\App\FinishedHour::create(array('user_id' => $reservedhour->user_id, 'service_id' => $reservedhour->service_id, 'client' => $reservedhour->client, 'price' => $reservedhour->service->price, 'created_at' => date('Y-m-d')));
\DB::table('reservedhours')->where('id', '=', $reservedhour->id)->delete();
return 'true';
}
开发者ID:DiCore,项目名称:hours,代码行数:7,代码来源:TaskController.php
示例13: create
/**
* handle data posted by ajax request
*/
public function create()
{
$id = \Auth::user()->id;
$term = \Session::get('term');
$subject_id = \Session::get('subject_id');
$act_name = \Input::get('deletable');
$query = \DB::table('records')->where('enrollment_faculty_load_id', $subject_id)->where('term', $term)->select('records.id as records_id')->get();
$recid = json_decode(json_encode($query), true);
foreach ($recid as $key => $value) {
$query = \DB::table('grades')->where('records_id', $value)->select('id')->get();
$gid[] = json_decode(json_encode($query), true);
}
foreach ($gid as $key => $data) {
foreach ($data as $key2 => $data2) {
$grades_id[] = $data2['id'];
}
}
foreach ($grades_id as $key => $data) {
\DB::table('grades')->where('id', $data)->where('name', $act_name)->delete();
}
\DB::table('selected_activities')->where('load_id', $subject_id)->where('term', $term)->where('act_name', $act_name)->delete();
\DB::table('activities')->join('records', 'records.id', '=', 'activities.records_id')->where('records.enrollment_faculty_load_id', $subject_id)->where('records.term', $term)->where('act_name', 'LIKE', $act_name . '%')->delete();
$response = 'The activity named ' . $act_name . ' has been deleted.';
return \Response::json($response);
}
开发者ID:must-classrecord,项目名称:must-classrecord.github.io,代码行数:28,代码来源:SettingsController.php
示例14: anyData
public function anyData(Request $req)
{
// $data = Unitkerja::all();
// $count = App\Flight::where('active', 1)->count();
// $data = \DB::table('unit_kerja');
$data = Unitkerja::with('skpd');
// dd($data->get());
if ($req->get('filter_skdp_id')) {
$result = $data->where('skpd_id', '=', $req->get('filter_skdp_id'))->get();
// $['rows']=$result;
// return $result;
$datax['rows'] = $this->show_relasi_kolom($result);
// return $this->show_relasi_kolom($result);
return $datax + ['token' => csrf_token()];
}
if ($req->get('page')) {
// dd($req->get('page')-1);
if ($req->get('page') == 1) {
$offset = $req->get('page') - 1;
} else {
$offset = ($req->get('page') - 1) * $req->get('rows');
}
$data->skip($offset);
}
if ($req->get('rows')) {
$data->take($req->get('rows'));
}
// $datax['rows']=$data->get();
// $datax['rows']=$this->show_relasi_kolom($data->get(),'skpd','nama_skpd','skpd');
$datax['rows'] = $this->show_relasi_kolom($data->get());
$total['total'] = \DB::table('unit_kerja')->count();
// dd($data->get());
return $total + $datax + ['token' => csrf_token()];
//
}
开发者ID:acmadi,项目名称:sp2d,代码行数:35,代码来源:UnitkerjaController.php
示例15: reset
/**
* reset uses to check,
* whether user is registered,
* if it is, then update new password.
*
* @return string
*/
public function reset(Request $request)
{
$credentials = $request->only('email', 'password');
$newpassword = $request->newpassword;
$mail = $request->email;
try {
// verify the credentials and create a token for the user
if (!($token = JWTAuth::attempt($credentials))) {
return response()->json(['error' => 'invalid_credentials', 'status' => 201], 201);
}
} catch (JWTException $e) {
// something went wrong
return response()->json(['error' => 'could_not_create_token', 'status' => 500], 500);
}
if ($this->CheckInternet()) {
$adminName = \DB::select('SELECT firstname FROM users WHERE email = "' . $mail . '"');
$sendMail = new EmailController();
$content = 'Dear Administrator, your updated password is ' . $newpassword;
$subject = 'COUPLEY Password Update';
$sendMail->SendMail($mail, $adminName[0]->firstname, $subject, $content);
$hashed = \Hash::make($newpassword);
\DB::table('users')->where('email', $mail)->update(['password' => $hashed]);
return response()->json(['password' => 'uptodate', 'status' => 200], 200);
} else {
return response()->json(['error' => 'No_network', 'status' => 203], 203);
}
}
开发者ID:rajikaimal,项目名称:Coupley,代码行数:34,代码来源:AdminPwdController.php
示例16: index
/**
* Display FRONT PAGE
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$programs = \App\Program::orderBy(\DB::raw('RAND()'))->take(4)->get();
$programs_high_bonus = \App\Program::orderBy(\DB::raw('RAND()'))->take(4)->get();
$program_logos = \App\Program::get(array('logo_bgcolor', 'slug'));
return view(\App\Template::view('page.front-page'))->with(['menu_item' => 'home', 'edit_mode' => false, 'programs' => $programs, 'programs_high_bonus' => $programs_high_bonus, 'program_logos' => $program_logos]);
}
开发者ID:kjellberg,项目名称:affecms,代码行数:12,代码来源:PageController.php
示例17: actualiza
public function actualiza(Request $request, $id)
{
$cantdb = \DB::table('productos')->select('CantExistente')->where('ID', $id)->first();
$cantinput = $request->input('cantidads');
$resul = $cantdb->CantExistente - intval($cantinput);
\DB::table('productos')->where('ID', $id)->update(['CantExistente' => $resul]);
$productoid = \DB::table('productos')->select('ID')->where('ID', $id)->first();
$cantinput = $request->input('cantidads');
$nombreus = $request->input('usuarios');
$nombreus2 = \DB::table('usuarios')->select('Nombre')->where('ID', $nombreus)->first();
$nombrpr = \DB::table('productos')->select('Nombre')->where('ID', $id)->first();
$salida = new salidasModelo();
$salida->Producto_ID = $productoid->ID;
$salida->Nombre_Producto = $nombrpr->Nombre;
$salida->Cantidad = intval($cantinput);
$salida->Usuario_ID = intval($nombreus);
$salida->Nombre_salida = $nombreus2->Nombre;
$salida->save();
/* $salida=salidasModelo::getInfoSalida($id);
dd($salida);
$vista = view('generapdf', compact($salida));
$dompdf = \App::make('dompdf.wrapper');
$dompdf->loadHTML($vista);
return $dompdf->stream();*/
return Redirect()->back();
// return view('generapdf');
}
开发者ID:Jorgelp01,项目名称:proyectofinal,代码行数:27,代码来源:indexController.php
示例18: autocomplete
public function autocomplete()
{
dd(Input::get('companyName'));
if (Input::get('companyName')) {
$term = Input::get('term');
$results = array();
$queries = \DB::table('emp_table')->where('emp_name', 'LIKE', '%' . $term . '%')->take(5)->get();
foreach ($queries as $query) {
$results[] = ['id' => $query->id, 'value' => $query->company_name];
}
return \Response::json($results);
}
if (Input::get('employeeName')) {
dd('lkhkhlk');
$term = Input::get('term');
$results = array();
$queries = \DB::table('emp_table')->where('emp_name', 'LIKE', '%' . $term . '%')->where('emp_status', '=', 'Active')->take(5)->get();
foreach ($queries as $query) {
$results[] = ['id' => $query->emp_id, 'value' => $query->emp_name];
}
dd('sss');
return \Response::json($results);
} else {
}
}
开发者ID:harshithanaiduk,项目名称:iclock-newtheme,代码行数:25,代码来源:SearchController.php
示例19: indexjson
public function indexjson($month, $year)
{
$eventList1 = Events::where('e_type', 'single')->where(\DB::raw('MONTH(e_date)'), '=', $month)->where(\DB::raw('YEAR(e_date)'), '=', $year)->orWhere('e_type', 'annual')->where(\DB::raw('MONTH(e_date)'), '=', $month)->where(\DB::raw('YEAR(e_date)'), '<=', $year)->get();
$eventList2 = Events::where('e_type', '!=', 'single')->where('e_type', '!=', 'annual')->get();
$eventList = $eventList1->merge($eventList2);
return response()->json($eventList);
}
开发者ID:bigoldv8,项目名称:Calendar-Package,代码行数:7,代码来源:EventsController.php
示例20: postQuery
public function postQuery(Request $request)
{
// User::where(function($query) {
// $query->where('name', '=', 'John')
// ->orWhere('votes', '>', 100);
// })
// ->get();
$this->validate($request, ['infinitive_it' => 'min:2', 'infinitive_en' => 'min:2', 'gerund_it' => 'min:2', 'past_part_it' => 'min:2']);
// $infinitive_it = $request->infinitive_it;
// $infinitive_en = $request->infinitive_en;
// $gerund_it = $request->gerund_it;
// $past_part_it = $request->past_part_it;
// $verbs = new \App\Verb();
// $verbs = \App\Verb::where(function($query) use ($request){
// $query->Where($verbModel->infinitive_it, '=', $request->infinitive_it)
// ->orWhere($verbModel->infinitive_en, 'LIKE', $infinitive_en)
// ->orWhere($verbModel->gerund_it, '=', $gerund_it)
// ->orWhere($verbModel->past_part_it, '=', $past_part_it);
// })
// ->get();
$verbs = \DB::table('verbs')->orWhere('infinitive_it', '=', $request->infinitive_it)->orWhere('infinitive_en', '=', $request->infinitive_en)->orWhere('gerund_it', '=', $request->gerund_it)->orWhere('past_part_it', '=', $request->past_part_it)->get();
//dump($verbs);
//dump($request);
if (empty($verbs)) {
\Session::flash('flash_message', 'Verb not found.');
return redirect('/verbs/query');
}
return view('verbs.query')->with('verbs', $verbs)->with('request', $request);
}
开发者ID:anthon94,项目名称:p4,代码行数:29,代码来源:VerbController.php
注:本文中的App\Http\Controllers\DB类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论