nero

Experience

1,660

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 0 Lessons Completed
  • 0 Favorites

15th June, 2018

nero started a new conversation How Do I Create Multilingual URLs In Laravel 5? • 2 months ago

How do I create multilingual URLs in laravel 5?

I have 2 languages. That is Indonesian and English

view/lang/id/routes.php:

return [
     'news' => 'berita',
];

view/lang/en/routes.php:

return [
     'news' => 'news',
];

routes/web.php Route::prefix('news')->group(function() { Route::get('', 'News\[email protected]')->name(''); Route::get('detail/{id}/{slug}', 'News\[email protected]')->name('news.detail'); });

app\Http\Middleware\Localization.php: public function handle($request, Closure $next) { if ( \Session::has('locale')) { \App::setLocale(\Session::get('locale'));

                // You also can set the Carbon locale
                Carbon::setLocale(\Session::get('locale'));
         }
        return $next($request);
    }

So the URL will be as follows: If Indonesian: www.domain.com/berita/

If English: www.domain.com/news/

30th May, 2018

nero left a reply on Please Help City_id For Jobs Table And Table Company • 2 months ago

@lostdreamer_nl

city or work location is different from the city of the company. Examples eg mining companies. Company Address in City A while address work in City B

nero started a new conversation Please Help City_id For Jobs Table And Table Company • 2 months ago

Request referrals and help:

I have a table:

cities table: id,name

companies table: id,city_id, name

jobs table: id,city_id,title, description

city_id in the companies table serves for the company's city data (company address). city_id in the jobs table works for city data work location.

How to write query builder if I want to display data like below? title, description, company_name, job_location, company_location

18th May, 2018

nero started a new conversation I Want To Ask Related News Category Updates In Multiple Select Form • 3 months ago

I want to ask related news category updates in multiple select form.

News Table:
- id
- title
- news

Table Category:
- id
- name

Table CategoryNews:
- id
- news_id
- category_id

News Category: Legal, Sports, Social, Internet, Entertainment, Education

Sample case: Initially I save data eg news with the title "Knowing Fake News on the Internet" with the category of Social, Internet, and Education. Then I want to change the category of Social and Internet.

The question is: How to write a script to convert the category data into Social and Internet only. And Education Categories automatically delete at execution Update news data?

Here's my code snippet. This code has succeeded to add category data.

$data = $request->all();
foreach ($data['category'] as $i => $value) { 
    $jobe= CategoryNews::updateOrcreate(
        [ 
            'news_id' => $id,
            'category_id' => $data['category'][$i]
        ],
        [
        ]
    );
}

nero left a reply on Undefined Offset: 2 • 3 months ago

@lostdreamer_nl

What if we want to delete the data we have before? if you remove it in multiple select box?

17th May, 2018

nero left a reply on Undefined Offset: 2 • 3 months ago

@lostdreamer_nl

I've tried but it works. Data is double. Insert data can, but double data Update data can not.

nero started a new conversation Undefined Offset: 2 • 3 months ago

Initially I had 2 types of education. Then I want to add 1 education but the error message as follows:

"Undefined offset: 2"

Here's my code snippet:

        foreach($request->educatione as $key=>$cond){
        $ServEdu=JobEducation::updateOrCreate(
            [
               'id'=>$request->ho[$key]
            ],
            [
                'job_id' => $id,
                'education_id'=>$cond          
            ]
        ); 
    }

Anyone help to improve my code above?

16th May, 2018

nero started a new conversation How To Use The Correct UpdateOrcreate In Laravel? • 3 months ago

How to use the correct updateOrcreate in Laravel?

I want to add and change data in the same code. I've been using updateOrcreate but the results are not as desirable.

The code can only change the data, but can not change the data.

My table:

jobs:

    id
    title
    deskription

educations:

    id
    name

job_educations:

    id
    job_id
    education_id

