1 year ago

how to show project name in limited characters in Laravel?

Posted 1 year ago by Flex

I need show My laravel application project name with limited characters. that means as an example consider some project name contains more than 10 letters, then I need only show 10 characters.

My project name create controller is

public function store(Request $request)
        $this->validate($request, [
            'name'     => 'required|min:3',
            'notes'    => 'required|min:10',
            'color'    => 'required',
            'group'    => 'required',
            'status'   => 'required'

        $project = new Project;
        $project->project_name   = $request->input('name');
        $project->project_status = $request->input('status');
        $project->group          = $request->input('group');
        $project->color          = $request->input('color');
        $project->project_notes  = $request->input('notes');
        $project->user_id        = Auth::user()->id;

        $duplicate = Project::where('project_name',$project->project_name)->first();
            return redirect()->route('projects.index')->with('warning','Title already exists');

        return redirect()->route('projects.index')->with('info','Your Project has been created successfully');

and project name showing blade file is

<div class="row">
             @foreach ($projects as $proj)
               <div class="col-md-3" style="border:3px solid {!!$proj->color!!};margin-left:5px;margin-bottom: 5px;">
               <h2><a href="/projects/{{ $proj->id }}">{!! $proj->project_name !!}</a></h2>

then how can I show only 10 charactors in My blade file?

Please sign in or create an account to participate in this conversation.