Я использую post man для проверки моего API, поэтому, когда я отправляю токен в заголовке, токен не предоставляется, но когда я передаю его в текстовом формате в формате json, я получаю результат успеха, поэтому я хочу получить результат успехакогда я передаю свой токен в заголовке
Как я могу сделать это изменение ??
Это мой контроллер Postcompanies
class CompaniesController extends Controller
{
public function index(Request $request)
{
# code...
// $Ads = ads::all();
// return $this->sendResponse($Ads->toArray(), 'Ads read succesfully');
// This is the name of the column you wish to search
$input = $request->all();
$validator = Validator::make($input, [
'user_id'=> 'required'
] );
$Companies = Companies::where('user_id','=', $request->user_id)->first();
return response()->json(['Companies'=>$Companies]);
}
public function stockcompanies (Request $request){
$input = $request->all();
$validator = Validator::make($input, [
'title'=> 'required',
'description'=> 'required',
'logo_path'=> 'image|nullable|max:1999'
] );
$user_id = Auth::id();
if($request->hasFile('logo_path')){
// Get filename with the extension
$filenameWithExt = $request->file('logo_path')->getClientOriginalName();
// Get just filename
$filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
// Get just ext
$extension = $request->file('logo_path')->getClientOriginalExtension();
// Filename to store
$fileNameToStore= $filename.'_'.time().'.'.$extension;
// Upload Image
$path = $request->file('logo_path')->storeAs('public/cover_images', $fileNameToStore);
} else {
$fileNameToStore = 'noimage.jpg';
}
if ($validator -> fails()) {
# code...
return response()->json($validator->errors());
}
//$Cards = CreditCards::create($input,$user_id);
$companies = Companies::create([
'title' => $request->get('title'),
'description' => $request->get('description'),
'logo_path' => $fileNameToStore,
'user_id' => $user_id
]);
return response()->json(['Companies'=>$companies]);
}
}
, и это мой API:
Route::group(['middleware' => ['jwt.auth']], function() {
Route::post('postmycompanies', 'CompaniesController@stockcompanies');
Route::get('test', function(){
return response()->json(['foo'=>'bar']);
});