Here's my code snippet:

    public function update(Request $request, $id)
      {                
        $input = Input::all();
            for($i=0;$i<count($condition);$i++){
                JobEducation::updateOrCreate(
                    [
                            'job_id'=>$id, 
                     ],
                     [
                         'job_id'=>$id,                
                            'education_id' => $input ['education'][$i]                   
                    ]
             );
    }

My requirement: I want to change the existing data and add new data.

Can anyone fix my code?

nero left a reply on How Do I Change The Multi-line Data? • 3 months ago

@N3

Yes, exactly. if necessary can add to education.

nero left a reply on How Do I Change The Multi-line Data? • 3 months ago

Hello @Snapey Can you help me constrain above?

nero started a new conversation How Do I Change The Multi-line Data? • 3 months ago

I have a simple table:

jobs: id title description

educations: id name

job_educations: id job_id education_id

Form edit.blade.php I have created. Next I want to create code in the controller to edit educational data.

My needs:

  • The data in the job_educations table is more multiple education.
  • I want to change educational data and add educational data in job_educations table. Here's the code snippet:

public function update(Request $request, $id) { $educations=$request->get('education'); foreach ($educations as $key => $education) { $data=[

            'education_id' => $education
        ];
        \DB::table('job_educations')->where('job_id', $id)->where('education_id',$key)->update($data);
}

How to fix the above code correct?

10th May, 2018

nero left a reply on Old Values ​​subcategory Does Not Work After Submit • 3 months ago

I have an input form: Title, Description, Category and Sub Category and other fields.

I want to check validation for example title not yet filled. But other forms have been filled. The validation system has been successful.

Dynamically Select Category (parent) and select Sub Category (child) is working properly.

But the problem here is when click Submit Old Values ​​sub category does not work (empty). I hope the subcategory I have selected is empty after submitting. But the actual old values ​​sub category is empty

9th May, 2018

nero left a reply on Old Values ​​subcategory Does Not Work After Submit • 3 months ago

@Cronix

Sorry different point. This one is a dynamic select option category (parent) and subcategory (child). If yesterday multiple select option

nero left a reply on Old Values ​​subcategory Does Not Work After Submit • 3 months ago

@Snapey

I've tidied up my code

8th May, 2018

nero left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Array Given • 3 months ago

@Snapey

When I change the code of this section as per your code like the following: @if(in_array($education->translation_of,old('education',[])))

Still the following error message appears: "htmlspecialchars() expects parameter 1 to be string, array given (View:

7th May, 2018

nero left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Array Given • 3 months ago

                                            <select name="education[]" id="education" class="form-control sselecter  input-lg" multiple="true" data-placeholder="@lang('global.Select Level Education')"  required>
                                            @foreach ($educations as $education)                                                    
                                            <option value="{{ $education->translation_of}}"
                                                
                                                @if(in_array($education->translation_of,old('education')))    
                                                    selected="selected"
                                                @endif >{{ $education->name }}</option>
                                            @endforeach
                                            </select>

nero left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Array Given • 3 months ago

@Snapey

I've fixed the above error, but still an error like this: "in_array() expects parameter 2 to be array, null given (View:

nero left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Array Given • 3 months ago

@Snapey

I've tried the code from you. But still the following error message

"Parse error: syntax error, unexpected ':', expecting '('"

nero left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Array Given • 3 months ago

@Snapey

I do not understand all of your answers above.

please provide examples of writing code according to my code above

nero left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Array Given • 3 months ago

@Snapey

If other fields are filled all does not appear error. But if only the contents of the education section just appeared error

6th May, 2018

nero left a reply on How To Store Multiple Select And Multi Row Data In Laravel 5? • 3 months ago

@AhmadGomaa

translation_of is the primary key. I created this name in multi language

nero started a new conversation Htmlspecialchars() Expects Parameter 1 To Be String, Array Given • 3 months ago

I have a form like this.

<select name="education[]" id="education" class="form-control sselecter  input-lg" multiple="true" data-placeholder="@lang('global.Select Level Education')" value="{{old('education') }}" required>
    @foreach ($educations as $education)                                                    
    <option value="{{ $education->translation_of}}"@if (old('education')==$education->translation_of)selected="selected"@endif> {{ $education->name }} </option>
    @endforeach
</select>

But when the contents of the data then Submit the following error message appears: "htmlspecialchars() expects parameter 1 to be string, array given (View:

nero started a new conversation How To Store Multiple Select And Multi Row Data In Laravel 5? • 3 months ago

How to store multiple select and multi row data in laravel 5?

I have a table:

educations:
    - id
    - name

job_educations:
    - id
    - education_id

Controller:
    $educations = $request->input('education');
    foreach ($educations as $education) {
        if(!empty($education))
        {
                JobEducation::create([
                'job_id' => $jobID,
                    'education_id'   => $education
                ]);
        }
    }   



Blade:
    <form role="form" files="true"  enctype="multipart/form-data" method="POST" action="{{ 
        route('jobs.create') }}" novalidate>
    <select name="education[]" id="education" class="form-control sselecter select2-    
        hidden-accessible input-lg" multiple tabindex="-1" aria-hidden="true" data-
        placeholder="@lang('global.Select Level Education')" value="{{ old('education') }}" 
        required>
        @foreach ($educations as $education)
            <option value="{{ $education->translation_of}}"@if      
            (old('education')==$education->translation_of)selected="selected"@endif> {{ 
            $education->name }} </option>
        @endforeach
    </select>

