REQUEST 관련 구문 정리

2020.10.22 22:57

Admin Views:25

 

request()->get('page')
request()->url()
URL::previous()

$request->validate([
  'mod' => 'required|string',
  'mid' => 'required|integer',
  'fid' => 'nullable|numeric',
]);

$validator = Validator::make($request->all(), [
  'id' => 'nullable|numeric',
  'type' => 'required|string',
]);

if ($validator->fails()) {
  return response()->json(["success" => 0, "error" => 1, "data" => '' ], 200);

}

$request->getQueryString();
if(!$request->hasFile('file')) return false;
$newrequest = new IlluminateHttpRequest();
$newrequest->setMethod('POST');
$newrequest->files->set('file', $file);
$newrequest->request->add(['mod'=>'Letter','mid' =>$id]);
$request->merge(['id'=>$id,'type' =>'update']);

try {
  $file = $request->file('file');
  $file->getClientOriginalName();
  $file->getClientOriginalExtension();
  $extension = pathinfo($Name, PATHINFO_EXTENSION);
  $request->file('file')->store($fileINFo->path, 'public');
  Storage::disk('storage')->put($thumb_file, $Photo);
  Storage::disk('storage')->url($thumb_file);
  if(Storage::disk($fileINFo->disk)->exists($source))
  Storage::disk('storage')->exists(HttpHandler::getRealPath($fileINFo->filename,2)) == TRUE
  list($width, $height, $type, $attr) = getimagesize($file);
  $file->getClientMimeType();
  $file->getSize();
}

catch (Exception $e)
{
 if ($request->ajax()) return response()->json(['msg'=>'No Data from server!','error'=> 1, 'data' => $e], 200);
}

catch (Throwable $e)
{
  report($e);
  if ($request->ajax()) return response($e,400);
  else return false;
}

return redirect()->route('show', [ 'id' => $request->srl ]);
return redirect()->back();
return redirect()->away($url);
if((Storage::disk('public')->exists($path)) === FALSE) Storage::disk('public')->makeDirectory(parse_url($path, PHP_URL_PATH));

if($image && Storage::disk('storage')->exists($image)) Storage::disk('storage')->delete($image);

$childs = array_unique($request->childlist)
$oldData = data_get($oldcamp, '*.child_profile_id');
$delData = array_diff($oldData,$childs);
$_PRINTED = data_get($child->SponsorChild, '*.profile_printed', 0);
$PRINTED = Arr::where($_PRINTED, function ($value, $key) { return $value == 0; });


$TODAY = date("Y-m-d");
$fistDay = new DateTime('first day of '.$TODAY);
$from = $fistDay->modify('sunday last week')->format('Y-m-d');


$campaign = File::find($id);
$newcampaign = $campaign->replicate();
$newcampaign->name = $campaign->name;
$newcampaign->save();
File::where('id', $id)->update(['logo' => $logo]);


public function __construct(Request $request)
{
  $this->middleware('auth');
  $this->middleware(function ($request, $next) {
    $Users = explode(",", config('app.userRole'));
    $this->admin = (in_array(Auth::user()->email,$Users)) ? 1 : 0;
    View::share('admin', $this->admin);
    return $next($request);
  });
}