مشكلة في ادخال كل قيم كل اللغات في قاعدة البينات و اختيار المحتوي بالاعتماد علي قاعدة البيانات

السلام عليكم أنا مبتدئة في Laravel وأعمل على مشروع التخرج وهو عباره عن موقع لعمل استبيان Survey الموقع تم إنشائة ولكن ما احتاج أن أعمله هو أني اجعله متعدد...

السلام عليكم

أنا مبتدئة في Laravel وأعمل على مشروع التخرج وهو عباره عن موقع لعمل استبيان Survey
الموقع تم إنشائة ولكن ما احتاج أن أعمله هو أني اجعله متعدد اللغات،
أتبعت الدرس في هذا الرابط:
بعنوان : ادخال كل قيم كل اللغات في قاعدة البينات و اختيار المحتوي بالاعتماد علي قاعدة البيانات
للاستاذ: Abdel Aziz Hassan
https://5dmat-web.com/ar/video/471
اخترت الصفحة الرئسية (Home) بما انها لاتحتوي على معلومات كثيره واستطيع الأن تخزين عنوان الاستبيان مع الوصف في الداتا بيس باللغتين. زي كذا:
a:2:{s:2:"en";s:11:"Education";s:2:"ar";s:16:"التعليم";}

^ نفس الموجود في الدرس.
ولكن المشكله هي عندما ارغب بعرض العنوان في الصفحة الرئيسية بلغة واحده EN وعند اختيار AR يتغير للغة العربية كما حدث بالدرس لم استطيع استخدام Unserialize، إذا كتبت جزد الكود الموجود في الدرس هذا مايحدث معي: "unserialize(): Error at offset 31 of 54 bytes

هذا كود الصفحة الرئسية:
@extends('master')
@section('title', 'Home')

@section('content')
    <div class="container">
        <div class="row banner">

            <div class="col-md-12">
              <ul class="collection with-header">
                  <li class="collection-header">
                      <h2 class="flow-text">Recent Surveys
                          <span style="float:right;">{{ link_to_route('new.survey', 'Create new') }}
                          </span>
                      </h2>
                  </li>
                  @forelse ($surveys as $survey)
                    <li class="collection-item">
                      <div>
                          {{ link_to_route('detail.survey', $survey->title, ['id'=>$survey->id])}}
                          <a href="survey/view/{{ $survey->id }}" title="Take Survey" class="secondary-content"><i class="material-icons">send</i></a>
                          <a href="survey/{{$survey->id}}/edit" title="Edit Survey" class="secondary-content"><i class="material-icons">edit</i></a>
                          <a href="survey/answers/{{ $survey->id }}" title="View Survey Answers" class="secondary-content"><i class="material-icons">textsms</i></a>
                      </div>
                      </li>
                  @empty
                      <p class="flow-text center-align">Nothing to show</p>
                  @endforelse
              </ul>


            </div>

        </div>
    </div>
@endsection


------------------------------------------------------------------
وهذا هو كود Surveycontroller.php:

<?php

namespace App\Http\Controllers;

use App\Survey;
use App\Answer;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redirect;

class SurveyController extends Controller
{

  public function home(Request $request)
  {
    $surveys = Survey::get();
    return view('home', compact('surveys'));
  }

  # Show page to create new survey
  public function new_survey()
  {
    return view('survey.new');
  }

  public function create(Request $request, Survey $survey)
  {
    //$arr = $request->all();

    // $request->all()['user_id'] = Auth::id();
  //  $arr['user_id'] = Auth::id();

    //$surveyItem = $survey->create($arr);
    $survey->title= serialize($request->title);
    $survey->description= serialize($request->description);
    $survey ->save();
    return Redirect::to("/survey/{$survey->id}");
  }

  # retrieve detail page and add questions here
  public function detail_survey(Survey $survey)
  {
    $survey->load('questions');
    return view('survey.detail', compact('survey'));
  }


  public function edit(Survey $survey)
  {
    return view('survey.edit', compact('survey'));
  }

  # edit survey
  public function update(Request $request, Survey $survey)
  {
    $survey->update($request->only(['title', 'description']));
    return redirect()->action('SurveyController@detail_survey', [$survey->id]);
  }

  # view survey publicly and complete survey
  public function view_survey(Survey $survey)
  {
    $survey->option_name = unserialize($survey->option_name);
    return view('survey.view', compact('survey'));
  }

  # view submitted answers from current logged in user
  public function view_survey_answers(Survey $survey)
  {
    $survey->load('questions.answers');
    // return view('survey.detail', compact('survey'));
    // return $survey;
    return view('answer.view', compact('survey'));
  }

  // TODO: Make sure user deleting survey
  // has authority to
  public function delete_survey(Survey $survey)
  {
    $survey->delete();
    return redirect('');
  }

}

0 التعليقات


    لا يوجد تعليقات حتي الان

اضف تعليق


يجب ان يكون لديك حساب في الموقع تسجيل الدخول او تسجيل عضوية جديدة

خدمات ويب الفريق