Saya sudah mencoba code diatas tapi muncul pesan error berikut ini: "Invalid argument supplied for foreach()"

4th May, 2018

nero left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 3 months ago

@Vilfago Sorry after I check your program suggestion code has been successful. Thank you for your support. Good Job

nero left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 3 months ago

@jlrdw

Do you have a solution?

nero left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 3 months ago

@Vilfago

Maximum salary validation must be greater than the minimum salary has been successful. However, when the maximal salary value is greater than the minimum salary the following message appears:

"The min salary must be a number."

As text conversion to numeric still has not worked

nero left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 3 months ago

@Vilfago

error message appears:

"Parse error: syntax error, unexpected ';', expecting ']'"

nero left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 3 months ago

@Vilfago

error message appears:

"Can't use method return value in write context"

nero left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 3 months ago

@Vilfago

The code you suggest works if numerical to numeric (Does not use conversions). But if text conversion to numeric does not work. How to validate system from text to numeric?

nero left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 3 months ago

@somnathsah

How do I enter your code into my code that I wrote above?

nero started a new conversation How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 3 months ago

I have a table structure: min_salary(float); max_salary(float);

I have form input minimum salary and maximum salary with comma format:

Here's the code snippet for validation: $validatedData = $request->validate([ 'min_salary' => 'required', 'max_salary' => 'required', ]);

My question: How to validate the maximal salary to be greater than the minimum salary?

3rd May, 2018

nero started a new conversation How To Convert From Salary • 3 months ago

I have a pay input form.

How to convert from salary to 100123.12?

nero started a new conversation Old ('subcategory') Does Not Work • 3 months ago

I have problems in dynamic categories and sub categories.

old ('subcategory') does not work.

Code Blade: Category: <option value="" data-type=""@if (old('category')=='' or old('category')=='')selected="selected"@endif> Category @foreach ($categories as $cat) <option value="{{ $cat->id}}"@if (old('category')==$cat->id)selected="selected"@endif> {{ $cat->name }} @endforeach

Sub Category:

Java Script: var $ = jQuery.noConflict(); $('#category').change(function() { $.get('categories/' + this.value + '/subcategories.json', function(subcategories) { var $subcategory = $('#subcategory');

        $subcategory.find('option').remove().end();

        $.each(subcategories, function(index, subcategory) {
           // $subcategory.append('<option value="' + subcategory.id + '">' + subcategory.name + '</option>');
            $subcategory.append($('<option/>').attr('value', subcategory.id).text(subcategory.name)); 
        });
    });
});

$(document).ready(function() {
    $(".category option[value='0']").attr("disabled","disabled");
    $(".subcategory option[value='0']").attr("disabled","disabled");
});

Router: Route::get('/jobs/categories/{code}/subcategories.json', function($code){ return \App\Category::where('active',1)->where('parent_id',$code)->get();

nero started a new conversation I Have Minimum Input Form Of Salary And Maximum Salary • 3 months ago

I have minimum input form of salary and maximum salary.

How to make validation to maximize salary must be bigger than minimum salary?

following my code:

Validation:

  $validatedData = $request->validate([
    'min_salary' => 'required|',
    'max_salary' => 'required|',

]); v

31st March, 2018

nero left a reply on How Do I Authenticate User Tables And User_details Tables? • 4 months ago

@franckysolo

I have two user tables:

users table: id, name, email, password

user_details table: user_id type address telp city

nero started a new conversation How Do I Authenticate User Tables And User_details Tables? • 4 months ago

I am using laravel version 5.6. I have two user tables: users: -id -name -email -password

user_details: -user_id -type -address -telp -city

The question is:

  1. How to create database relation of users table and user_details table?
  2. How do I create user authentication with type = 'Admin' to get into admin page?

26th March, 2018

nero left a reply on After Login Process, Login Form Can Still Be Accessed. It Should Be Direct To Home. • 4 months ago

Mode User.php: class User extends Authenticatable { use Notifiable;

protected $fillable = [
    'name', 'email', 'password','type',
];

protected $hidden = [
    'password', 'remember_token',
];

}

Middleware: CompanyLoginMiddleware.php: class CompanyLoginMiddleware {

public function handle($request, Closure $next)
{
        if(Auth::check() && Auth::user()->type==1)

    {
         return $next($request);
    }
        if(Auth::check() && Auth::user()->type==2)

    {
         return redirect('company/login');
    }       
    else{
        return redirect('company/login');
    }
}

}

CompanyLoginController.php: class CompanyLoginController extends Controller { use AuthenticatesUsers; protected $redirectTo = '/home';

public function __construct()
{
     $this->middleware('guest:companylogin', ['except' => ['logout']]);
}
public function showLoginForm()
{
  return view('company.auth.login');

}
public function login(Request $request)
{
  $this->validate($request, [
    'email'   => 'required|email',
    'password' => 'required|min:6'
  ]);

  if (Auth::guard('companylogin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
    return redirect()->intended(route('company.dashboard'));
  }

return redirect()->back(); }

Kernel.php: protected $routeMiddleware = [ 'companylogin' => \App\Http\Middleware\CompanyLoginMiddleware::class,//Tambah Kayetanus ];

Handler.php: class Handler extends ExceptionHandler { protected $dontReport = [ // ];

/**
 * A list of the inputs that are never flashed for validation exceptions.
 *
 * @var array
 */
protected $dontFlash = [
    'password',
    'password_confirmation',
];

public function report(Exception $exception)
{
    parent::report($exception);
}

public function render($request, Exception $exception)
{

 if ($this->isHttpException($exception)) {
    switch ($exception->getStatusCode()) {

        // not authorized
        case '403':
            return redirect()->back();
            break;

        // not found
        case '404':
            return redirect()->back();
            break;

        // internal error
        case '500':
            return redirect()->back();
            break;

        default:
            return $this->renderHttpException($exception);
            break;
    }
} else {
    return parent::render($request, $exception);
}       

}   

protected function unauthenticated($request, AuthenticationException $exception)
{
    if ($request->expectsJson()) {
        return response()->json(['error' => 'Unauthenticated.'], 401);
    }

            $guard = array_get($exception->guards(), 0);
        switch ($guard) {
            case 'companylogin':
                $login = 'company.login';
            break;
            default:
                $login = 'login';
            break;
        }
    return redirect()->guest(route($login));
}

}

RedirectIfAuthenticated.php: class RedirectIfAuthenticated { public function handle($request, Closure $next, $guard = null) { /if (Auth::guard($guard)->check()) { return redirect('/homex'); } return $next($request);/

          switch ($guard) {
    case 'companylogin':
      if (Auth::guard($guard)->check()) 
      {

              // if (\Auth::user() && \Auth::user()->type == 1)
           if(Auth::check() && Auth::user()->type==1)
          {
                   return redirect()->route('company.dashboard');
          }
      }
      break;
    default:
      if (Auth::guard($guard)->check()) {
                      //if (\Auth::user() && \Auth::user()->type == 2)
               if(Auth::check() && Auth::user()->type==2)
            {
          return redirect('/');
                      }

      }
      break;
  }
  return $next($request);
}

}

nero left a reply on After Login Process, Login Form Can Still Be Accessed. It Should Be Direct To Home. • 4 months ago

Still failing.

Login form can still be accessed when the user has been authenticated

25th March, 2018

nero left a reply on After Login Process, Login Form Can Still Be Accessed. It Should Be Direct To Home. • 4 months ago

How to write script in laravel?

nero started a new conversation After Login Process, Login Form Can Still Be Accessed. It Should Be Direct To Home. • 4 months ago

I have 3 type user. User Member, User Company and Admin.

Middleware: CompanyMiddleware, AdminMiddleware

I have a problem at login Company. The case is Once the login form login process can still be accessed or still appear on the dashboard page. It should be direct to home.

That's what causes it? how to handle it?

I am using laravel 5.6

1st September, 2017

nero left a reply on Please How To Upgrade Laravel Version 5.4   To 5.5 • 11 months ago

Hello Hujjat,

By using composer update: Can i adjust to my finished project using laravel 5.4 ?? Is there any program script that should be adjusted? Or auto adjust?

nero started a new conversation Please How To Upgrade Laravel Version 5.4   To 5.5 • 11 months ago

Please How to upgrade laravel version 5.4 to 5.5

5th October, 2016

nero started a new conversation Adding User Type Field In Form Register User • 1 year ago

I'm using 5.3 laravel In the users table I add a field type. The following structure: - id - type_id - name - email - password - remember_token - created_at -updated_at

And following table structure types: - id - type - created_at - updated_at

Questions to: How do I register form part of the implementation of the user, the controller and the model in laravel 5.3?

22nd July, 2016

nero left a reply on The Result Is A Picture Can Not Appear In Laravel • 2 years ago

Route::post('ajaximage', function(){ if(empty($FILES['file'])) { exit(); } else { /--------------------Start Pengolahan Gambar---------------/ $size = Input::file('file')->getSize(); // ukuran asli file $tmp_name=Input::file('file')->getPathName(); $image = Input::file('file'); // form input gambar //$file = Request::file('file'); $filename = time() . '.' . $image->getClientOriginalExtension(); // Ektensi file asli -----pakai /----start buat nama file-----/ $date=date('ymd'); $hours=date('His'); $kyt='KILO'; $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; $acakx = ""; for($i=0; $i<12; $i++) $acakx.=$chars[mt_rand(0,strlen($chars)-1)]; $name_rand1=$date.$hours.$kyt.$acakx; $name_rand2 = rand(1000,100000)."-".$filename; $file_name=$name_rand1."content".$name_rand2; $finish_file_name = strtolower($file_name); /----end buat nama file-----/

    $dir_name = "uploads/event/content/"; // folder tempat upload file
    $path = public_path($dir_name.$finish_file_name); // lokasi penyimpanan gambar 
    $widthx=450; //lebar gambar
    $sizexx=GetimageSize($tmp_name); //Mengambil ukuran gambar yang asli
    $heightx=round($widthx*$sizexx[1]/$sizexx[0]); // rumus konversi mengecilkan gambar
    
    Image::make($image->getRealPath())->resize($widthx, $heightx)->save($path); // Membuat ulang gambar sesuai dengan ukuran baru
        

    //$destinationPath = public_path().'/uploads/event/content/';
    //$filename = $file->getClientOriginalName();
    //$file->move($destinationPath, $filename);
    echo url().'/uploads/event/content/'.$finish_file_name;
}

});

nero left a reply on The Result Is A Picture Can Not Appear In Laravel • 2 years ago

Snapey: Code to upload and display images I wrote in router.php not view

nero left a reply on The Result Is A Picture Can Not Appear In Laravel • 2 years ago

The process of uploading the image file can be. But when that data can not be performed.

18th July, 2016

nero left a reply on The Result Is A Picture Can Not Appear In Laravel • 2 years ago

If the development server, but when uploaded to the server hosting the picture can not appear

nero started a new conversation The Result Is A Picture Can Not Appear In Laravel • 2 years ago

I've uploaded my project laravel 5 to shared hosting: My laravel project stored in: / Users / nero / laravel.

Folders to upload pictures I put in Users / nero / laravel / public / uploads code to display the image I wrote in router.php. Here's the code: echo asset('/uploads/event/content/'.$finish_file_name);

The result is a picture can not appear. Does the code to display the image there is something wrong?

Can you help me?

16th July, 2016

nero started a new conversation Why Css And Js Does Not Work In Shared Hosting? • 2 years ago

I've uploaded my project laravel 5 to shared hosting: My laravel project stored in: / Users / nero / laravel.

Css files, JSS, image I keep in the public folder: Users / nero / laravel / public

Then I copy all of the files in / Users / nero / laravel / public to / Users / nero / public_html

File front.blade.php:

Application has been able to walk, but why css style can not work? Images can appear but css and js can not work.

Can you help me?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.